Bug 369159 - [Compatibility] ICommandService/IExecutionListener not
fired
These changes were done without API changes in core.commands.
They should be the same in 3.8 and 4.2
diff --git a/bundles/org.eclipse.core.commands/META-INF/MANIFEST.MF b/bundles/org.eclipse.core.commands/META-INF/MANIFEST.MF
index 209dfa9..bc9e490 100644
--- a/bundles/org.eclipse.core.commands/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.core.commands/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.core.commands
-Bundle-Version: 3.6.0.qualifier
+Bundle-Version: 3.6.1.qualifier
Bundle-ClassPath: .
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/Command.java b/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/Command.java
index f3f25a4..f92dcb2 100644
--- a/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/Command.java
+++ b/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/Command.java
@@ -83,6 +83,8 @@
* collection is <code>null</code> if there are no listeners.
*/
private transient ListenerList executionListeners = null;
+
+ boolean shouldFireEvents = true;
/**
* The handler currently associated with this command. This value may be
@@ -403,24 +405,32 @@
*/
public final Object execute(final ExecutionEvent event)
throws ExecutionException, NotHandledException {
- firePreExecute(event);
+ if (shouldFireEvents) {
+ firePreExecute(event);
+ }
final IHandler handler = this.handler;
// Perform the execution, if there is a handler.
if ((handler != null) && (handler.isHandled())) {
try {
final Object returnValue = handler.execute(event);
- firePostExecuteSuccess(returnValue);
+ if (shouldFireEvents) {
+ firePostExecuteSuccess(returnValue);
+ }
return returnValue;
} catch (final ExecutionException e) {
- firePostExecuteFailure(e);
+ if (shouldFireEvents) {
+ firePostExecuteFailure(e);
+ }
throw e;
}
}
final NotHandledException e = new NotHandledException(
"There is no handler to execute. " + getId()); //$NON-NLS-1$
- fireNotHandled(e);
+ if (shouldFireEvents) {
+ fireNotHandled(e);
+ }
throw e;
}
@@ -451,14 +461,24 @@
public final Object executeWithChecks(final ExecutionEvent event)
throws ExecutionException, NotDefinedException,
NotEnabledException, NotHandledException {
- firePreExecute(event);
+ if (shouldFireEvents) {
+ firePreExecute(event);
+ }
final IHandler handler = this.handler;
+ // workaround for the division of responsibilities to get
+ // bug 369159 working
+ if ("org.eclipse.ui.internal.MakeHandlersGo".equals(handler.getClass() //$NON-NLS-1$
+ .getName())) {
+ return handler.execute(event);
+ }
if (!isDefined()) {
final NotDefinedException exception = new NotDefinedException(
"Trying to execute a command that is not defined. " //$NON-NLS-1$
+ getId());
- fireNotDefined(exception);
+ if (shouldFireEvents) {
+ fireNotDefined(exception);
+ }
throw exception;
}
@@ -468,23 +488,31 @@
if (!isEnabled()) {
final NotEnabledException exception = new NotEnabledException(
"Trying to execute the disabled command " + getId()); //$NON-NLS-1$
- fireNotEnabled(exception);
+ if (shouldFireEvents) {
+ fireNotEnabled(exception);
+ }
throw exception;
}
try {
final Object returnValue = handler.execute(event);
- firePostExecuteSuccess(returnValue);
+ if (shouldFireEvents) {
+ firePostExecuteSuccess(returnValue);
+ }
return returnValue;
} catch (final ExecutionException e) {
- firePostExecuteFailure(e);
+ if (shouldFireEvents) {
+ firePostExecuteFailure(e);
+ }
throw e;
}
}
final NotHandledException e = new NotHandledException(
"There is no handler to execute for command " + getId()); //$NON-NLS-1$
- fireNotHandled(e);
+ if (shouldFireEvents) {
+ fireNotHandled(e);
+ }
throw e;
}
diff --git a/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/CommandManager.java b/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/CommandManager.java
index 1fa61a8..5316c4b 100644
--- a/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/CommandManager.java
+++ b/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/CommandManager.java
@@ -260,6 +260,8 @@
* manager.
*/
private IExecutionListenerWithChecks executionListener = null;
+
+ private boolean shouldCommandFireEvents = true;
/**
* The collection of execution listeners. This collection is
@@ -546,6 +548,7 @@
Command command = (Command) handleObjectsById.get(commandId);
if (command == null) {
command = new Command(commandId);
+ command.shouldFireEvents = shouldCommandFireEvents;
handleObjectsById.put(commandId, command);
command.addCommandListener(this);