Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Loskutov2014-12-21 15:32:17 +0000
committerPaul Webster2015-01-14 20:15:47 +0000
commitd94ad70154d8c9dc22c67cbec3b6c505ab563b0f (patch)
treebeac708844ce71c990802471f32e3cf0783db40f
parentb3eab327711f465853b9e82678f362557572cfdf (diff)
downloadeclipse.platform.ui-d94ad70154d8c9dc22c67cbec3b6c505ab563b0f.tar.gz
eclipse.platform.ui-d94ad70154d8c9dc22c67cbec3b6c505ab563b0f.tar.xz
eclipse.platform.ui-d94ad70154d8c9dc22c67cbec3b6c505ab563b0f.zip
Bug 404348 - remember disabled action sets
The action set "visibility" state managed by ActionSetManager was never persisted and the user choice to disable action set was lost on shutdown. This change persists user choice in the same way as it was done for toolbars and menus. Note: plugins can request to show/hide ActionSet (depending on the application needs), but once user decides to "disable" action set, his decision must override application choice. The best example is the debug action set with the global debug buttons which requests "visibility" on each breakpoint hit. The change allows Eclipse to ignore those requests once user decided to do so. Change-Id: Ie3a962b42f2e157344385e4a16bcc8782d64c1c6 Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Perspective.java36
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/cpd/CustomizePerspectiveDialog.java28
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/ModeledPageLayout.java1
3 files changed, 55 insertions, 10 deletions
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Perspective.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Perspective.java
index 1e4924f6339..eddf71d5348 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Perspective.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Perspective.java
@@ -10,6 +10,7 @@
* Markus Alexander Kuppe, Versant GmbH - bug 215797
* Sascha Zak - bug 282874
* Lars Vogel <Lars.Vogel@gmail.com> - Bug 440810, 440136
+ * Andrey Loskutov <loskutov@gmx.de> - Bug 404348, 421178, 456727
*******************************************************************************/
package org.eclipse.ui.internal;
@@ -47,12 +48,36 @@ public class Perspective {
public void initActionSets() {
if (descriptor != null) {
- List<String> ids = ModeledPageLayout.getIds(layout, ModeledPageLayout.ACTION_SET_TAG);
- for (IActionSetDescriptor descriptor : createInitialActionSets(ids)) {
+ List<String> alwaysOn = ModeledPageLayout.getIds(layout, ModeledPageLayout.ACTION_SET_TAG);
+
+ // read explicitly disabled sets.
+ String hiddenIDs = page.getHiddenItems();
+ List<String> alwaysOff = new ArrayList<String>();
+
+ String[] hiddenIds = hiddenIDs.split(","); //$NON-NLS-1$
+ for (String id : hiddenIds) {
+ if (!id.startsWith(ModeledPageLayout.HIDDEN_ACTIONSET_PREFIX)) {
+ continue;
+ }
+ id = id.substring(ModeledPageLayout.HIDDEN_ACTIONSET_PREFIX.length());
+ if (!alwaysOff.contains(id)) {
+ alwaysOff.add(id);
+ }
+ }
+
+ alwaysOn.removeAll(alwaysOff);
+
+ for (IActionSetDescriptor descriptor : createInitialActionSets(alwaysOn)) {
if (!alwaysOnActionSets.contains(descriptor)) {
alwaysOnActionSets.add(descriptor);
}
}
+
+ for (IActionSetDescriptor descriptor : createInitialActionSets(alwaysOff)) {
+ if (!alwaysOffActionSets.contains(descriptor)) {
+ alwaysOffActionSets.add(descriptor);
+ }
+ }
}
}
@@ -210,11 +235,8 @@ public class Perspective {
}
}
addAlwaysOff(toRemove);
- // remove tag
- String tag = ModeledPageLayout.ACTION_SET_TAG + id;
- if (layout.getTags().contains(tag)) {
- layout.getTags().remove(tag);
- }
+ // not necessary to remove the ModeledPageLayout.ACTION_SET_TAG + id
+ // tag as the entry is only disabled.
} finally {
service.deferUpdates(false);
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/cpd/CustomizePerspectiveDialog.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/cpd/CustomizePerspectiveDialog.java
index 0d121dd9efb..7057230e543 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/cpd/CustomizePerspectiveDialog.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/cpd/CustomizePerspectiveDialog.java
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
* Tom Hochstein (Freescale) - Bug 407522 - Perspective reset not working correctly
* Lars Vogel <Lars.Vogel@gmail.com> - Bug 422040, 431992
- * Andrey Loskutov <loskutov@gmx.de> - Bug 456729
+ * Andrey Loskutov <loskutov@gmx.de> - Bug 456729, 404348, 421178
*******************************************************************************/
package org.eclipse.ui.internal.dialogs.cpd;
@@ -2228,13 +2228,33 @@ public class CustomizePerspectiveDialog extends TrayDialog {
}
}
- private boolean updateHiddenElements(DisplayItem items, String currentHidden, String prefix) {
- boolean hasChanges = false;
+ private boolean updateHiddenElements(List<ActionSet> items, String currentHidden, String prefix) {
+ List<String> changedAndVisible = new ArrayList<String>();
+ List<String> changedAndInvisible = new ArrayList<String>();
+ for (ActionSet actionSet : items) {
+ if (!actionSet.wasChanged()) {
+ continue;
+ }
+ if (actionSet.isActive()) {
+ changedAndVisible.add(actionSet.descriptor.getId());
+ } else {
+ changedAndInvisible.add(actionSet.descriptor.getId());
+ }
+ }
+ return updateHiddenElements(currentHidden, prefix, changedAndVisible, changedAndInvisible);
+ }
+ private boolean updateHiddenElements(DisplayItem items, String currentHidden, String prefix) {
List<String> changedAndVisible = new ArrayList<String>();
List<String> changedAndInvisible = new ArrayList<String>();
getChangedIds(items, changedAndInvisible, changedAndVisible);
+ return updateHiddenElements(currentHidden, prefix, changedAndVisible, changedAndInvisible);
+ }
+
+ private boolean updateHiddenElements(String currentHidden, String prefix, List<String> changedAndVisible,
+ List<String> changedAndInvisible) {
+ boolean hasChanges = false;
// Remove explicitly 'visible' elements from the current list
for (String id : changedAndVisible) {
if (id != null && currentHidden.contains(prefix + id)) {
@@ -2289,6 +2309,8 @@ public class CustomizePerspectiveDialog extends TrayDialog {
perspective.turnOnActionSets(toAdd.toArray(new IActionSetDescriptor[toAdd.size()]));
perspective.turnOffActionSets(toRemove.toArray(new IActionSetDescriptor[toRemove.size()]));
+ requiresUpdate |= updateHiddenElements(actionSets, wPage.getHiddenItems(),
+ ModeledPageLayout.HIDDEN_ACTIONSET_PREFIX);
// Menu and Toolbar Items
requiresUpdate |= updateHiddenElements(menuItems, wPage.getHiddenItems(),
ModeledPageLayout.HIDDEN_MENU_PREFIX);
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/ModeledPageLayout.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/ModeledPageLayout.java
index 96c2c9560b6..8aa15ce2710 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/ModeledPageLayout.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/ModeledPageLayout.java
@@ -62,6 +62,7 @@ public class ModeledPageLayout implements IPageLayout {
public static final String SHOW_VIEW_TAG = "persp.viewSC:"; //$NON-NLS-1$
public static final String HIDDEN_MENU_PREFIX = "persp.hideMenuSC:"; //$NON-NLS-1$
public static final String HIDDEN_TOOLBAR_PREFIX = "persp.hideToolbarSC:"; //$NON-NLS-1$
+ public static final String HIDDEN_ACTIONSET_PREFIX = "persp.hideActionSetSC:"; //$NON-NLS-1$
public static final String HIDDEN_ITEMS_KEY = "persp.hiddenItems"; //$NON-NLS-1$
public static List<String> getIds(MPerspective model, String tagPrefix) {

Back to the top