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 models selected |
552 |
Set selectedModels; |
553 |
Object[] itemsCheckedInList = fPluginListViewer.getCheckedElements(); |
554 |
IPluginModelBase[] allModels = getCurrentModels(); |
555 |
if (itemsCheckedInList.length == allModels.length) { |
556 |
|
557 |
// All items are selected - no need to do any magic selection retention stuff |
558 |
selectedModels = null; |
559 |
|
560 |
} else { |
561 |
|
562 |
// Build a set containing the ids of the selected plugin/bundle/fragments |
563 |
selectedModels = new HashSet(); |
564 |
for (int i = 0; i < itemsCheckedInList.length; i++) { |
565 |
Object item = itemsCheckedInList[i]; |
566 |
if (item instanceof IPluginModel) { |
567 |
|
568 |
IPluginModel pluginModel = (IPluginModel) item; |
569 |
String id = pluginModel.getPluginBase().getId(); |
570 |
selectedModels.add(id); |
571 |
|
572 |
} else if (item instanceof IFragmentModel) { |
573 |
|
574 |
IFragmentModel fragmentModel = (IFragmentModel) item; |
575 |
String id = fragmentModel.getPluginBase().getId(); |
576 |
selectedModels.add(id); |
577 |
} |
578 |
} |
579 |
} |
580 |
|
551 |
ReloadOperation op = new ReloadOperation(platformPath); |
581 |
ReloadOperation op = new ReloadOperation(platformPath); |
552 |
try { |
582 |
try { |
553 |
PlatformUI.getWorkbench().getProgressService().run(true, false, op); |
583 |
PlatformUI.getWorkbench().getProgressService().run(true, false, op); |
Lines 556-565
Link Here
|
556 |
} |
586 |
} |
557 |
fPluginListViewer.setInput(PDECore.getDefault().getModelManager().getExternalModelManager()); |
587 |
fPluginListViewer.setInput(PDECore.getDefault().getModelManager().getExternalModelManager()); |
558 |
fPluginTreeViewer.setInput(PDECore.getDefault().getModelManager().getExternalModelManager()); |
588 |
fPluginTreeViewer.setInput(PDECore.getDefault().getModelManager().getExternalModelManager()); |
559 |
fPluginTreeViewer.setSubtreeChecked(fPluginTreeViewer.getInput(), true); |
|
|
560 |
fPluginTreeViewer.setGrayedElements(new Object[0]); |
589 |
fPluginTreeViewer.setGrayedElements(new Object[0]); |
561 |
fChangedModels.clear(); |
590 |
fChangedModels.clear(); |
562 |
handleSelectAll(true); |
591 |
|
|
|
592 |
boolean restoredSelection; |
593 |
restoredSelection = handleRestoreSelection(selectedModels); |
594 |
|
595 |
// If the selection wasn't restored the default to the 'select all' logic |
596 |
if (!restoredSelection) |
597 |
handleSelectAll(true); |
598 |
|
563 |
if (fTreeViewerContents.size() > 1) |
599 |
if (fTreeViewerContents.size() > 1) |
564 |
fPluginTreeViewer.collapseAll(); |
600 |
fPluginTreeViewer.collapseAll(); |
565 |
fReloaded = true; |
601 |
fReloaded = true; |
Lines 724-729
Link Here
|
724 |
} |
760 |
} |
725 |
|
761 |
|
726 |
/** |
762 |
/** |
|
|
763 |
* Restore the selection to the specified set of models. |
764 |
* @param selectedModels Set of plugin/bundle identifiers |
765 |
* @return true if the selection occurred, false if it didn't |
766 |
*/ |
767 |
private boolean handleRestoreSelection(Set selectedModels) { |
768 |
|
769 |
boolean restoredSelection = false; |
770 |
|
771 |
if (selectedModels != null) { |
772 |
|
773 |
int numSelected = 0; |
774 |
|
775 |
IPluginModelBase[] allModels = getCurrentModels(); |
776 |
|
777 |
// There are two ways of dealing with the checking of the UI widgets: |
778 |
// (1) un-check them all and selectively check individual ones |
779 |
// (1) check them all and selectively un-check individual ones |
780 |
// The method chosen depends on the ratio of selectedModels to allModels. |
781 |
// This method cannot be guaranteed to be accurate since the set of plugins |
782 |
// between two targets may be completely different, but it's going to give a |
783 |
// reasonable guess. |
784 |
|
785 |
boolean checkingMethod = true; |
786 |
if (selectedModels.size() > (allModels.length / 2)) { |
787 |
// more than half the number of models to be selected than |
788 |
// models we have in total, so selectively un-check |
789 |
checkingMethod = false; |
790 |
} |
791 |
|
792 |
fPluginListViewer.setAllChecked(!checkingMethod); |
793 |
fPluginTreeViewer.setAllChecked(!checkingMethod); |
794 |
|
795 |
restoredSelection = true; |
796 |
|
797 |
for (int i = 0; i < allModels.length; i++) { |
798 |
IPluginModelBase model = allModels[i]; |
799 |
|
800 |
String id = model.getPluginBase().getId(); |
801 |
boolean selected = selectedModels.contains(id); |
802 |
|
803 |
if (selected) { |
804 |
numSelected++; |
805 |
if (checkingMethod) { |
806 |
fPluginListViewer.setChecked(model, true); |
807 |
fPluginTreeViewer.setChecked(model, true); |
808 |
} |
809 |
} else if (!checkingMethod) { |
810 |
|
811 |
fPluginListViewer.setChecked(model, false); |
812 |
fPluginTreeViewer.setChecked(model, false); |
813 |
} |
814 |
|
815 |
if (model.isEnabled() != selected) { |
816 |
fChangedModels.add(model); |
817 |
} else if (fChangedModels.contains(model) && model.isEnabled() == selected) { |
818 |
fChangedModels.remove(model); |
819 |
} |
820 |
} |
821 |
|
822 |
// Handle grey-ness in table |
823 |
Set parents = fTreeViewerContents.keySet(); |
824 |
Iterator parentIter = parents.iterator(); |
825 |
while (parentIter.hasNext()) { |
826 |
File parent = (File) parentIter.next(); |
827 |
handleGrayChecked(parent, true); |
828 |
} |
829 |
|
830 |
setCounter(numSelected); |
831 |
} |
832 |
return restoredSelection; |
833 |
} |
834 |
|
835 |
/** |
727 |
* Enables or disables all of the plugins. |
836 |
* Enables or disables all of the plugins. |
728 |
* @param selected whether to enable or disable the plugins |
837 |
* @param selected whether to enable or disable the plugins |
729 |
*/ |
838 |
*/ |