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 / +86 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 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
					final IExtensionDelta[] commandDeltas = event
234
							.getExtensionDeltas(PlatformUI.PLUGIN_ID,
235
									IWorkbenchConstants.PL_COMMANDS);
236
					if (commandDeltas.length == 0) {
237
						final IExtensionDelta[] actionDefinitionDeltas = event
238
								.getExtensionDeltas(
239
										PlatformUI.PLUGIN_ID,
240
										IWorkbenchConstants.PL_ACTION_DEFINITIONS);
241
						if (actionDefinitionDeltas.length == 0) {
242
							return;
243
						}
244
					}
245
246
					/*
247
					 * At least one of the deltas is non-zero, so re-read all of
248
					 * the bindings.
249
					 */
250
					Display.getDefault().asyncExec(new Runnable() {
251
						public void run() {
252
							read(commandManager);
253
						}
254
					});
255
				}
256
			}, PlatformUI.PLUGIN_ID);
257
258
			listenersAttached = true;
259
		}
208
	}
260
	}
209
261
210
	/**
262
	/**
Lines 224-229 Link Here
224
			final IConfigurationElement[] configurationElements,
276
			final IConfigurationElement[] configurationElements,
225
			final int configurationElementCount,
277
			final int configurationElementCount,
226
			final CommandManager commandManager) {
278
			final CommandManager commandManager) {
279
		// Undefine all the previous handle objects.
280
		final Set categoryIds = commandManager.getDefinedCategoryIds();
281
		if (categoryIds != null) {
282
			final Iterator categoryIdItr = categoryIds.iterator();
283
			final Category[] categories = new Category[categoryIds.size()];
284
			int i = 0;
285
			
286
			while (categoryIdItr.hasNext()) {
287
				categories[i++] = commandManager.getCategory((String) categoryIdItr.next());
288
			}
289
290
			for (int j = 0; j < categories.length; j++) {
291
				categories[j].undefine();
292
			}
293
		}
294
		
227
		/*
295
		/*
228
		 * If necessary, this list of status items will be constructed. It will
296
		 * If necessary, this list of status items will be constructed. It will
229
		 * only contains instances of <code>IStatus</code>.
297
		 * only contains instances of <code>IStatus</code>.
Lines 305-310 Link Here
305
			final IConfigurationElement[] configurationElements,
373
			final IConfigurationElement[] configurationElements,
306
			final int configurationElementCount,
374
			final int configurationElementCount,
307
			final CommandManager commandManager) {
375
			final CommandManager commandManager) {
376
		// Undefine all the previous handle objects.
377
		final Set commandIds = commandManager.getDefinedCommandIds();
378
		if (commandIds != null) {
379
			final Iterator commandIdItr = commandIds.iterator();
380
			final Command[] commands = new Command[commandIds.size()];
381
			int i = 0;
382
			
383
			while (commandIdItr.hasNext()) {
384
				commands[i++] = commandManager.getCommand((String) commandIdItr.next());
385
			}
386
387
			for (int j = 0; j < commands.length; j++) {
388
				commands[j].undefine();
389
			}
390
		}
391
		
308
		/*
392
		/*
309
		 * If necessary, this list of status items will be constructed. It will
393
		 * If necessary, this list of status items will be constructed. It will
310
		 * only contains instances of <code>IStatus</code>.
394
		 * only contains instances of <code>IStatus</code>.
(-)Eclipse UI/org/eclipse/ui/internal/contexts/ContextPersistence.java (-3 / +77 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
					final IExtensionDelta[] acceleratorScopeDeltas = event
245
							.getExtensionDeltas(
246
									PlatformUI.PLUGIN_ID,
247
									IWorkbenchConstants.PL_ACCELERATOR_SCOPES);
248
					if (acceleratorScopeDeltas.length == 0) {
249
						final IExtensionDelta[] contextDeltas = event
250
								.getExtensionDeltas(PlatformUI.PLUGIN_ID,
251
										IWorkbenchConstants.PL_CONTEXTS);
252
						if (contextDeltas.length == 0) {
253
							final IExtensionDelta[] commandDeltas = event
254
									.getExtensionDeltas(PlatformUI.PLUGIN_ID,
255
											IWorkbenchConstants.PL_COMMANDS);
256
							if (commandDeltas.length == 0) {
257
								return;
258
							}
259
						}
260
					}
261
262
					/*
263
					 * At least one of the deltas is non-zero, so re-read all of
264
					 * the bindings.
265
					 */
266
					Display.getDefault().asyncExec(new Runnable() {
267
						public void run() {
268
							read(contextManager);
269
						}
270
					});
271
				}
272
			}, PlatformUI.PLUGIN_ID);
273
274
			listenersAttached = true;
275
		}
218
	}
276
	}
219
277
220
	/**
278
	/**
Lines 234-239 Link Here
234
			final IConfigurationElement[] configurationElements,
292
			final IConfigurationElement[] configurationElements,
235
			final int configurationElementCount,
293
			final int configurationElementCount,
236
			final ContextManager contextManager) {
294
			final ContextManager contextManager) {
295
		// Undefine all the previous handle objects.
296
		final Set contextIds = contextManager.getDefinedContextIds();
297
		if (contextIds != null) {
298
			final Iterator contextIdItr = contextIds.iterator();
299
			final Context[] contexts = new Context[contextIds.size()];
300
			int i = 0;
301
			
302
			while (contextIdItr.hasNext()) {
303
				contexts[i++] = contextManager.getContext((String) contextIdItr.next());
304
			}
305
306
			for (int j = 0; j < contexts.length; j++) {
307
				contexts[j].undefine();
308
			}
309
		}
310
		
237
		/*
311
		/*
238
		 * If necessary, this list of status items will be constructed. It will
312
		 * If necessary, this list of status items will be constructed. It will
239
		 * only contains instances of <code>IStatus</code>.
313
		 * only contains instances of <code>IStatus</code>.
(-)Eclipse UI/org/eclipse/ui/internal/handlers/HandlerPersistence.java (-11 / +98 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
					 * Handlers will need to be re-read (i.e., re-verified) if
274
					 * any of the handler extensions change (i.e., handlers,
275
					 * commands), or if any of the command extensions change
276
					 * (i.e., action definitions).
277
					 */
278
					final IExtensionDelta[] handlerDeltas = event
279
							.getExtensionDeltas(PlatformUI.PLUGIN_ID,
280
									IWorkbenchConstants.PL_HANDLERS);
281
					if (handlerDeltas.length == 0) {
282
						final IExtensionDelta[] commandDeltas = event
283
								.getExtensionDeltas(PlatformUI.PLUGIN_ID,
284
										IWorkbenchConstants.PL_COMMANDS);
285
						if (commandDeltas.length == 0) {
286
							final IExtensionDelta[] actionDefinitionDeltas = event
287
									.getExtensionDeltas(
288
											PlatformUI.PLUGIN_ID,
289
											IWorkbenchConstants.PL_ACTION_DEFINITIONS);
290
							if (actionDefinitionDeltas.length == 0) {
291
								return;
292
							}
293
						}
294
					}
295
296
					/*
297
					 * At least one of the deltas is non-zero, so re-read all of
298
					 * the bindings.
299
					 */
300
					Display.getDefault().asyncExec(new Runnable() {
301
						public void run() {
302
							read(handlerService);
303
						}
304
					});
305
				}
306
			}, PlatformUI.PLUGIN_ID);
307
308
			listenersAttached = true;
309
		}
226
	}
310
	}
227
311
228
	/**
312
	/**
Lines 260-267 Link Here
260
				continue;
344
				continue;
261
			}
345
			}
262
346
263
			handlerService.activateHandler(commandId, new HandlerProxy(
347
			handlerActivations.add(handlerService.activateHandler(commandId,
264
					configurationElement, ATTRIBUTE_DEFAULT_HANDLER));
348
					new HandlerProxy(configurationElement,
349
							ATTRIBUTE_DEFAULT_HANDLER)));
265
		}
350
		}
266
	}
351
	}
267
352
Lines 412-429 Link Here
412
			}
497
			}
413
498
414
			if (activeWhenExpression != null) {
499
			if (activeWhenExpression != null) {
415
				handlerService
500
				handlerActivations.add(handlerService
416
						.activateHandler(commandId, new HandlerProxy(
501
						.activateHandler(commandId, new HandlerProxy(
417
								configurationElement, ATTRIBUTE_CLASS,
502
								configurationElement, ATTRIBUTE_CLASS,
418
								enabledWhenExpression, handlerService),
503
								enabledWhenExpression, handlerService),
419
								activeWhenExpression, ISources.ACTIVE_CONTEXT
504
								activeWhenExpression, ISources.ACTIVE_CONTEXT
420
										| ISources.ACTIVE_CURRENT_SELECTION
505
										| ISources.ACTIVE_CURRENT_SELECTION
421
										| ISources.ACTIVE_EDITOR
506
										| ISources.ACTIVE_EDITOR
422
										| ISources.ACTIVE_PART);
507
										| ISources.ACTIVE_PART));
423
			} else {
508
			} else {
424
				handlerService.activateHandler(commandId, new HandlerProxy(
509
				handlerActivations.add(handlerService.activateHandler(
425
						configurationElement, ATTRIBUTE_CLASS,
510
						commandId, new HandlerProxy(configurationElement,
426
						enabledWhenExpression, handlerService));
511
								ATTRIBUTE_CLASS, enabledWhenExpression,
512
								handlerService)));
427
			}
513
			}
428
		}
514
		}
429
515
Lines 480-487 Link Here
480
				continue;
566
				continue;
481
			}
567
			}
482
568
483
			handlerService.activateHandler(commandId, new LegacyHandlerWrapper(
569
			handlerActivations.add(handlerService.activateHandler(commandId,
484
					new LegacyHandlerProxy(configurationElement)));
570
					new LegacyHandlerWrapper(new LegacyHandlerProxy(
571
							configurationElement))));
485
		}
572
		}
486
573
487
		// If there were any warnings, then log them now.
574
		// If there were any warnings, then log them now.
(-)Eclipse UI/org/eclipse/ui/internal/keys/BindingPersistence.java (-22 / +101 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
					 * Bindings will need to be re-read (i.e., re-verified) if
672
					 * any of the binding extensions change (i.e., accelerator
673
					 * configurations, bindings, commands), or if any of the
674
					 * command or context extensions change (i.e., accelerator
675
					 * scopes, contexts, action definitions).
676
					 */
677
					final IExtensionDelta[] acceleratorConfigurationDeltas = event
678
							.getExtensionDeltas(
679
									PlatformUI.PLUGIN_ID,
680
									IWorkbenchConstants.PL_ACCELERATOR_CONFIGURATIONS);
681
					if (acceleratorConfigurationDeltas.length == 0) {
682
						final IExtensionDelta[] bindingDeltas = event
683
								.getExtensionDeltas(PlatformUI.PLUGIN_ID,
684
										IWorkbenchConstants.PL_BINDINGS);
685
						if (bindingDeltas.length == 0) {
686
							final IExtensionDelta[] commandDeltas = event
687
									.getExtensionDeltas(PlatformUI.PLUGIN_ID,
688
											IWorkbenchConstants.PL_COMMANDS);
689
							if (commandDeltas.length == 0) {
690
								final IExtensionDelta[] acceleratorScopeDeltas = event
691
										.getExtensionDeltas(
692
												PlatformUI.PLUGIN_ID,
693
												IWorkbenchConstants.PL_ACCELERATOR_SCOPES);
694
								if (acceleratorScopeDeltas.length == 0) {
695
									final IExtensionDelta[] contextDeltas = event
696
											.getExtensionDeltas(
697
													PlatformUI.PLUGIN_ID,
698
													IWorkbenchConstants.PL_CONTEXTS);
699
									if (contextDeltas.length == 0) {
700
										final IExtensionDelta[] actionDefinitionDeltas = event
701
												.getExtensionDeltas(
702
														PlatformUI.PLUGIN_ID,
703
														IWorkbenchConstants.PL_ACTION_DEFINITIONS);
704
										if (actionDefinitionDeltas.length == 0) {
705
											return;
706
										}
707
									}
708
								}
709
							}
710
						}
711
					}
712
713
					/*
714
					 * At least one of the deltas is non-zero, so re-read all of
715
					 * the bindings.
716
					 */
717
					Display.getDefault().asyncExec(new Runnable() {
718
						public void run() {
719
							read(bindingManager, commandService);
720
						}
721
					});
722
				}
723
			}, PlatformUI.PLUGIN_ID);
724
725
			listenersAttached = true;
726
		}
658
    }
727
    }
659
728
660
729
Lines 778-784 Link Here
778
							.getScheme(IBindingService.DEFAULT_DEFAULT_ACTIVE_SCHEME_ID));
847
							.getScheme(IBindingService.DEFAULT_DEFAULT_ACTIVE_SCHEME_ID));
779
		} catch (final NotDefinedException e) {
848
		} catch (final NotDefinedException e) {
780
			// Damn, we're fucked.
849
			// Damn, we're fucked.
781
			throw new Error("You cannot make something from nothing"); //$NON-NLS-1$
850
			throw new Error(
851
					"The default default active scheme id is not defined."); //$NON-NLS-1$
782
		}
852
		}
783
	}
853
	}
784
854
Lines 1365-1370 Link Here
1365
			final IConfigurationElement[] configurationElements,
1435
			final IConfigurationElement[] configurationElements,
1366
			final int configurationElementCount,
1436
			final int configurationElementCount,
1367
			final BindingManager bindingManager) {
1437
			final BindingManager bindingManager) {
1438
		// Undefine all the previous handle objects.
1439
		final HandleObject[] handleObjects = bindingManager
1440
				.getDefinedSchemes();
1441
		if (handleObjects != null) {
1442
			for (int i = 0; i < handleObjects.length; i++) {
1443
				handleObjects[i].undefine();
1444
			}
1445
		}
1446
		
1368
		for (int i = 0; i < configurationElementCount; i++) {
1447
		for (int i = 0; i < configurationElementCount; i++) {
1369
			final IConfigurationElement configurationElement = configurationElements[i];
1448
			final IConfigurationElement configurationElement = configurationElements[i];
1370
1449

Return to bug 96600