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 26591 Details for
Bug 96600
[DynamicUI] [Commands] [Contexts] [KeyBindings] Commands architecture isn't dynamic
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch to "org.eclipse.ui.workbench"
Bug96600-org.eclipse.ui.workbench-r4.patch (text/plain), 27.03 KB, created by
Douglas Pollock
on 2005-08-29 11:20:08 EDT
(
hide
)
Description:
Patch to "org.eclipse.ui.workbench"
Filename:
MIME Type:
Creator:
Douglas Pollock
Created:
2005-08-29 11:20:08 EDT
Size:
27.03 KB
patch
obsolete
>Index: Eclipse UI/org/eclipse/ui/internal/IWorkbenchConstants.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/IWorkbenchConstants.java,v >retrieving revision 1.65 >diff -u -r1.65 IWorkbenchConstants.java >--- Eclipse UI/org/eclipse/ui/internal/IWorkbenchConstants.java 16 Jun 2005 23:12:18 -0000 1.65 >+++ Eclipse UI/org/eclipse/ui/internal/IWorkbenchConstants.java 29 Aug 2005 15:16:24 -0000 >@@ -78,6 +78,57 @@ > public static final String PL_DECORATORS = "decorators"; //$NON-NLS-1$ > > public static final String PL_SYSTEM_SUMMARY_SECTIONS = "systemSummarySections"; //$NON-NLS-1$ >+ >+ /** >+ * The legacy extension point (2.1.x and earlier) for specifying a key >+ * binding scheme. >+ * >+ * @since 3.1.1 >+ */ >+ public static final String PL_ACCELERATOR_CONFIGURATIONS = "acceleratorConfigurations"; //$NON-NLS-1$ >+ >+ /** >+ * The legacy extension point (2.1.x and earlier) for specifying a context. >+ * >+ * @since 3.1.1 >+ */ >+ public static final String PL_ACCELERATOR_SCOPES = "acceleratorScopes"; //$NON-NLS-1$ >+ >+ /** >+ * The legacy extension point (2.1.x and earlier) for specifying a command. >+ * >+ * @since 3.1.1 >+ */ >+ public static final String PL_ACTION_DEFINITIONS = "actionDefinitions"; //$NON-NLS-1$ >+ >+ /** >+ * The extension point (3.1 and later) for specifying bindings, such as >+ * keyboard shortcuts. >+ * >+ * @since 3.1.1 >+ */ >+ public static final String PL_BINDINGS = "bindings"; //$NON-NLS-1$ >+ >+ /** >+ * The extension point (2.1.x and later) for specifying a command. A lot >+ * of other things have appeared first in this extension point and then been >+ * moved to their own extension point. >+ * >+ * @since 3.1.1 >+ */ >+ public static final String PL_COMMANDS = "commands"; //$NON-NLS-1$ >+ >+ /** >+ * The extension point (3.0 and later) for specifying a context. >+ * >+ * @since 3.1.1 >+ */ >+ public static final String PL_CONTEXTS = "contexts"; //$NON-NLS-1$ >+ >+ /** >+ * The extension point (3.1 and later) for specifying handlers. >+ */ >+ public static final String PL_HANDLERS = "handlers"; //$NON-NLS-1$ > > /** > * The extension point for encoding definitions. >Index: Eclipse UI/org/eclipse/ui/internal/commands/CommandPersistence.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/commands/CommandPersistence.java,v >retrieving revision 1.8 >diff -u -r1.8 CommandPersistence.java >--- Eclipse UI/org/eclipse/ui/internal/commands/CommandPersistence.java 20 Apr 2005 15:37:06 -0000 1.8 >+++ Eclipse UI/org/eclipse/ui/internal/commands/CommandPersistence.java 29 Aug 2005 15:16:25 -0000 >@@ -12,17 +12,25 @@ > package org.eclipse.ui.internal.commands; > > import java.util.ArrayList; >+import java.util.Iterator; > import java.util.List; >+import java.util.Set; > > import org.eclipse.core.commands.Category; > import org.eclipse.core.commands.Command; > import org.eclipse.core.commands.CommandManager; > import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IExtensionDelta; > import org.eclipse.core.runtime.IExtensionRegistry; >+import org.eclipse.core.runtime.IRegistryChangeEvent; >+import org.eclipse.core.runtime.IRegistryChangeListener; > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.MultiStatus; > import org.eclipse.core.runtime.Platform; > import org.eclipse.core.runtime.Status; >+import org.eclipse.swt.widgets.Display; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.internal.IWorkbenchConstants; > import org.eclipse.ui.internal.WorkbenchPlugin; > import org.eclipse.ui.internal.util.Util; > >@@ -95,12 +103,14 @@ > /** > * The name of the action definitions extension point. > */ >- private static final String EXTENSION_ACTION_DEFINITIONS = "org.eclipse.ui.actionDefinitions"; //$NON-NLS-1$ >+ private static final String EXTENSION_ACTION_DEFINITIONS = PlatformUI.PLUGIN_ID >+ + '.' + IWorkbenchConstants.PL_ACTION_DEFINITIONS; > > /** > * The name of the commands extension point. > */ >- private static final String EXTENSION_COMMANDS = "org.eclipse.ui.commands"; //$NON-NLS-1$ >+ private static final String EXTENSION_COMMANDS = PlatformUI.PLUGIN_ID + '.' >+ + IWorkbenchConstants.PL_COMMANDS; > > /** > * The index of the category elements in the indexed array. >@@ -117,6 +127,12 @@ > private static final int INDEX_COMMAND_DEFINITIONS = 1; > > /** >+ * Whether the preference and registry change listeners have been attached >+ * yet. >+ */ >+ private static boolean listenersAttached = false; >+ >+ /** > * Inserts the given element into the indexed two-dimensional array in the > * array at the index. The array is grown as necessary. > * >@@ -205,6 +221,42 @@ > readCommandsFromCommandsExtensionPoint( > indexedConfigurationElements[INDEX_COMMAND_DEFINITIONS], > commandDefinitionCount, commandManager); >+ >+ /* >+ * Adds listener so that future registry changes trigger an update of >+ * the command manager automatically. >+ */ >+ if (!listenersAttached) { >+ registry.addRegistryChangeListener(new IRegistryChangeListener() { >+ public final void registryChanged( >+ final IRegistryChangeEvent event) { >+ final IExtensionDelta[] commandDeltas = event >+ .getExtensionDeltas(PlatformUI.PLUGIN_ID, >+ IWorkbenchConstants.PL_COMMANDS); >+ if (commandDeltas.length == 0) { >+ final IExtensionDelta[] actionDefinitionDeltas = event >+ .getExtensionDeltas( >+ PlatformUI.PLUGIN_ID, >+ IWorkbenchConstants.PL_ACTION_DEFINITIONS); >+ if (actionDefinitionDeltas.length == 0) { >+ return; >+ } >+ } >+ >+ /* >+ * At least one of the deltas is non-zero, so re-read all of >+ * the bindings. >+ */ >+ Display.getDefault().asyncExec(new Runnable() { >+ public void run() { >+ read(commandManager); >+ } >+ }); >+ } >+ }, PlatformUI.PLUGIN_ID); >+ >+ listenersAttached = true; >+ } > } > > /** >@@ -224,6 +276,22 @@ > final IConfigurationElement[] configurationElements, > final int configurationElementCount, > final CommandManager commandManager) { >+ // Undefine all the previous handle objects. >+ final Set categoryIds = commandManager.getDefinedCategoryIds(); >+ if (categoryIds != null) { >+ final Iterator categoryIdItr = categoryIds.iterator(); >+ final Category[] categories = new Category[categoryIds.size()]; >+ int i = 0; >+ >+ while (categoryIdItr.hasNext()) { >+ categories[i++] = commandManager.getCategory((String) categoryIdItr.next()); >+ } >+ >+ for (int j = 0; j < categories.length; j++) { >+ categories[j].undefine(); >+ } >+ } >+ > /* > * If necessary, this list of status items will be constructed. It will > * only contains instances of <code>IStatus</code>. >@@ -305,6 +373,22 @@ > final IConfigurationElement[] configurationElements, > final int configurationElementCount, > final CommandManager commandManager) { >+ // Undefine all the previous handle objects. >+ final Set commandIds = commandManager.getDefinedCommandIds(); >+ if (commandIds != null) { >+ final Iterator commandIdItr = commandIds.iterator(); >+ final Command[] commands = new Command[commandIds.size()]; >+ int i = 0; >+ >+ while (commandIdItr.hasNext()) { >+ commands[i++] = commandManager.getCommand((String) commandIdItr.next()); >+ } >+ >+ for (int j = 0; j < commands.length; j++) { >+ commands[j].undefine(); >+ } >+ } >+ > /* > * If necessary, this list of status items will be constructed. It will > * only contains instances of <code>IStatus</code>. >Index: Eclipse UI/org/eclipse/ui/internal/contexts/ContextPersistence.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/contexts/ContextPersistence.java,v >retrieving revision 1.3 >diff -u -r1.3 ContextPersistence.java >--- Eclipse UI/org/eclipse/ui/internal/contexts/ContextPersistence.java 20 Apr 2005 15:37:06 -0000 1.3 >+++ Eclipse UI/org/eclipse/ui/internal/contexts/ContextPersistence.java 29 Aug 2005 15:16:25 -0000 >@@ -12,16 +12,24 @@ > package org.eclipse.ui.internal.contexts; > > import java.util.ArrayList; >+import java.util.Iterator; > import java.util.List; >+import java.util.Set; > > import org.eclipse.core.commands.contexts.Context; > import org.eclipse.core.commands.contexts.ContextManager; > import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IExtensionDelta; > import org.eclipse.core.runtime.IExtensionRegistry; >+import org.eclipse.core.runtime.IRegistryChangeEvent; >+import org.eclipse.core.runtime.IRegistryChangeListener; > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.MultiStatus; > import org.eclipse.core.runtime.Platform; > import org.eclipse.core.runtime.Status; >+import org.eclipse.swt.widgets.Display; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.internal.IWorkbenchConstants; > import org.eclipse.ui.internal.WorkbenchPlugin; > > /** >@@ -85,17 +93,20 @@ > /** > * The name of the accelerator scopes extension point. > */ >- private static final String EXTENSION_ACCELERATOR_SCOPES = "org.eclipse.ui.acceleratorScopes"; //$NON-NLS-1$ >+ private static final String EXTENSION_ACCELERATOR_SCOPES = PlatformUI.PLUGIN_ID >+ + '.' + IWorkbenchConstants.PL_ACCELERATOR_SCOPES; > > /** > * The name of the commands extension point. > */ >- private static final String EXTENSION_COMMANDS = "org.eclipse.ui.commands"; //$NON-NLS-1$ >+ private static final String EXTENSION_COMMANDS = PlatformUI.PLUGIN_ID + '.' >+ + IWorkbenchConstants.PL_COMMANDS; > > /** > * The name of the contexts extension point. > */ >- private static final String EXTENSION_CONTEXTS = "org.eclipse.ui.contexts"; //$NON-NLS-1$ >+ private static final String EXTENSION_CONTEXTS = PlatformUI.PLUGIN_ID + '.' >+ + IWorkbenchConstants.PL_CONTEXTS; > > /** > * The index of the context elements in the indexed array. >@@ -105,6 +116,12 @@ > private static final int INDEX_CONTEXT_DEFINITIONS = 0; > > /** >+ * Whether the preference and registry change listeners have been attached >+ * yet. >+ */ >+ private static boolean listenersAttached = false; >+ >+ /** > * Inserts the given element into the indexed two-dimensional array in the > * array at the index. The array is grown as necessary. > * >@@ -215,6 +232,47 @@ > readContextsFromExtensionPoint( > indexedConfigurationElements[INDEX_CONTEXT_DEFINITIONS], > contextDefinitionCount, contextManager); >+ >+ /* >+ * Adds listener so that future registry changes trigger an update of >+ * the command manager automatically. >+ */ >+ if (!listenersAttached) { >+ registry.addRegistryChangeListener(new IRegistryChangeListener() { >+ public final void registryChanged( >+ final IRegistryChangeEvent event) { >+ final IExtensionDelta[] acceleratorScopeDeltas = event >+ .getExtensionDeltas( >+ PlatformUI.PLUGIN_ID, >+ IWorkbenchConstants.PL_ACCELERATOR_SCOPES); >+ if (acceleratorScopeDeltas.length == 0) { >+ final IExtensionDelta[] contextDeltas = event >+ .getExtensionDeltas(PlatformUI.PLUGIN_ID, >+ IWorkbenchConstants.PL_CONTEXTS); >+ if (contextDeltas.length == 0) { >+ final IExtensionDelta[] commandDeltas = event >+ .getExtensionDeltas(PlatformUI.PLUGIN_ID, >+ IWorkbenchConstants.PL_COMMANDS); >+ if (commandDeltas.length == 0) { >+ return; >+ } >+ } >+ } >+ >+ /* >+ * At least one of the deltas is non-zero, so re-read all of >+ * the bindings. >+ */ >+ Display.getDefault().asyncExec(new Runnable() { >+ public void run() { >+ read(contextManager); >+ } >+ }); >+ } >+ }, PlatformUI.PLUGIN_ID); >+ >+ listenersAttached = true; >+ } > } > > /** >@@ -234,6 +292,22 @@ > final IConfigurationElement[] configurationElements, > final int configurationElementCount, > final ContextManager contextManager) { >+ // Undefine all the previous handle objects. >+ final Set contextIds = contextManager.getDefinedContextIds(); >+ if (contextIds != null) { >+ final Iterator contextIdItr = contextIds.iterator(); >+ final Context[] contexts = new Context[contextIds.size()]; >+ int i = 0; >+ >+ while (contextIdItr.hasNext()) { >+ contexts[i++] = contextManager.getContext((String) contextIdItr.next()); >+ } >+ >+ for (int j = 0; j < contexts.length; j++) { >+ contexts[j].undefine(); >+ } >+ } >+ > /* > * If necessary, this list of status items will be constructed. It will > * only contains instances of <code>IStatus</code>. >Index: Eclipse UI/org/eclipse/ui/internal/handlers/HandlerPersistence.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/HandlerPersistence.java,v >retrieving revision 1.5 >diff -u -r1.5 HandlerPersistence.java >--- Eclipse UI/org/eclipse/ui/internal/handlers/HandlerPersistence.java 20 Apr 2005 15:37:06 -0000 1.5 >+++ Eclipse UI/org/eclipse/ui/internal/handlers/HandlerPersistence.java 29 Aug 2005 15:16:26 -0000 >@@ -12,6 +12,7 @@ > package org.eclipse.ui.internal.handlers; > > import java.util.ArrayList; >+import java.util.Collection; > import java.util.List; > > import org.eclipse.core.expressions.ElementHandler; >@@ -19,13 +20,19 @@ > import org.eclipse.core.expressions.ExpressionConverter; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IExtensionDelta; > import org.eclipse.core.runtime.IExtensionRegistry; >+import org.eclipse.core.runtime.IRegistryChangeEvent; >+import org.eclipse.core.runtime.IRegistryChangeListener; > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.MultiStatus; > import org.eclipse.core.runtime.Platform; > import org.eclipse.core.runtime.Status; >+import org.eclipse.swt.widgets.Display; > import org.eclipse.ui.ISources; >+import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.handlers.IHandlerService; >+import org.eclipse.ui.internal.IWorkbenchConstants; > import org.eclipse.ui.internal.WorkbenchPlugin; > > /** >@@ -100,12 +107,21 @@ > /** > * The name of the commands extension point. > */ >- private static final String EXTENSION_COMMANDS = "org.eclipse.ui.commands"; //$NON-NLS-1$ >+ private static final String EXTENSION_COMMANDS = PlatformUI.PLUGIN_ID + '.' >+ + IWorkbenchConstants.PL_COMMANDS; > > /** > * The name of the commands extension point. > */ >- private static final String EXTENSION_HANDLERS = "org.eclipse.ui.handlers"; //$NON-NLS-1$ >+ private static final String EXTENSION_HANDLERS = PlatformUI.PLUGIN_ID + '.' >+ + IWorkbenchConstants.PL_HANDLERS; >+ >+ /** >+ * The handler activations that have come from the registry. This is used to >+ * flush the activations when the registry is re-read. This value is never >+ * <code>null</code> >+ */ >+ private static final Collection handlerActivations = new ArrayList(); > > /** > * The index of the command elements in the indexed array. >@@ -129,6 +145,12 @@ > private static final int INDEX_HANDLER_SUBMISSIONS = 2; > > /** >+ * Whether the preference and registry change listeners have been attached >+ * yet. >+ */ >+ private static boolean listenersAttached = false; >+ >+ /** > * Inserts the given element into the indexed two-dimensional array in the > * array at the index. The array is grown as necessary. > * >@@ -164,6 +186,20 @@ > } > elements[currentCount] = elementToAdd; > } >+ >+ /** >+ * Deactivates all of the activations made by this class, and then clears >+ * the collection. This should be called before every read. >+ * >+ * @param handlerService >+ * The service handling the activations; must not be >+ * <code>null</code>. >+ */ >+ private static final void clearActivations( >+ final IHandlerService handlerService) { >+ handlerService.deactivateHandlers(handlerActivations); >+ handlerActivations.clear(); >+ } > > /** > * Reads all of the handlers from the registry >@@ -214,6 +250,7 @@ > } > } > >+ clearActivations(handlerService); > readDefaultHandlersFromCommandsExtensionPoint( > indexedConfigurationElements[INDEX_COMMAND_DEFINITIONS], > commandDefinitionCount, handlerService); >@@ -223,6 +260,53 @@ > readHandlersFromHandlersExtensionPoint( > indexedConfigurationElements[INDEX_HANDLER_DEFINITIONS], > handlerDefinitionCount, handlerService); >+ >+ /* >+ * Adds listener so that future registry changes trigger an update of >+ * the command manager automatically. >+ */ >+ if (!listenersAttached) { >+ registry.addRegistryChangeListener(new IRegistryChangeListener() { >+ public final void registryChanged( >+ final IRegistryChangeEvent event) { >+ /* >+ * Handlers will need to be re-read (i.e., re-verified) if >+ * any of the handler extensions change (i.e., handlers, >+ * commands), or if any of the command extensions change >+ * (i.e., action definitions). >+ */ >+ final IExtensionDelta[] handlerDeltas = event >+ .getExtensionDeltas(PlatformUI.PLUGIN_ID, >+ IWorkbenchConstants.PL_HANDLERS); >+ if (handlerDeltas.length == 0) { >+ final IExtensionDelta[] commandDeltas = event >+ .getExtensionDeltas(PlatformUI.PLUGIN_ID, >+ IWorkbenchConstants.PL_COMMANDS); >+ if (commandDeltas.length == 0) { >+ final IExtensionDelta[] actionDefinitionDeltas = event >+ .getExtensionDeltas( >+ PlatformUI.PLUGIN_ID, >+ IWorkbenchConstants.PL_ACTION_DEFINITIONS); >+ if (actionDefinitionDeltas.length == 0) { >+ return; >+ } >+ } >+ } >+ >+ /* >+ * At least one of the deltas is non-zero, so re-read all of >+ * the bindings. >+ */ >+ Display.getDefault().asyncExec(new Runnable() { >+ public void run() { >+ read(handlerService); >+ } >+ }); >+ } >+ }, PlatformUI.PLUGIN_ID); >+ >+ listenersAttached = true; >+ } > } > > /** >@@ -260,8 +344,9 @@ > continue; > } > >- handlerService.activateHandler(commandId, new HandlerProxy( >- configurationElement, ATTRIBUTE_DEFAULT_HANDLER)); >+ handlerActivations.add(handlerService.activateHandler(commandId, >+ new HandlerProxy(configurationElement, >+ ATTRIBUTE_DEFAULT_HANDLER))); > } > } > >@@ -412,18 +497,19 @@ > } > > if (activeWhenExpression != null) { >- handlerService >+ handlerActivations.add(handlerService > .activateHandler(commandId, new HandlerProxy( > configurationElement, ATTRIBUTE_CLASS, > enabledWhenExpression, handlerService), > activeWhenExpression, ISources.ACTIVE_CONTEXT > | ISources.ACTIVE_CURRENT_SELECTION > | ISources.ACTIVE_EDITOR >- | ISources.ACTIVE_PART); >+ | ISources.ACTIVE_PART)); > } else { >- handlerService.activateHandler(commandId, new HandlerProxy( >- configurationElement, ATTRIBUTE_CLASS, >- enabledWhenExpression, handlerService)); >+ handlerActivations.add(handlerService.activateHandler( >+ commandId, new HandlerProxy(configurationElement, >+ ATTRIBUTE_CLASS, enabledWhenExpression, >+ handlerService))); > } > } > >@@ -480,8 +566,9 @@ > continue; > } > >- handlerService.activateHandler(commandId, new LegacyHandlerWrapper( >- new LegacyHandlerProxy(configurationElement))); >+ handlerActivations.add(handlerService.activateHandler(commandId, >+ new LegacyHandlerWrapper(new LegacyHandlerProxy( >+ configurationElement)))); > } > > // If there were any warnings, then log them now. >Index: Eclipse UI/org/eclipse/ui/internal/keys/BindingPersistence.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/keys/BindingPersistence.java,v >retrieving revision 1.17 >diff -u -r1.17 BindingPersistence.java >--- Eclipse UI/org/eclipse/ui/internal/keys/BindingPersistence.java 16 Jun 2005 15:31:48 -0000 1.17 >+++ Eclipse UI/org/eclipse/ui/internal/keys/BindingPersistence.java 29 Aug 2005 15:16:27 -0000 >@@ -27,9 +27,13 @@ > import org.eclipse.core.commands.IParameter; > import org.eclipse.core.commands.Parameterization; > import org.eclipse.core.commands.ParameterizedCommand; >+import org.eclipse.core.commands.common.HandleObject; > import org.eclipse.core.commands.common.NotDefinedException; > import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IExtensionDelta; > import org.eclipse.core.runtime.IExtensionRegistry; >+import org.eclipse.core.runtime.IRegistryChangeEvent; >+import org.eclipse.core.runtime.IRegistryChangeListener; > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.MultiStatus; > import org.eclipse.core.runtime.Platform; >@@ -50,12 +54,14 @@ > import org.eclipse.jface.util.PropertyChangeEvent; > import org.eclipse.jface.util.Util; > import org.eclipse.swt.SWT; >+import org.eclipse.swt.widgets.Display; > import org.eclipse.ui.IMemento; > import org.eclipse.ui.IWorkbenchPreferenceConstants; > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.WorkbenchException; > import org.eclipse.ui.XMLMemento; > import org.eclipse.ui.commands.ICommandService; >+import org.eclipse.ui.internal.IWorkbenchConstants; > import org.eclipse.ui.internal.WorkbenchPlugin; > import org.eclipse.ui.internal.misc.Policy; > import org.eclipse.ui.keys.IBindingService; >@@ -231,18 +237,21 @@ > /** > * The name of the deprecated accelerator configurations extension point. > */ >- private static final String EXTENSION_ACCELERATOR_CONFIGURATIONS = "org.eclipse.ui.acceleratorConfigurations"; //$NON-NLS-1$ >+ private static final String EXTENSION_ACCELERATOR_CONFIGURATIONS = PlatformUI.PLUGIN_ID >+ + '.' + IWorkbenchConstants.PL_ACCELERATOR_CONFIGURATIONS; > > /** > * The name of the bindings extension point. > */ >- private static final String EXTENSION_BINDINGS = "org.eclipse.ui.bindings"; //$NON-NLS-1$ >+ private static final String EXTENSION_BINDINGS = PlatformUI.PLUGIN_ID + '.' >+ + IWorkbenchConstants.PL_BINDINGS; > > /** > * The name of the commands extension point, and the name of the key for the > * commands preferences. > */ >- private static final String EXTENSION_COMMANDS = "org.eclipse.ui.commands"; //$NON-NLS-1$ >+ private static final String EXTENSION_COMMANDS = PlatformUI.PLUGIN_ID + '.' >+ + IWorkbenchConstants.PL_COMMANDS; > > /** > * The index of the active scheme configuration elements in the indexed >@@ -274,15 +283,16 @@ > private static final String LEGACY_DEFAULT_SCOPE = "org.eclipse.ui.globalScope"; //$NON-NLS-1$ > > /** >+ * Whether the preference and registry change listeners have been attached >+ * yet. >+ */ >+ private static boolean listenersAttached = false; >+ >+ /** > * A look-up map for 2.1.x style <code>string</code> keys on a > * <code>keyBinding</code> element. > */ > private static final Map r2_1KeysByName = new HashMap(); >- >- /** >- * Whether the property change listener has been attached yet. >- */ >- private static boolean propertyChangeListenerAttached = false; > > static { > final IKeyLookup lookup = KeyLookupFactory.getDefault(); >@@ -642,19 +652,78 @@ > commandService); > > /* >- * Add a listener so that future preference changes trigger an update of >- * the binding manager automatically. >- */ >- if (!propertyChangeListenerAttached) { >- store.addPropertyChangeListener(new IPropertyChangeListener() { >- public void propertyChange(PropertyChangeEvent event) { >- if (EXTENSION_COMMANDS.equals(event.getProperty())) { >- read(bindingManager, commandService); >- } >- } >- }); >- propertyChangeListenerAttached = true; >- } >+ * Adds listener so that future preference and registry changes trigger >+ * an update of the binding manager automatically. >+ */ >+ if (!listenersAttached) { >+ store.addPropertyChangeListener(new IPropertyChangeListener() { >+ public final void propertyChange(final PropertyChangeEvent event) { >+ if (EXTENSION_COMMANDS.equals(event.getProperty())) { >+ read(bindingManager, commandService); >+ } >+ } >+ }); >+ >+ registry.addRegistryChangeListener(new IRegistryChangeListener() { >+ public final void registryChanged( >+ final IRegistryChangeEvent event) { >+ /* >+ * Bindings will need to be re-read (i.e., re-verified) if >+ * any of the binding extensions change (i.e., accelerator >+ * configurations, bindings, commands), or if any of the >+ * command or context extensions change (i.e., accelerator >+ * scopes, contexts, action definitions). >+ */ >+ final IExtensionDelta[] acceleratorConfigurationDeltas = event >+ .getExtensionDeltas( >+ PlatformUI.PLUGIN_ID, >+ IWorkbenchConstants.PL_ACCELERATOR_CONFIGURATIONS); >+ if (acceleratorConfigurationDeltas.length == 0) { >+ final IExtensionDelta[] bindingDeltas = event >+ .getExtensionDeltas(PlatformUI.PLUGIN_ID, >+ IWorkbenchConstants.PL_BINDINGS); >+ if (bindingDeltas.length == 0) { >+ final IExtensionDelta[] commandDeltas = event >+ .getExtensionDeltas(PlatformUI.PLUGIN_ID, >+ IWorkbenchConstants.PL_COMMANDS); >+ if (commandDeltas.length == 0) { >+ final IExtensionDelta[] acceleratorScopeDeltas = event >+ .getExtensionDeltas( >+ PlatformUI.PLUGIN_ID, >+ IWorkbenchConstants.PL_ACCELERATOR_SCOPES); >+ if (acceleratorScopeDeltas.length == 0) { >+ final IExtensionDelta[] contextDeltas = event >+ .getExtensionDeltas( >+ PlatformUI.PLUGIN_ID, >+ IWorkbenchConstants.PL_CONTEXTS); >+ if (contextDeltas.length == 0) { >+ final IExtensionDelta[] actionDefinitionDeltas = event >+ .getExtensionDeltas( >+ PlatformUI.PLUGIN_ID, >+ IWorkbenchConstants.PL_ACTION_DEFINITIONS); >+ if (actionDefinitionDeltas.length == 0) { >+ return; >+ } >+ } >+ } >+ } >+ } >+ } >+ >+ /* >+ * At least one of the deltas is non-zero, so re-read all of >+ * the bindings. >+ */ >+ Display.getDefault().asyncExec(new Runnable() { >+ public void run() { >+ read(bindingManager, commandService); >+ } >+ }); >+ } >+ }, PlatformUI.PLUGIN_ID); >+ >+ listenersAttached = true; >+ } > } > > >@@ -778,7 +847,8 @@ > .getScheme(IBindingService.DEFAULT_DEFAULT_ACTIVE_SCHEME_ID)); > } catch (final NotDefinedException e) { > // Damn, we're fucked. >- throw new Error("You cannot make something from nothing"); //$NON-NLS-1$ >+ throw new Error( >+ "The default default active scheme id is not defined."); //$NON-NLS-1$ > } > } > >@@ -1365,6 +1435,15 @@ > final IConfigurationElement[] configurationElements, > final int configurationElementCount, > final BindingManager bindingManager) { >+ // Undefine all the previous handle objects. >+ final HandleObject[] handleObjects = bindingManager >+ .getDefinedSchemes(); >+ if (handleObjects != null) { >+ for (int i = 0; i < handleObjects.length; i++) { >+ handleObjects[i].undefine(); >+ } >+ } >+ > for (int i = 0; i < configurationElementCount; i++) { > final IConfigurationElement configurationElement = configurationElements[i]; >
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 96600
:
26476
|
26477
|
26479
|
26556
|
26557
|
26558
|
26561
|
26590
| 26591