Lines 28-35
Link Here
|
28 |
import org.eclipse.osgi.util.NLS; |
28 |
import org.eclipse.osgi.util.NLS; |
29 |
import org.eclipse.pde.core.IModel; |
29 |
import org.eclipse.pde.core.IModel; |
30 |
import org.eclipse.pde.core.IModelProviderEvent; |
30 |
import org.eclipse.pde.core.IModelProviderEvent; |
31 |
import org.eclipse.pde.core.plugin.IPluginModelBase; |
31 |
import org.eclipse.pde.core.plugin.*; |
32 |
import org.eclipse.pde.core.plugin.PluginRegistry; |
|
|
33 |
import org.eclipse.pde.internal.core.*; |
32 |
import org.eclipse.pde.internal.core.*; |
34 |
import org.eclipse.pde.internal.core.ifeature.*; |
33 |
import org.eclipse.pde.internal.core.ifeature.*; |
35 |
import org.eclipse.pde.internal.core.itarget.*; |
34 |
import org.eclipse.pde.internal.core.itarget.*; |
Lines 548-553
Link Here
|
548 |
protected void handleReload() { |
547 |
protected void handleReload() { |
549 |
String platformPath = fPage.getPlatformPath(); |
548 |
String platformPath = fPage.getPlatformPath(); |
550 |
if (platformPath != null && platformPath.length() > 0) { |
549 |
if (platformPath != null && platformPath.length() > 0) { |
|
|
550 |
|
551 |
// Get the set of model ids selected |
552 |
Set selectedModels; |
553 |
selectedModels = getSelectedModelIds(true); |
554 |
|
551 |
ReloadOperation op = new ReloadOperation(platformPath); |
555 |
ReloadOperation op = new ReloadOperation(platformPath); |
552 |
try { |
556 |
try { |
553 |
PlatformUI.getWorkbench().getProgressService().run(true, false, op); |
557 |
PlatformUI.getWorkbench().getProgressService().run(true, false, op); |
Lines 556-565
Link Here
|
556 |
} |
560 |
} |
557 |
fPluginListViewer.setInput(PDECore.getDefault().getModelManager().getExternalModelManager()); |
561 |
fPluginListViewer.setInput(PDECore.getDefault().getModelManager().getExternalModelManager()); |
558 |
fPluginTreeViewer.setInput(PDECore.getDefault().getModelManager().getExternalModelManager()); |
562 |
fPluginTreeViewer.setInput(PDECore.getDefault().getModelManager().getExternalModelManager()); |
559 |
fPluginTreeViewer.setSubtreeChecked(fPluginTreeViewer.getInput(), true); |
|
|
560 |
fPluginTreeViewer.setGrayedElements(new Object[0]); |
563 |
fPluginTreeViewer.setGrayedElements(new Object[0]); |
561 |
fChangedModels.clear(); |
564 |
fChangedModels.clear(); |
562 |
handleSelectAll(true); |
565 |
|
|
|
566 |
boolean restoredSelection; |
567 |
restoredSelection = handleRestoreSelection(selectedModels); |
568 |
|
569 |
// If the selection wasn't restored the default to the 'select all' logic |
570 |
if (!restoredSelection) |
571 |
handleSelectAll(true); |
572 |
|
563 |
if (fTreeViewerContents.size() > 1) |
573 |
if (fTreeViewerContents.size() > 1) |
564 |
fPluginTreeViewer.collapseAll(); |
574 |
fPluginTreeViewer.collapseAll(); |
565 |
fReloaded = true; |
575 |
fReloaded = true; |
Lines 569-574
Link Here
|
569 |
} |
579 |
} |
570 |
|
580 |
|
571 |
/** |
581 |
/** |
|
|
582 |
* Return a set of currently selected model ids |
583 |
* @param nullIfAll Affects what will be returned if all are selected, |
584 |
* i.e. if true and all are selected then this will return <code>null</code>. |
585 |
* @return A set of identifiers for the currently selected models, or <code>null</code> |
586 |
* if all are selected and <code>nullIfAll</code> is <code>true</code>. |
587 |
*/ |
588 |
private Set getSelectedModelIds(boolean nullIfAll) { |
589 |
|
590 |
Object[] itemsCheckedInList = fPluginListViewer.getCheckedElements(); |
591 |
IPluginModelBase[] allModels = getCurrentModels(); |
592 |
boolean allSelected = (itemsCheckedInList.length == allModels.length); |
593 |
if (nullIfAll && allSelected) { |
594 |
|
595 |
// All items are selected - no need to do any magic, just return null |
596 |
return null; |
597 |
} |
598 |
|
599 |
Set selectedModels; |
600 |
|
601 |
// Build a set containing the ids of the selected plugin/bundle/fragments |
602 |
selectedModels = new HashSet(); |
603 |
for (int i = 0; i < itemsCheckedInList.length; i++) { |
604 |
Object item = itemsCheckedInList[i]; |
605 |
if (item instanceof IPluginModel) { |
606 |
|
607 |
IPluginModel pluginModel = (IPluginModel) item; |
608 |
String id = pluginModel.getPluginBase().getId(); |
609 |
selectedModels.add(id); |
610 |
|
611 |
} else if (item instanceof IFragmentModel) { |
612 |
|
613 |
IFragmentModel fragmentModel = (IFragmentModel) item; |
614 |
String id = fragmentModel.getPluginBase().getId(); |
615 |
selectedModels.add(id); |
616 |
} |
617 |
} |
618 |
|
619 |
return selectedModels; |
620 |
} |
621 |
|
622 |
/** |
572 |
* Sets the given locations as additional locations to check, then handles the reload. |
623 |
* Sets the given locations as additional locations to check, then handles the reload. |
573 |
* @param additionalLocations list of additional locations. |
624 |
* @param additionalLocations list of additional locations. |
574 |
*/ |
625 |
*/ |
Lines 724-729
Link Here
|
724 |
} |
775 |
} |
725 |
|
776 |
|
726 |
/** |
777 |
/** |
|
|
778 |
* Restore the selection to the specified set of models. |
779 |
* @param selectedModels Set of plugin/bundle identifiers |
780 |
* @return true if the selection occurred, false if it didn't |
781 |
*/ |
782 |
private boolean handleRestoreSelection(Set selectedModels) { |
783 |
|
784 |
boolean restoredSelection = false; |
785 |
|
786 |
if (selectedModels != null) { |
787 |
|
788 |
int numSelected = 0; |
789 |
|
790 |
IPluginModelBase[] allModels = getCurrentModels(); |
791 |
|
792 |
// There are two ways of dealing with the checking of the UI widgets: |
793 |
// (1) un-check them all and selectively check individual ones |
794 |
// (1) check them all and selectively un-check individual ones |
795 |
// The method chosen depends on the ratio of selectedModels to allModels. |
796 |
// This method cannot be guaranteed to be accurate since the set of plugins |
797 |
// between two targets may be completely different, but it's going to give a |
798 |
// reasonable guess. |
799 |
|
800 |
boolean checkingMethod = true; |
801 |
if (selectedModels.size() > (allModels.length / 2)) { |
802 |
// more than half the number of models to be selected than |
803 |
// models we have in total, so selectively un-check |
804 |
checkingMethod = false; |
805 |
} |
806 |
|
807 |
fPluginListViewer.setAllChecked(!checkingMethod); |
808 |
fPluginTreeViewer.setAllChecked(!checkingMethod); |
809 |
|
810 |
restoredSelection = true; |
811 |
|
812 |
for (int i = 0; i < allModels.length; i++) { |
813 |
IPluginModelBase model = allModels[i]; |
814 |
|
815 |
String id = model.getPluginBase().getId(); |
816 |
boolean selected = selectedModels.contains(id); |
817 |
|
818 |
if (selected) { |
819 |
numSelected++; |
820 |
if (checkingMethod) { |
821 |
fPluginListViewer.setChecked(model, true); |
822 |
fPluginTreeViewer.setChecked(model, true); |
823 |
} |
824 |
} else if (!checkingMethod) { |
825 |
|
826 |
fPluginListViewer.setChecked(model, false); |
827 |
fPluginTreeViewer.setChecked(model, false); |
828 |
} |
829 |
|
830 |
if (model.isEnabled() != selected) { |
831 |
fChangedModels.add(model); |
832 |
} else if (fChangedModels.contains(model) && model.isEnabled() == selected) { |
833 |
fChangedModels.remove(model); |
834 |
} |
835 |
} |
836 |
|
837 |
// Handle grey-ness in table |
838 |
Set parents = fTreeViewerContents.keySet(); |
839 |
Iterator parentIter = parents.iterator(); |
840 |
while (parentIter.hasNext()) { |
841 |
File parent = (File) parentIter.next(); |
842 |
handleGrayChecked(parent, true); |
843 |
} |
844 |
|
845 |
setCounter(numSelected); |
846 |
} |
847 |
return restoredSelection; |
848 |
} |
849 |
|
850 |
/** |
727 |
* Enables or disables all of the plugins. |
851 |
* Enables or disables all of the plugins. |
728 |
* @param selected whether to enable or disable the plugins |
852 |
* @param selected whether to enable or disable the plugins |
729 |
*/ |
853 |
*/ |