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 / +76 lines)
Lines 17-28 Link Here
17
import org.eclipse.core.commands.Category;
17
import org.eclipse.core.commands.Category;
18
import org.eclipse.core.commands.Command;
18
import org.eclipse.core.commands.Command;
19
import org.eclipse.core.commands.CommandManager;
19
import org.eclipse.core.commands.CommandManager;
20
import org.eclipse.core.commands.common.HandleObject;
20
import org.eclipse.core.runtime.IConfigurationElement;
21
import org.eclipse.core.runtime.IConfigurationElement;
22
import org.eclipse.core.runtime.IExtensionDelta;
21
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;
22
import org.eclipse.core.runtime.IStatus;
26
import org.eclipse.core.runtime.IStatus;
23
import org.eclipse.core.runtime.MultiStatus;
27
import org.eclipse.core.runtime.MultiStatus;
24
import org.eclipse.core.runtime.Platform;
28
import org.eclipse.core.runtime.Platform;
25
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;
26
import org.eclipse.ui.internal.WorkbenchPlugin;
33
import org.eclipse.ui.internal.WorkbenchPlugin;
27
import org.eclipse.ui.internal.util.Util;
34
import org.eclipse.ui.internal.util.Util;
28
35
Lines 95-106 Link Here
95
	/**
102
	/**
96
	 * The name of the action definitions extension point.
103
	 * The name of the action definitions extension point.
97
	 */
104
	 */
98
	private static final String EXTENSION_ACTION_DEFINITIONS = "org.eclipse.ui.actionDefinitions"; //$NON-NLS-1$
105
	private static final String EXTENSION_ACTION_DEFINITIONS = PlatformUI.PLUGIN_ID
106
			+ '.' + IWorkbenchConstants.PL_ACTION_DEFINITIONS;
99
107
100
	/**
108
	/**
101
	 * The name of the commands extension point.
109
	 * The name of the commands extension point.
102
	 */
110
	 */
103
	private static final String EXTENSION_COMMANDS = "org.eclipse.ui.commands"; //$NON-NLS-1$
111
	private static final String EXTENSION_COMMANDS = PlatformUI.PLUGIN_ID + '.'
112
			+ IWorkbenchConstants.PL_COMMANDS;
104
113
105
	/**
114
	/**
106
	 * The index of the category elements in the indexed array.
115
	 * The index of the category elements in the indexed array.
Lines 117-122 Link Here
117
	private static final int INDEX_COMMAND_DEFINITIONS = 1;
126
	private static final int INDEX_COMMAND_DEFINITIONS = 1;
118
127
119
	/**
128
	/**
129
	 * Whether the preference and registry change listeners have been attached
130
	 * yet.
131
	 */
132
    private static boolean listenersAttached = false;
133
134
	/**
120
	 * Inserts the given element into the indexed two-dimensional array in the
135
	 * Inserts the given element into the indexed two-dimensional array in the
121
	 * array at the index. The array is grown as necessary.
136
	 * array at the index. The array is grown as necessary.
122
	 * 
137
	 * 
Lines 193-198 Link Here
193
			final String name = configurationElement.getName();
208
			final String name = configurationElement.getName();
194
209
195
			if (ELEMENT_ACTION_DEFINITION.equals(name)) {
210
			if (ELEMENT_ACTION_DEFINITION.equals(name)) {
211
				System.out.println("found action definition"); //$NON-NLS-1$
196
				addElementToIndexedArray(configurationElement,
212
				addElementToIndexedArray(configurationElement,
197
						indexedConfigurationElements,
213
						indexedConfigurationElements,
198
						INDEX_COMMAND_DEFINITIONS, commandDefinitionCount++);
214
						INDEX_COMMAND_DEFINITIONS, commandDefinitionCount++);
Lines 205-210 Link Here
205
		readCommandsFromCommandsExtensionPoint(
221
		readCommandsFromCommandsExtensionPoint(
206
				indexedConfigurationElements[INDEX_COMMAND_DEFINITIONS],
222
				indexedConfigurationElements[INDEX_COMMAND_DEFINITIONS],
207
				commandDefinitionCount, commandManager);
223
				commandDefinitionCount, commandManager);
224
		
225
        /*
226
		 * Adds listener so that future registry changes trigger an update of
227
		 * the command manager automatically.
228
		 */
229
		if (!listenersAttached) {
230
			registry.addRegistryChangeListener(new IRegistryChangeListener() {
231
				public final void registryChanged(
232
						final IRegistryChangeEvent event) {
233
					/*
234
					 * TODO This should include extension points on which
235
					 * commands are depedent.
236
					 */
237
					final IExtensionDelta[] commandDeltas = event
238
							.getExtensionDeltas(PlatformUI.PLUGIN_ID,
239
									IWorkbenchConstants.PL_COMMANDS);
240
					if (commandDeltas.length == 0) {
241
						final IExtensionDelta[] actionDefinitionDeltas = event
242
								.getExtensionDeltas(
243
										PlatformUI.PLUGIN_ID,
244
										IWorkbenchConstants.PL_ACTION_DEFINITIONS);
245
						if (actionDefinitionDeltas.length == 0) {
246
							return;
247
						}
248
					}
249
250
					/*
251
					 * At least one of the deltas is non-zero, so re-read all of
252
					 * the bindings.
253
					 */
254
					Display.getDefault().asyncExec(new Runnable() {
255
						public void run() {
256
							read(commandManager);
257
						}
258
					});
259
				}
260
			}, PlatformUI.PLUGIN_ID);
261
262
			listenersAttached = true;
263
		}
208
	}
264
	}
209
265
210
	/**
266
	/**
Lines 224-229 Link Here
224
			final IConfigurationElement[] configurationElements,
280
			final IConfigurationElement[] configurationElements,
225
			final int configurationElementCount,
281
			final int configurationElementCount,
226
			final CommandManager commandManager) {
282
			final CommandManager commandManager) {
283
		// Undefine all the previous handle objects.
284
		final HandleObject[] handleObjects = commandManager
285
				.getDefinedCategories();
286
		if (handleObjects != null) {
287
			for (int i = 0; i < handleObjects.length; i++) {
288
				handleObjects[i].undefine();
289
			}
290
		}
291
		
227
		/*
292
		/*
228
		 * If necessary, this list of status items will be constructed. It will
293
		 * If necessary, this list of status items will be constructed. It will
229
		 * only contains instances of <code>IStatus</code>.
294
		 * only contains instances of <code>IStatus</code>.
Lines 305-310 Link Here
305
			final IConfigurationElement[] configurationElements,
370
			final IConfigurationElement[] configurationElements,
306
			final int configurationElementCount,
371
			final int configurationElementCount,
307
			final CommandManager commandManager) {
372
			final CommandManager commandManager) {
373
		// Undefine all the previous handle objects.
374
		final HandleObject[] handleObjects = commandManager
375
				.getDefinedCommands();
376
		if (handleObjects != null) {
377
			for (int i = 0; i < handleObjects.length; i++) {
378
				handleObjects[i].undefine();
379
			}
380
		}
381
		
308
		/*
382
		/*
309
		 * If necessary, this list of status items will be constructed. It will
383
		 * If necessary, this list of status items will be constructed. It will
310
		 * only contains instances of <code>IStatus</code>.
384
		 * only contains instances of <code>IStatus</code>.
(-)Eclipse UI/org/eclipse/ui/internal/contexts/ContextPersistence.java (-3 / +73 lines)
Lines 14-27 Link Here
14
import java.util.ArrayList;
14
import java.util.ArrayList;
15
import java.util.List;
15
import java.util.List;
16
16
17
import org.eclipse.core.commands.common.HandleObject;
17
import org.eclipse.core.commands.contexts.Context;
18
import org.eclipse.core.commands.contexts.Context;
18
import org.eclipse.core.commands.contexts.ContextManager;
19
import org.eclipse.core.commands.contexts.ContextManager;
19
import org.eclipse.core.runtime.IConfigurationElement;
20
import org.eclipse.core.runtime.IConfigurationElement;
21
import org.eclipse.core.runtime.IExtensionDelta;
20
import org.eclipse.core.runtime.IExtensionRegistry;
22
import org.eclipse.core.runtime.IExtensionRegistry;
23
import org.eclipse.core.runtime.IRegistryChangeEvent;
24
import org.eclipse.core.runtime.IRegistryChangeListener;
21
import org.eclipse.core.runtime.IStatus;
25
import org.eclipse.core.runtime.IStatus;
22
import org.eclipse.core.runtime.MultiStatus;
26
import org.eclipse.core.runtime.MultiStatus;
23
import org.eclipse.core.runtime.Platform;
27
import org.eclipse.core.runtime.Platform;
24
import org.eclipse.core.runtime.Status;
28
import org.eclipse.core.runtime.Status;
29
import org.eclipse.swt.widgets.Display;
30
import org.eclipse.ui.PlatformUI;
31
import org.eclipse.ui.internal.IWorkbenchConstants;
25
import org.eclipse.ui.internal.WorkbenchPlugin;
32
import org.eclipse.ui.internal.WorkbenchPlugin;
26
33
27
/**
34
/**
Lines 85-101 Link Here
85
	/**
92
	/**
86
	 * The name of the accelerator scopes extension point.
93
	 * The name of the accelerator scopes extension point.
87
	 */
94
	 */
88
	private static final String EXTENSION_ACCELERATOR_SCOPES = "org.eclipse.ui.acceleratorScopes"; //$NON-NLS-1$
95
	private static final String EXTENSION_ACCELERATOR_SCOPES = PlatformUI.PLUGIN_ID
96
			+ '.' + IWorkbenchConstants.PL_ACCELERATOR_SCOPES;
89
97
90
	/**
98
	/**
91
	 * The name of the commands extension point.
99
	 * The name of the commands extension point.
92
	 */
100
	 */
93
	private static final String EXTENSION_COMMANDS = "org.eclipse.ui.commands"; //$NON-NLS-1$
101
	private static final String EXTENSION_COMMANDS = PlatformUI.PLUGIN_ID + '.'
102
			+ IWorkbenchConstants.PL_COMMANDS;
94
103
95
	/**
104
	/**
96
	 * The name of the contexts extension point.
105
	 * The name of the contexts extension point.
97
	 */
106
	 */
98
	private static final String EXTENSION_CONTEXTS = "org.eclipse.ui.contexts"; //$NON-NLS-1$
107
	private static final String EXTENSION_CONTEXTS = PlatformUI.PLUGIN_ID + '.'
108
			+ IWorkbenchConstants.PL_CONTEXTS;
99
109
100
	/**
110
	/**
101
	 * The index of the context elements in the indexed array.
111
	 * The index of the context elements in the indexed array.
Lines 105-110 Link Here
105
	private static final int INDEX_CONTEXT_DEFINITIONS = 0;
115
	private static final int INDEX_CONTEXT_DEFINITIONS = 0;
106
116
107
	/**
117
	/**
118
	 * Whether the preference and registry change listeners have been attached
119
	 * yet.
120
	 */
121
    private static boolean listenersAttached = false;
122
123
	/**
108
	 * Inserts the given element into the indexed two-dimensional array in the
124
	 * Inserts the given element into the indexed two-dimensional array in the
109
	 * array at the index. The array is grown as necessary.
125
	 * array at the index. The array is grown as necessary.
110
	 * 
126
	 * 
Lines 215-220 Link Here
215
		readContextsFromExtensionPoint(
231
		readContextsFromExtensionPoint(
216
				indexedConfigurationElements[INDEX_CONTEXT_DEFINITIONS],
232
				indexedConfigurationElements[INDEX_CONTEXT_DEFINITIONS],
217
				contextDefinitionCount, contextManager);
233
				contextDefinitionCount, contextManager);
234
		
235
        /*
236
		 * Adds listener so that future registry changes trigger an update of
237
		 * the command manager automatically.
238
		 */
239
		if (!listenersAttached) {
240
			registry.addRegistryChangeListener(new IRegistryChangeListener() {
241
				public final void registryChanged(
242
						final IRegistryChangeEvent event) {
243
					/*
244
					 * TODO This should include extension points on which
245
					 * contexts are depedent.
246
					 */
247
					final IExtensionDelta[] acceleratorScopeDeltas = event
248
							.getExtensionDeltas(
249
									PlatformUI.PLUGIN_ID,
250
									IWorkbenchConstants.PL_ACCELERATOR_SCOPES);
251
					if (acceleratorScopeDeltas.length == 0) {
252
						final IExtensionDelta[] contextDeltas = event
253
								.getExtensionDeltas(PlatformUI.PLUGIN_ID,
254
										IWorkbenchConstants.PL_CONTEXTS);
255
						if (contextDeltas.length == 0) {
256
							final IExtensionDelta[] commandDeltas = event
257
									.getExtensionDeltas(PlatformUI.PLUGIN_ID,
258
											IWorkbenchConstants.PL_COMMANDS);
259
							if (commandDeltas.length == 0) {
260
								return;
261
							}
262
						}
263
					}
264
265
					/*
266
					 * At least one of the deltas is non-zero, so re-read all of
267
					 * the bindings.
268
					 */
269
					Display.getDefault().asyncExec(new Runnable() {
270
						public void run() {
271
							read(contextManager);
272
						}
273
					});
274
				}
275
			}, PlatformUI.PLUGIN_ID);
276
277
			listenersAttached = true;
278
		}
218
	}
279
	}
219
280
220
	/**
281
	/**
Lines 234-239 Link Here
234
			final IConfigurationElement[] configurationElements,
295
			final IConfigurationElement[] configurationElements,
235
			final int configurationElementCount,
296
			final int configurationElementCount,
236
			final ContextManager contextManager) {
297
			final ContextManager contextManager) {
298
		// Undefine all the previous handle objects.
299
		final HandleObject[] handleObjects = contextManager
300
				.getDefinedContexts();
301
		if (handleObjects != null) {
302
			for (int i = 0; i < handleObjects.length; i++) {
303
				handleObjects[i].undefine();
304
			}
305
		}
306
		
237
		/*
307
		/*
238
		 * If necessary, this list of status items will be constructed. It will
308
		 * If necessary, this list of status items will be constructed. It will
239
		 * only contains instances of <code>IStatus</code>.
309
		 * 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