Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 87240 Details for
Bug 72511
PDE Target Platform pref page should keep checked state
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch to retain selection on target reload
patch-bug72511-B.txt (text/plain), 6.33 KB, created by
Les Jones
on 2008-01-18 05:00:18 EST
(
hide
)
Description:
Patch to retain selection on target reload
Filename:
MIME Type:
Creator:
Les Jones
Created:
2008-01-18 05:00:18 EST
Size:
6.33 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.pde.ui >Index: src/org/eclipse/pde/internal/ui/preferences/TargetPluginsTab.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/preferences/TargetPluginsTab.java,v >retrieving revision 1.45 >diff -u -r1.45 TargetPluginsTab.java >--- src/org/eclipse/pde/internal/ui/preferences/TargetPluginsTab.java 16 Jan 2008 17:08:15 -0000 1.45 >+++ src/org/eclipse/pde/internal/ui/preferences/TargetPluginsTab.java 18 Jan 2008 09:58:45 -0000 >@@ -28,8 +28,7 @@ > import org.eclipse.osgi.util.NLS; > import org.eclipse.pde.core.IModel; > import org.eclipse.pde.core.IModelProviderEvent; >-import org.eclipse.pde.core.plugin.IPluginModelBase; >-import org.eclipse.pde.core.plugin.PluginRegistry; >+import org.eclipse.pde.core.plugin.*; > import org.eclipse.pde.internal.core.*; > import org.eclipse.pde.internal.core.ifeature.*; > import org.eclipse.pde.internal.core.itarget.*; >@@ -548,6 +547,11 @@ > protected void handleReload() { > String platformPath = fPage.getPlatformPath(); > if (platformPath != null && platformPath.length() > 0) { >+ >+ // Get the set of model ids selected >+ Set selectedModels; >+ selectedModels = getSelectedModelIds(true); >+ > ReloadOperation op = new ReloadOperation(platformPath); > try { > PlatformUI.getWorkbench().getProgressService().run(true, false, op); >@@ -556,10 +560,16 @@ > } > fPluginListViewer.setInput(PDECore.getDefault().getModelManager().getExternalModelManager()); > fPluginTreeViewer.setInput(PDECore.getDefault().getModelManager().getExternalModelManager()); >- fPluginTreeViewer.setSubtreeChecked(fPluginTreeViewer.getInput(), true); > fPluginTreeViewer.setGrayedElements(new Object[0]); > fChangedModels.clear(); >- handleSelectAll(true); >+ >+ boolean restoredSelection; >+ restoredSelection = handleRestoreSelection(selectedModels); >+ >+ // If the selection wasn't restored the default to the 'select all' logic >+ if (!restoredSelection) >+ handleSelectAll(true); >+ > if (fTreeViewerContents.size() > 1) > fPluginTreeViewer.collapseAll(); > fReloaded = true; >@@ -569,6 +579,47 @@ > } > > /** >+ * Return a set of currently selected model ids >+ * @param nullIfAll Affects what will be returned if all are selected, >+ * i.e. if true and all are selected then this will return <code>null</code>. >+ * @return A set of identifiers for the currently selected models, or <code>null</code> >+ * if all are selected and <code>nullIfAll</code> is <code>true</code>. >+ */ >+ private Set getSelectedModelIds(boolean nullIfAll) { >+ >+ Object[] itemsCheckedInList = fPluginListViewer.getCheckedElements(); >+ IPluginModelBase[] allModels = getCurrentModels(); >+ boolean allSelected = (itemsCheckedInList.length == allModels.length); >+ if (nullIfAll && allSelected) { >+ >+ // All items are selected - no need to do any magic, just return null >+ return null; >+ } >+ >+ Set selectedModels; >+ >+ // Build a set containing the ids of the selected plugin/bundle/fragments >+ selectedModels = new HashSet(); >+ for (int i = 0; i < itemsCheckedInList.length; i++) { >+ Object item = itemsCheckedInList[i]; >+ if (item instanceof IPluginModel) { >+ >+ IPluginModel pluginModel = (IPluginModel) item; >+ String id = pluginModel.getPluginBase().getId(); >+ selectedModels.add(id); >+ >+ } else if (item instanceof IFragmentModel) { >+ >+ IFragmentModel fragmentModel = (IFragmentModel) item; >+ String id = fragmentModel.getPluginBase().getId(); >+ selectedModels.add(id); >+ } >+ } >+ >+ return selectedModels; >+ } >+ >+ /** > * Sets the given locations as additional locations to check, then handles the reload. > * @param additionalLocations list of additional locations. > */ >@@ -724,6 +775,79 @@ > } > > /** >+ * Restore the selection to the specified set of models. >+ * @param selectedModels Set of plugin/bundle identifiers >+ * @return true if the selection occurred, false if it didn't >+ */ >+ private boolean handleRestoreSelection(Set selectedModels) { >+ >+ boolean restoredSelection = false; >+ >+ if (selectedModels != null) { >+ >+ int numSelected = 0; >+ >+ IPluginModelBase[] allModels = getCurrentModels(); >+ >+ // There are two ways of dealing with the checking of the UI widgets: >+ // (1) un-check them all and selectively check individual ones >+ // (1) check them all and selectively un-check individual ones >+ // The method chosen depends on the ratio of selectedModels to allModels. >+ // This method cannot be guaranteed to be accurate since the set of plugins >+ // between two targets may be completely different, but it's going to give a >+ // reasonable guess. >+ >+ boolean checkingMethod = true; >+ if (selectedModels.size() > (allModels.length / 2)) { >+ // more than half the number of models to be selected than >+ // models we have in total, so selectively un-check >+ checkingMethod = false; >+ } >+ >+ fPluginListViewer.setAllChecked(!checkingMethod); >+ fPluginTreeViewer.setAllChecked(!checkingMethod); >+ >+ restoredSelection = true; >+ >+ for (int i = 0; i < allModels.length; i++) { >+ IPluginModelBase model = allModels[i]; >+ >+ String id = model.getPluginBase().getId(); >+ boolean selected = selectedModels.contains(id); >+ >+ if (selected) { >+ numSelected++; >+ if (checkingMethod) { >+ fPluginListViewer.setChecked(model, true); >+ fPluginTreeViewer.setChecked(model, true); >+ } >+ } else if (!checkingMethod) { >+ >+ fPluginListViewer.setChecked(model, false); >+ fPluginTreeViewer.setChecked(model, false); >+ } >+ >+ if (model.isEnabled() != selected) { >+ fChangedModels.add(model); >+ } else if (fChangedModels.contains(model) && model.isEnabled() == selected) { >+ fChangedModels.remove(model); >+ } >+ } >+ >+ // Handle grey-ness in table >+ Set parents = fTreeViewerContents.keySet(); >+ Iterator parentIter = parents.iterator(); >+ while (parentIter.hasNext()) { >+ File parent = (File) parentIter.next(); >+ handleGrayChecked(parent, true); >+ } >+ >+ setCounter(numSelected); >+ } >+ return restoredSelection; >+ } >+ >+ /** > * Enables or disables all of the plugins. > * @param selected whether to enable or disable the plugins > */
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 72511
:
87238
| 87240