Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Webster2013-08-19 19:25:15 +0000
committerGerrit Code Review @ Eclipse.org2013-08-20 11:55:03 +0000
commitcc298fea671240a16fe977aa8ee2b70274de70d5 (patch)
tree2ee62de81c768c4708eb8e921dac80120c81251c
parentd038f2279c469429c871e5f5dc31c9167e25bd6c (diff)
downloadeclipse.platform.ui-cc298fea671240a16fe977aa8ee2b70274de70d5.tar.gz
eclipse.platform.ui-cc298fea671240a16fe977aa8ee2b70274de70d5.tar.xz
eclipse.platform.ui-cc298fea671240a16fe977aa8ee2b70274de70d5.zip
Bug 406003 - Persisting bindings forever results in bad/conflicting
bindings that cannot be removed Remove keys (system bindings) that aren't backed by extensions.
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/BindingToModelProcessor.java27
1 files changed, 26 insertions, 1 deletions
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/BindingToModelProcessor.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/BindingToModelProcessor.java
index 7884a8c6efb..503ff55795c 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/BindingToModelProcessor.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/BindingToModelProcessor.java
@@ -13,8 +13,10 @@ package org.eclipse.ui.internal;
import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.eclipse.core.commands.CommandManager;
import org.eclipse.core.commands.contexts.ContextManager;
import org.eclipse.e4.core.contexts.IEclipseContext;
@@ -25,7 +27,9 @@ import org.eclipse.e4.ui.model.application.commands.MBindingContext;
import org.eclipse.e4.ui.model.application.commands.MBindingTable;
import org.eclipse.e4.ui.model.application.commands.MCommand;
import org.eclipse.e4.ui.model.application.commands.MCommandsFactory;
+import org.eclipse.e4.ui.model.application.commands.MKeyBinding;
import org.eclipse.e4.ui.model.application.commands.impl.CommandsFactoryImpl;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.bindings.Binding;
import org.eclipse.jface.bindings.BindingManager;
import org.eclipse.ui.internal.keys.BindingPersistence;
@@ -36,6 +40,7 @@ public class BindingToModelProcessor {
private Map<String, MBindingContext> contexts = new HashMap<String, MBindingContext>();
private Map<String, MCommand> commands = new HashMap<String, MCommand>();
private Map<String, MBindingTable> tables = new HashMap<String, MBindingTable>();
+ private Set<MKeyBinding> keys = new HashSet<MKeyBinding>();
@Execute
void process(final MApplication application, IEclipseContext context) {
@@ -70,12 +75,19 @@ public class BindingToModelProcessor {
addBinding(application, binding);
}
+ removeBindings();
+
persistence.dispose();
+ contexts.clear();
+ commands.clear();
+ tables.clear();
+ keys.clear();
}
private void gatherTables(List<MBindingTable> bindingTables) {
for (MBindingTable table : bindingTables) {
tables.put(table.getBindingContext().getElementId(), table);
+ keys.addAll(table.getBindings());
}
}
@@ -86,7 +98,20 @@ public class BindingToModelProcessor {
if (table == null) {
table = createTable(application, binding.getContextId());
}
- BindingService.createORupdateMKeyBinding(application, table, binding);
+ MKeyBinding model = BindingService.createORupdateMKeyBinding(application, table, binding);
+ keys.remove(model);
+ }
+
+ private void removeBindings() {
+ for (MKeyBinding key : keys) {
+ if (!key.getTags().contains("type:user")) { //$NON-NLS-1$
+ EObject obj = ((EObject) key).eContainer();
+ if (obj instanceof MBindingTable) {
+ MBindingTable table = (MBindingTable) obj;
+ table.getBindings().remove(key);
+ }
+ }
+ }
}
public MBindingContext getBindingContext(MApplication application, String id) {

Back to the top