|
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. |