Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 96600 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse UI/org/eclipse/ui/internal/IWorkbenchConstants.java (+51 lines)
Lines 78-83 Link Here
78
    public static final String PL_DECORATORS = "decorators"; //$NON-NLS-1$
78
    public static final String PL_DECORATORS = "decorators"; //$NON-NLS-1$
79
79
80
    public static final String PL_SYSTEM_SUMMARY_SECTIONS = "systemSummarySections"; //$NON-NLS-1$
80
    public static final String PL_SYSTEM_SUMMARY_SECTIONS = "systemSummarySections"; //$NON-NLS-1$
81
82
    /**
83
     * The legacy extension point (2.1.x and earlier) for specifying a key
84
     * binding scheme.
85
     * 
86
     * @since 3.1.1
87
     */
88
    public static final String PL_ACCELERATOR_CONFIGURATIONS = "acceleratorConfigurations"; //$NON-NLS-1$
89
    
90
    /**
91
     * The legacy extension point (2.1.x and earlier) for specifying a context.
92
     * 
93
     * @since 3.1.1
94
     */
95
    public static final String PL_ACCELERATOR_SCOPES = "acceleratorScopes"; //$NON-NLS-1$
96
    
97
    /**
98
     * The legacy extension point (2.1.x and earlier) for specifying a command.
99
     * 
100
     * @since 3.1.1
101
     */
102
    public static final String PL_ACTION_DEFINITIONS = "actionDefinitions"; //$NON-NLS-1$
103
    
104
    /**
105
     * The extension point (3.1 and later) for specifying bindings, such as
106
     * keyboard shortcuts.
107
     * 
108
     * @since 3.1.1
109
     */
110
    public static final String PL_BINDINGS = "bindings"; //$NON-NLS-1$
111
    
112
    /**
113
     * The extension point (2.1.x and later) for specifying a command.  A lot
114
     * of other things have appeared first in this extension point and then been
115
     * moved to their own extension point.
116
     * 
117
     * @since 3.1.1
118
     */
119
    public static final String PL_COMMANDS = "commands"; //$NON-NLS-1$
120
    
121
    /**
122
     * The extension point (3.0 and later) for specifying a context.
123
     * 
124
     * @since 3.1.1
125
     */
126
    public static final String PL_CONTEXTS = "contexts"; //$NON-NLS-1$
127
    
128
    /**
129
     * The extension point (3.1 and later) for specifying handlers.
130
     */
131
    public static final String PL_HANDLERS = "handlers"; //$NON-NLS-1$
81
    
132
    
82
    /**
133
    /**
83
     * The extension point for encoding definitions.
134
     * The extension point for encoding definitions.
(-)Eclipse UI/org/eclipse/ui/internal/commands/CommandPersistence.java (-2 / +79 lines)
Lines 12-28 Link Here
12
package org.eclipse.ui.internal.commands;
12
package org.eclipse.ui.internal.commands;
13
13
14
import java.util.ArrayList;
14
import java.util.ArrayList;
15
import java.util.Iterator;
15
import java.util.List;
16
import java.util.List;
17
import java.util.Set;
16
18
17
import org.eclipse.core.commands.Category;
19
import org.eclipse.core.commands.Category;
18
import org.eclipse.core.commands.Command;
20
import org.eclipse.core.commands.Command;
19
import org.eclipse.core.commands.CommandManager;
21
import org.eclipse.core.commands.CommandManager;
20
import org.eclipse.core.runtime.IConfigurationElement;
22
import org.eclipse.core.runtime.IConfigurationElement;
23
import org.eclipse.core.runtime.IExtensionDelta;
21
import org.eclipse.core.runtime.IExtensionRegistry;
24
import org.eclipse.core.runtime.IExtensionRegistry;
25
import org.eclipse.core.runtime.IRegistryChangeEvent;
26
import org.eclipse.core.runtime.IRegistryChangeListener;
22
import org.eclipse.core.runtime.IStatus;
27
import org.eclipse.core.runtime.IStatus;
23
import org.eclipse.core.runtime.MultiStatus;
28
import org.eclipse.core.runtime.MultiStatus;
24
import org.eclipse.core.runtime.Platform;
29
import org.eclipse.core.runtime.Platform;
25
import org.eclipse.core.runtime.Status;
30
import org.eclipse.core.runtime.Status;
31
import org.eclipse.swt.widgets.Display;
32
import org.eclipse.ui.PlatformUI;
33
import org.eclipse.ui.internal.IWorkbenchConstants;
26
import org.eclipse.ui.internal.WorkbenchPlugin;
34
import org.eclipse.ui.internal.WorkbenchPlugin;
27
import org.eclipse.ui.internal.util.Util;
35
import org.eclipse.ui.internal.util.Util;
28
36
Lines 95-106 Link Here
95
	/**
103
	/**
96
	 * The name of the action definitions extension point.
104
	 * The name of the action definitions extension point.
97
	 */
105
	 */
98
	private static final String EXTENSION_ACTION_DEFINITIONS = "org.eclipse.ui.actionDefinitions"; //$NON-NLS-1$
106
	private static final String EXTENSION_ACTION_DEFINITIONS = PlatformUI.PLUGIN_ID
107
			+ '.' + IWorkbenchConstants.PL_ACTION_DEFINITIONS;
99
108
100
	/**
109
	/**
101
	 * The name of the commands extension point.
110
	 * The name of the commands extension point.
102
	 */
111
	 */
103
	private static final String EXTENSION_COMMANDS = "org.eclipse.ui.commands"; //$NON-NLS-1$
112
	private static final String EXTENSION_COMMANDS = PlatformUI.PLUGIN_ID + '.'
113
			+ IWorkbenchConstants.PL_COMMANDS;
104
114
105
	/**
115
	/**
106
	 * The index of the category elements in the indexed array.
116
	 * The index of the category elements in the indexed array.
Lines 117-122 Link Here
117
	private static final int INDEX_COMMAND_DEFINITIONS = 1;
127
	private static final int INDEX_COMMAND_DEFINITIONS = 1;
118
128
119
	/**
129
	/**
130
	 * Whether the preference and registry change listeners have been attached
131
	 * yet.
132
	 */
133
    private static boolean listenersAttached = false;
134
135
	/**
120
	 * Inserts the given element into the indexed two-dimensional array in the
136
	 * Inserts the given element into the indexed two-dimensional array in the
121
	 * array at the index. The array is grown as necessary.
137
	 * array at the index. The array is grown as necessary.
122
	 * 
138
	 * 
Lines 193-198 Link Here
193
			final String name = configurationElement.getName();
209
			final String name = configurationElement.getName();
194
210
195
			if (ELEMENT_ACTION_DEFINITION.equals(name)) {
211
			if (ELEMENT_ACTION_DEFINITION.equals(name)) {
212
				System.out.println("found action definition"); //$NON-NLS-1$
196
				addElementToIndexedArray(configurationElement,
213
				addElementToIndexedArray(configurationElement,
197
						indexedConfigurationElements,
214
						indexedConfigurationElements,
198
						INDEX_COMMAND_DEFINITIONS, commandDefinitionCount++);
215
						INDEX_COMMAND_DEFINITIONS, commandDefinitionCount++);
Lines 205-210 Link Here
205
		readCommandsFromCommandsExtensionPoint(
222
		readCommandsFromCommandsExtensionPoint(
206
				indexedConfigurationElements[INDEX_COMMAND_DEFINITIONS],
223
				indexedConfigurationElements[INDEX_COMMAND_DEFINITIONS],
207
				commandDefinitionCount, commandManager);
224
				commandDefinitionCount, commandManager);
225
		
226
        /*
227
		 * Adds listener so that future registry changes trigger an update of
228
		 * the command manager automatically.
229
		 */
230
		if (!listenersAttached) {
231
			registry.addRegistryChangeListener(new IRegistryChangeListener() {
232
				public final void registryChanged(
233
						final IRegistryChangeEvent event) {
234
					/*
235
					 * TODO This should include extension points on which
236
					 * commands are depedent.
237
					 */
238
					final IExtensionDelta[] commandDeltas = event
239
							.getExtensionDeltas(PlatformUI.PLUGIN_ID,
240
									IWorkbenchConstants.PL_COMMANDS);
241
					if (commandDeltas.length == 0) {
242
						final IExtensionDelta[] actionDefinitionDeltas = event
243
								.getExtensionDeltas(
244
										PlatformUI.PLUGIN_ID,
245
										IWorkbenchConstants.PL_ACTION_DEFINITIONS);
246
						if (actionDefinitionDeltas.length == 0) {
247
							return;
248
						}
249
					}
250
251
					/*
252
					 * At least one of the deltas is non-zero, so re-read all of
253
					 * the bindings.
254
					 */
255
					Display.getDefault().asyncExec(new Runnable() {
256
						public void run() {
257
							read(commandManager);
258
						}
259
					});
260
				}
261
			}, PlatformUI.PLUGIN_ID);
262
263
			listenersAttached = true;
264
		}
208
	}
265
	}
209
266
210
	/**
267
	/**
Lines 224-229 Link Here
224
			final IConfigurationElement[] configurationElements,
281
			final IConfigurationElement[] configurationElements,
225
			final int configurationElementCount,
282
			final int configurationElementCount,
226
			final CommandManager commandManager) {
283
			final CommandManager commandManager) {
284
		// Undefine all the previous handle objects.
285
		final Set categoryIds = commandManager.getDefinedCategoryIds();
286
		if (categoryIds != null) {
287
			final Iterator categoryIdItr = categoryIds.iterator();
288
			while (categoryIdItr.hasNext()) {
289
				commandManager.getCategory((String) categoryIdItr.next())
290
						.undefine();
291
			}
292
		}
293
		
227
		/*
294
		/*
228
		 * If necessary, this list of status items will be constructed. It will
295
		 * If necessary, this list of status items will be constructed. It will
229
		 * only contains instances of <code>IStatus</code>.
296
		 * only contains instances of <code>IStatus</code>.
Lines 305-310 Link Here
305
			final IConfigurationElement[] configurationElements,
372
			final IConfigurationElement[] configurationElements,
306
			final int configurationElementCount,
373
			final int configurationElementCount,
307
			final CommandManager commandManager) {
374
			final CommandManager commandManager) {
375
		// Undefine all the previous handle objects.
376
		final Set commandIds = commandManager.getDefinedCommandIds();
377
		if (commandIds != null) {
378
			final Iterator commandIdItr = commandIds.iterator();
379
			while (commandIdItr.hasNext()) {
380
				commandManager.getCommand((String) commandIdItr.next())
381
						.undefine();
382
			}
383
		}
384
		
308
		/*
385
		/*
309
		 * If necessary, this list of status items will be constructed. It will
386
		 * If necessary, this list of status items will be constructed. It will
310
		 * only contains instances of <code>IStatus</code>.
387
		 * only contains instances of <code>IStatus</code>.
(-)Eclipse UI/org/eclipse/ui/internal/contexts/ContextPersistence.java (-3 / +75 lines)
Lines 12-27 Link Here
12
package org.eclipse.ui.internal.contexts;
12
package org.eclipse.ui.internal.contexts;
13
13
14
import java.util.ArrayList;
14
import java.util.ArrayList;
15
import java.util.Iterator;
15
import java.util.List;
16
import java.util.List;
17
import java.util.Set;
16
18
17
import org.eclipse.core.commands.contexts.Context;
19
import org.eclipse.core.commands.contexts.Context;
18
import org.eclipse.core.commands.contexts.ContextManager;
20
import org.eclipse.core.commands.contexts.ContextManager;
19
import org.eclipse.core.runtime.IConfigurationElement;
21
import org.eclipse.core.runtime.IConfigurationElement;
22
import org.eclipse.core.runtime.IExtensionDelta;
20
import org.eclipse.core.runtime.IExtensionRegistry;
23
import org.eclipse.core.runtime.IExtensionRegistry;
24
import org.eclipse.core.runtime.IRegistryChangeEvent;
25
import org.eclipse.core.runtime.IRegistryChangeListener;
21
import org.eclipse.core.runtime.IStatus;
26
import org.eclipse.core.runtime.IStatus;
22
import org.eclipse.core.runtime.MultiStatus;
27
import org.eclipse.core.runtime.MultiStatus;
23
import org.eclipse.core.runtime.Platform;
28
import org.eclipse.core.runtime.Platform;
24
import org.eclipse.core.runtime.Status;
29
import org.eclipse.core.runtime.Status;
30
import org.eclipse.swt.widgets.Display;
31
import org.eclipse.ui.PlatformUI;
32
import org.eclipse.ui.internal.IWorkbenchConstants;
25
import org.eclipse.ui.internal.WorkbenchPlugin;
33
import org.eclipse.ui.internal.WorkbenchPlugin;
26
34
27
/**
35
/**
Lines 85-101 Link Here
85
	/**
93
	/**
86
	 * The name of the accelerator scopes extension point.
94
	 * The name of the accelerator scopes extension point.
87
	 */
95
	 */
88
	private static final String EXTENSION_ACCELERATOR_SCOPES = "org.eclipse.ui.acceleratorScopes"; //$NON-NLS-1$
96
	private static final String EXTENSION_ACCELERATOR_SCOPES = PlatformUI.PLUGIN_ID
97
			+ '.' + IWorkbenchConstants.PL_ACCELERATOR_SCOPES;
89
98
90
	/**
99
	/**
91
	 * The name of the commands extension point.
100
	 * The name of the commands extension point.
92
	 */
101
	 */
93
	private static final String EXTENSION_COMMANDS = "org.eclipse.ui.commands"; //$NON-NLS-1$
102
	private static final String EXTENSION_COMMANDS = PlatformUI.PLUGIN_ID + '.'
103
			+ IWorkbenchConstants.PL_COMMANDS;
94
104
95
	/**
105
	/**
96
	 * The name of the contexts extension point.
106
	 * The name of the contexts extension point.
97
	 */
107
	 */
98
	private static final String EXTENSION_CONTEXTS = "org.eclipse.ui.contexts"; //$NON-NLS-1$
108
	private static final String EXTENSION_CONTEXTS = PlatformUI.PLUGIN_ID + '.'
109
			+ IWorkbenchConstants.PL_CONTEXTS;
99
110
100
	/**
111
	/**
101
	 * The index of the context elements in the indexed array.
112
	 * The index of the context elements in the indexed array.
Lines 105-110 Link Here
105
	private static final int INDEX_CONTEXT_DEFINITIONS = 0;
116
	private static final int INDEX_CONTEXT_DEFINITIONS = 0;
106
117
107
	/**
118
	/**
119
	 * Whether the preference and registry change listeners have been attached
120
	 * yet.
121
	 */
122
    private static boolean listenersAttached = false;
123
124
	/**
108
	 * Inserts the given element into the indexed two-dimensional array in the
125
	 * Inserts the given element into the indexed two-dimensional array in the
109
	 * array at the index. The array is grown as necessary.
126
	 * array at the index. The array is grown as necessary.
110
	 * 
127
	 * 
Lines 215-220 Link Here
215
		readContextsFromExtensionPoint(
232
		readContextsFromExtensionPoint(
216
				indexedConfigurationElements[INDEX_CONTEXT_DEFINITIONS],
233
				indexedConfigurationElements[INDEX_CONTEXT_DEFINITIONS],
217
				contextDefinitionCount, contextManager);
234
				contextDefinitionCount, contextManager);
235
		
236
        /*
237
		 * Adds listener so that future registry changes trigger an update of
238
		 * the command manager automatically.
239
		 */
240
		if (!listenersAttached) {
241
			registry.addRegistryChangeListener(new IRegistryChangeListener() {
242
				public final void registryChanged(
243
						final IRegistryChangeEvent event) {
244
					/*
245
					 * TODO This should include extension points on which
246
					 * contexts are depedent.
247
					 */
248
					final IExtensionDelta[] acceleratorScopeDeltas = event
249
							.getExtensionDeltas(
250
									PlatformUI.PLUGIN_ID,
251
									IWorkbenchConstants.PL_ACCELERATOR_SCOPES);
252
					if (acceleratorScopeDeltas.length == 0) {
253
						final IExtensionDelta[] contextDeltas = event
254
								.getExtensionDeltas(PlatformUI.PLUGIN_ID,
255
										IWorkbenchConstants.PL_CONTEXTS);
256
						if (contextDeltas.length == 0) {
257
							final IExtensionDelta[] commandDeltas = event
258
									.getExtensionDeltas(PlatformUI.PLUGIN_ID,
259
											IWorkbenchConstants.PL_COMMANDS);
260
							if (commandDeltas.length == 0) {
261
								return;
262
							}
263
						}
264
					}
265
266
					/*
267
					 * At least one of the deltas is non-zero, so re-read all of
268
					 * the bindings.
269
					 */
270
					Display.getDefault().asyncExec(new Runnable() {
271
						public void run() {
272
							read(contextManager);
273
						}
274
					});
275
				}
276
			}, PlatformUI.PLUGIN_ID);
277
278
			listenersAttached = true;
279
		}
218
	}
280
	}
219
281
220
	/**
282
	/**
Lines 234-239 Link Here
234
			final IConfigurationElement[] configurationElements,
296
			final IConfigurationElement[] configurationElements,
235
			final int configurationElementCount,
297
			final int configurationElementCount,
236
			final ContextManager contextManager) {
298
			final ContextManager contextManager) {
299
		// Undefine all the previous handle objects.
300
		final Set contextIds = contextManager.getDefinedContextIds();
301
		if (contextIds != null) {
302
			final Iterator contextIdItr = contextIds.iterator();
303
			while (contextIdItr.hasNext()) {
304
				contextManager.getContext((String) contextIdItr.next())
305
						.undefine();
306
			}
307
		}
308
		
237
		/*
309
		/*
238
		 * If necessary, this list of status items will be constructed. It will
310
		 * If necessary, this list of status items will be constructed. It will
239
		 * only contains instances of <code>IStatus</code>.
311
		 * only contains instances of <code>IStatus</code>.
(-)Eclipse UI/org/eclipse/ui/internal/handlers/HandlerPersistence.java (-11 / +96 lines)
Lines 12-17 Link Here
12
package org.eclipse.ui.internal.handlers;
12
package org.eclipse.ui.internal.handlers;
13
13
14
import java.util.ArrayList;
14
import java.util.ArrayList;
15
import java.util.Collection;
15
import java.util.List;
16
import java.util.List;
16
17
17
import org.eclipse.core.expressions.ElementHandler;
18
import org.eclipse.core.expressions.ElementHandler;
Lines 19-31 Link Here
19
import org.eclipse.core.expressions.ExpressionConverter;
20
import org.eclipse.core.expressions.ExpressionConverter;
20
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.core.runtime.IConfigurationElement;
22
import org.eclipse.core.runtime.IConfigurationElement;
23
import org.eclipse.core.runtime.IExtensionDelta;
22
import org.eclipse.core.runtime.IExtensionRegistry;
24
import org.eclipse.core.runtime.IExtensionRegistry;
25
import org.eclipse.core.runtime.IRegistryChangeEvent;
26
import org.eclipse.core.runtime.IRegistryChangeListener;
23
import org.eclipse.core.runtime.IStatus;
27
import org.eclipse.core.runtime.IStatus;
24
import org.eclipse.core.runtime.MultiStatus;
28
import org.eclipse.core.runtime.MultiStatus;
25
import org.eclipse.core.runtime.Platform;
29
import org.eclipse.core.runtime.Platform;
26
import org.eclipse.core.runtime.Status;
30
import org.eclipse.core.runtime.Status;
31
import org.eclipse.swt.widgets.Display;
27
import org.eclipse.ui.ISources;
32
import org.eclipse.ui.ISources;
33
import org.eclipse.ui.PlatformUI;
28
import org.eclipse.ui.handlers.IHandlerService;
34
import org.eclipse.ui.handlers.IHandlerService;
35
import org.eclipse.ui.internal.IWorkbenchConstants;
29
import org.eclipse.ui.internal.WorkbenchPlugin;
36
import org.eclipse.ui.internal.WorkbenchPlugin;
30
37
31
/**
38
/**
Lines 100-111 Link Here
100
	/**
107
	/**
101
	 * The name of the commands extension point.
108
	 * The name of the commands extension point.
102
	 */
109
	 */
103
	private static final String EXTENSION_COMMANDS = "org.eclipse.ui.commands"; //$NON-NLS-1$
110
	private static final String EXTENSION_COMMANDS = PlatformUI.PLUGIN_ID + '.'
111
			+ IWorkbenchConstants.PL_COMMANDS;
104
112
105
	/**
113
	/**
106
	 * The name of the commands extension point.
114
	 * The name of the commands extension point.
107
	 */
115
	 */
108
	private static final String EXTENSION_HANDLERS = "org.eclipse.ui.handlers"; //$NON-NLS-1$
116
	private static final String EXTENSION_HANDLERS = PlatformUI.PLUGIN_ID + '.'
117
			+ IWorkbenchConstants.PL_HANDLERS;
118
	
119
	/**
120
	 * The handler activations that have come from the registry. This is used to
121
	 * flush the activations when the registry is re-read. This value is never
122
	 * <code>null</code>
123
	 */
124
	private static final Collection handlerActivations = new ArrayList();
109
125
110
	/**
126
	/**
111
	 * The index of the command elements in the indexed array.
127
	 * The index of the command elements in the indexed array.
Lines 129-134 Link Here
129
	private static final int INDEX_HANDLER_SUBMISSIONS = 2;
145
	private static final int INDEX_HANDLER_SUBMISSIONS = 2;
130
146
131
	/**
147
	/**
148
	 * Whether the preference and registry change listeners have been attached
149
	 * yet.
150
	 */
151
    private static boolean listenersAttached = false;
152
153
	/**
132
	 * Inserts the given element into the indexed two-dimensional array in the
154
	 * Inserts the given element into the indexed two-dimensional array in the
133
	 * array at the index. The array is grown as necessary.
155
	 * array at the index. The array is grown as necessary.
134
	 * 
156
	 * 
Lines 164-169 Link Here
164
		}
186
		}
165
		elements[currentCount] = elementToAdd;
187
		elements[currentCount] = elementToAdd;
166
	}
188
	}
189
	
190
	/**
191
	 * Deactivates all of the activations made by this class, and then clears
192
	 * the collection. This should be called before every read.
193
	 * 
194
	 * @param handlerService
195
	 *            The service handling the activations; must not be
196
	 *            <code>null</code>.
197
	 */
198
	private static final void clearActivations(
199
			final IHandlerService handlerService) {
200
		handlerService.deactivateHandlers(handlerActivations);
201
		handlerActivations.clear();
202
	}
167
203
168
	/**
204
	/**
169
	 * Reads all of the handlers from the registry
205
	 * Reads all of the handlers from the registry
Lines 214-219 Link Here
214
			}
250
			}
215
		}
251
		}
216
252
253
		clearActivations(handlerService);
217
		readDefaultHandlersFromCommandsExtensionPoint(
254
		readDefaultHandlersFromCommandsExtensionPoint(
218
				indexedConfigurationElements[INDEX_COMMAND_DEFINITIONS],
255
				indexedConfigurationElements[INDEX_COMMAND_DEFINITIONS],
219
				commandDefinitionCount, handlerService);
256
				commandDefinitionCount, handlerService);
Lines 223-228 Link Here
223
		readHandlersFromHandlersExtensionPoint(
260
		readHandlersFromHandlersExtensionPoint(
224
				indexedConfigurationElements[INDEX_HANDLER_DEFINITIONS],
261
				indexedConfigurationElements[INDEX_HANDLER_DEFINITIONS],
225
				handlerDefinitionCount, handlerService);
262
				handlerDefinitionCount, handlerService);
263
		
264
		/*
265
		 * Adds listener so that future registry changes trigger an update of
266
		 * the command manager automatically.
267
		 */
268
		if (!listenersAttached) {
269
			registry.addRegistryChangeListener(new IRegistryChangeListener() {
270
				public final void registryChanged(
271
						final IRegistryChangeEvent event) {
272
					/*
273
					 * TODO This should include extension points on which
274
					 * handlers are depedent.
275
					 */
276
					final IExtensionDelta[] acceleratorConfigurationDeltas = event
277
							.getExtensionDeltas(
278
									PlatformUI.PLUGIN_ID,
279
									IWorkbenchConstants.PL_ACCELERATOR_CONFIGURATIONS);
280
					if (acceleratorConfigurationDeltas.length == 0) {
281
						final IExtensionDelta[] bindingDeltas = event
282
								.getExtensionDeltas(PlatformUI.PLUGIN_ID,
283
										IWorkbenchConstants.PL_BINDINGS);
284
						if (bindingDeltas.length == 0) {
285
							final IExtensionDelta[] commandDeltas = event
286
									.getExtensionDeltas(PlatformUI.PLUGIN_ID,
287
											IWorkbenchConstants.PL_COMMANDS);
288
							if (commandDeltas.length == 0) {
289
								return;
290
							}
291
						}
292
					}
293
294
					/*
295
					 * At least one of the deltas is non-zero, so re-read all of
296
					 * the bindings.
297
					 */
298
					Display.getDefault().asyncExec(new Runnable() {
299
						public void run() {
300
							read(handlerService);
301
						}
302
					});
303
				}
304
			}, PlatformUI.PLUGIN_ID);
305
306
			listenersAttached = true;
307
		}
226
	}
308
	}
227
309
228
	/**
310
	/**
Lines 260-267 Link Here
260
				continue;
342
				continue;
261
			}
343
			}
262
344
263
			handlerService.activateHandler(commandId, new HandlerProxy(
345
			handlerActivations.add(handlerService.activateHandler(commandId,
264
					configurationElement, ATTRIBUTE_DEFAULT_HANDLER));
346
					new HandlerProxy(configurationElement,
347
							ATTRIBUTE_DEFAULT_HANDLER)));
265
		}
348
		}
266
	}
349
	}
267
350
Lines 412-429 Link Here
412
			}
495
			}
413
496
414
			if (activeWhenExpression != null) {
497
			if (activeWhenExpression != null) {
415
				handlerService
498
				handlerActivations.add(handlerService
416
						.activateHandler(commandId, new HandlerProxy(
499
						.activateHandler(commandId, new HandlerProxy(
417
								configurationElement, ATTRIBUTE_CLASS,
500
								configurationElement, ATTRIBUTE_CLASS,
418
								enabledWhenExpression, handlerService),
501
								enabledWhenExpression, handlerService),
419
								activeWhenExpression, ISources.ACTIVE_CONTEXT
502
								activeWhenExpression, ISources.ACTIVE_CONTEXT
420
										| ISources.ACTIVE_CURRENT_SELECTION
503
										| ISources.ACTIVE_CURRENT_SELECTION
421
										| ISources.ACTIVE_EDITOR
504
										| ISources.ACTIVE_EDITOR
422
										| ISources.ACTIVE_PART);
505
										| ISources.ACTIVE_PART));
423
			} else {
506
			} else {
424
				handlerService.activateHandler(commandId, new HandlerProxy(
507
				handlerActivations.add(handlerService.activateHandler(
425
						configurationElement, ATTRIBUTE_CLASS,
508
						commandId, new HandlerProxy(configurationElement,
426
						enabledWhenExpression, handlerService));
509
								ATTRIBUTE_CLASS, enabledWhenExpression,
510
								handlerService)));
427
			}
511
			}
428
		}
512
		}
429
513
Lines 480-487 Link Here
480
				continue;
564
				continue;
481
			}
565
			}
482
566
483
			handlerService.activateHandler(commandId, new LegacyHandlerWrapper(
567
			handlerActivations.add(handlerService.activateHandler(commandId,
484
					new LegacyHandlerProxy(configurationElement)));
568
					new LegacyHandlerWrapper(new LegacyHandlerProxy(
569
							configurationElement))));
485
		}
570
		}
486
571
487
		// If there were any warnings, then log them now.
572
		// If there were any warnings, then log them now.
(-)Eclipse UI/org/eclipse/ui/internal/keys/BindingPersistence.java (-22 / +80 lines)
Lines 27-35 Link Here
27
import org.eclipse.core.commands.IParameter;
27
import org.eclipse.core.commands.IParameter;
28
import org.eclipse.core.commands.Parameterization;
28
import org.eclipse.core.commands.Parameterization;
29
import org.eclipse.core.commands.ParameterizedCommand;
29
import org.eclipse.core.commands.ParameterizedCommand;
30
import org.eclipse.core.commands.common.HandleObject;
30
import org.eclipse.core.commands.common.NotDefinedException;
31
import org.eclipse.core.commands.common.NotDefinedException;
31
import org.eclipse.core.runtime.IConfigurationElement;
32
import org.eclipse.core.runtime.IConfigurationElement;
33
import org.eclipse.core.runtime.IExtensionDelta;
32
import org.eclipse.core.runtime.IExtensionRegistry;
34
import org.eclipse.core.runtime.IExtensionRegistry;
35
import org.eclipse.core.runtime.IRegistryChangeEvent;
36
import org.eclipse.core.runtime.IRegistryChangeListener;
33
import org.eclipse.core.runtime.IStatus;
37
import org.eclipse.core.runtime.IStatus;
34
import org.eclipse.core.runtime.MultiStatus;
38
import org.eclipse.core.runtime.MultiStatus;
35
import org.eclipse.core.runtime.Platform;
39
import org.eclipse.core.runtime.Platform;
Lines 50-61 Link Here
50
import org.eclipse.jface.util.PropertyChangeEvent;
54
import org.eclipse.jface.util.PropertyChangeEvent;
51
import org.eclipse.jface.util.Util;
55
import org.eclipse.jface.util.Util;
52
import org.eclipse.swt.SWT;
56
import org.eclipse.swt.SWT;
57
import org.eclipse.swt.widgets.Display;
53
import org.eclipse.ui.IMemento;
58
import org.eclipse.ui.IMemento;
54
import org.eclipse.ui.IWorkbenchPreferenceConstants;
59
import org.eclipse.ui.IWorkbenchPreferenceConstants;
55
import org.eclipse.ui.PlatformUI;
60
import org.eclipse.ui.PlatformUI;
56
import org.eclipse.ui.WorkbenchException;
61
import org.eclipse.ui.WorkbenchException;
57
import org.eclipse.ui.XMLMemento;
62
import org.eclipse.ui.XMLMemento;
58
import org.eclipse.ui.commands.ICommandService;
63
import org.eclipse.ui.commands.ICommandService;
64
import org.eclipse.ui.internal.IWorkbenchConstants;
59
import org.eclipse.ui.internal.WorkbenchPlugin;
65
import org.eclipse.ui.internal.WorkbenchPlugin;
60
import org.eclipse.ui.internal.misc.Policy;
66
import org.eclipse.ui.internal.misc.Policy;
61
import org.eclipse.ui.keys.IBindingService;
67
import org.eclipse.ui.keys.IBindingService;
Lines 231-248 Link Here
231
	/**
237
	/**
232
	 * The name of the deprecated accelerator configurations extension point.
238
	 * The name of the deprecated accelerator configurations extension point.
233
	 */
239
	 */
234
	private static final String EXTENSION_ACCELERATOR_CONFIGURATIONS = "org.eclipse.ui.acceleratorConfigurations"; //$NON-NLS-1$
240
	private static final String EXTENSION_ACCELERATOR_CONFIGURATIONS = PlatformUI.PLUGIN_ID
241
			+ '.' + IWorkbenchConstants.PL_ACCELERATOR_CONFIGURATIONS;
235
242
236
	/**
243
	/**
237
	 * The name of the bindings extension point.
244
	 * The name of the bindings extension point.
238
	 */
245
	 */
239
	private static final String EXTENSION_BINDINGS = "org.eclipse.ui.bindings"; //$NON-NLS-1$
246
	private static final String EXTENSION_BINDINGS = PlatformUI.PLUGIN_ID + '.'
247
			+ IWorkbenchConstants.PL_BINDINGS;
240
248
241
	/**
249
	/**
242
	 * The name of the commands extension point, and the name of the key for the
250
	 * The name of the commands extension point, and the name of the key for the
243
	 * commands preferences.
251
	 * commands preferences.
244
	 */
252
	 */
245
	private static final String EXTENSION_COMMANDS = "org.eclipse.ui.commands"; //$NON-NLS-1$
253
	private static final String EXTENSION_COMMANDS = PlatformUI.PLUGIN_ID + '.'
254
			+ IWorkbenchConstants.PL_COMMANDS;
246
255
247
	/**
256
	/**
248
	 * The index of the active scheme configuration elements in the indexed
257
	 * The index of the active scheme configuration elements in the indexed
Lines 274-288 Link Here
274
	private static final String LEGACY_DEFAULT_SCOPE = "org.eclipse.ui.globalScope"; //$NON-NLS-1$
283
	private static final String LEGACY_DEFAULT_SCOPE = "org.eclipse.ui.globalScope"; //$NON-NLS-1$
275
284
276
	/**
285
	/**
286
	 * Whether the preference and registry change listeners have been attached
287
	 * yet.
288
	 */
289
    private static boolean listenersAttached = false;
290
    
291
    /**
277
	 * A look-up map for 2.1.x style <code>string</code> keys on a
292
	 * A look-up map for 2.1.x style <code>string</code> keys on a
278
	 * <code>keyBinding</code> element.
293
	 * <code>keyBinding</code> element.
279
	 */
294
	 */
280
	private static final Map r2_1KeysByName = new HashMap();
295
	private static final Map r2_1KeysByName = new HashMap();
281
    
282
    /**
283
     * Whether the property change listener has been attached yet.
284
     */
285
    private static boolean propertyChangeListenerAttached = false;
286
296
287
	static {
297
	static {
288
		final IKeyLookup lookup = KeyLookupFactory.getDefault();
298
		final IKeyLookup lookup = KeyLookupFactory.getDefault();
Lines 642-660 Link Here
642
                commandService);
652
                commandService);
643
653
644
        /*
654
        /*
645
         * Add a listener so that future preference changes trigger an update of
655
		 * Adds listener so that future preference and registry changes trigger
646
         * the binding manager automatically.
656
		 * an update of the binding manager automatically.
647
         */
657
		 */
648
        if (!propertyChangeListenerAttached) {
658
        if (!listenersAttached) {
649
            store.addPropertyChangeListener(new IPropertyChangeListener() {
659
			store.addPropertyChangeListener(new IPropertyChangeListener() {
650
                public void propertyChange(PropertyChangeEvent event) {
660
				public final void propertyChange(final PropertyChangeEvent event) {
651
                    if (EXTENSION_COMMANDS.equals(event.getProperty())) {
661
					if (EXTENSION_COMMANDS.equals(event.getProperty())) {
652
                        read(bindingManager, commandService);
662
						read(bindingManager, commandService);
653
                    }
663
					}
654
                }
664
				}
655
            });
665
			});
656
            propertyChangeListenerAttached = true;
666
657
        }
667
			registry.addRegistryChangeListener(new IRegistryChangeListener() {
668
				public final void registryChanged(
669
						final IRegistryChangeEvent event) {
670
					/*
671
					 * TODO This should include extension points on which
672
					 * bindings are depedent.
673
					 */
674
					final IExtensionDelta[] acceleratorConfigurationDeltas = event
675
							.getExtensionDeltas(
676
									PlatformUI.PLUGIN_ID,
677
									IWorkbenchConstants.PL_ACCELERATOR_CONFIGURATIONS);
678
					if (acceleratorConfigurationDeltas.length == 0) {
679
						final IExtensionDelta[] bindingDeltas = event
680
								.getExtensionDeltas(PlatformUI.PLUGIN_ID,
681
										IWorkbenchConstants.PL_BINDINGS);
682
						if (bindingDeltas.length == 0) {
683
							final IExtensionDelta[] commandDeltas = event
684
									.getExtensionDeltas(PlatformUI.PLUGIN_ID,
685
											IWorkbenchConstants.PL_COMMANDS);
686
							if (commandDeltas.length == 0) {
687
								return;
688
							}
689
						}
690
					}
691
					
692
					/*
693
					 * At least one of the deltas is non-zero, so re-read all of
694
					 * the bindings.
695
					 */
696
					Display.getDefault().asyncExec(new Runnable() {
697
						public void run() {
698
							read(bindingManager, commandService);
699
						}
700
					});
701
				}
702
			}, PlatformUI.PLUGIN_ID);
703
704
			listenersAttached = true;
705
		}
658
    }
706
    }
659
707
660
708
Lines 778-784 Link Here
778
							.getScheme(IBindingService.DEFAULT_DEFAULT_ACTIVE_SCHEME_ID));
826
							.getScheme(IBindingService.DEFAULT_DEFAULT_ACTIVE_SCHEME_ID));
779
		} catch (final NotDefinedException e) {
827
		} catch (final NotDefinedException e) {
780
			// Damn, we're fucked.
828
			// Damn, we're fucked.
781
			throw new Error("You cannot make something from nothing"); //$NON-NLS-1$
829
			throw new Error(
830
					"The default default active scheme id is not defined."); //$NON-NLS-1$
782
		}
831
		}
783
	}
832
	}
784
833
Lines 1365-1370 Link Here
1365
			final IConfigurationElement[] configurationElements,
1414
			final IConfigurationElement[] configurationElements,
1366
			final int configurationElementCount,
1415
			final int configurationElementCount,
1367
			final BindingManager bindingManager) {
1416
			final BindingManager bindingManager) {
1417
		// Undefine all the previous handle objects.
1418
		final HandleObject[] handleObjects = bindingManager
1419
				.getDefinedSchemes();
1420
		if (handleObjects != null) {
1421
			for (int i = 0; i < handleObjects.length; i++) {
1422
				handleObjects[i].undefine();
1423
			}
1424
		}
1425
		
1368
		for (int i = 0; i < configurationElementCount; i++) {
1426
		for (int i = 0; i < configurationElementCount; i++) {
1369
			final IConfigurationElement configurationElement = configurationElements[i];
1427
			final IConfigurationElement configurationElement = configurationElements[i];
1370
1428

Return to bug 96600