import java.util.TreeSet;
import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.NotEnabledException;
+import org.eclipse.core.commands.NotHandledException;
+import org.eclipse.core.commands.common.NotDefinedException;
import org.eclipse.core.commands.operations.IOperationHistory;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.ide.undo.WorkspaceUndoUtil;
import org.eclipse.ui.part.EditorPart;
import org.eclipse.ui.progress.IProgressService;
}
+ public static void executeCommand(String commandId, Object source, String pluginId) {
+ IHandlerService handlerService = (IHandlerService) AbstractUtility.getService(IHandlerService.class);
+ Exception exception = null;
+ try {
+ handlerService.executeCommand(commandId, null);
+ } catch (ExecutionException e) {
+ exception = e;
+ } catch (NotDefinedException e) {
+ exception = e;
+ } catch (NotEnabledException e) {
+ exception = e;
+ } catch (NotHandledException e) {
+ exception = e;
+ } finally {
+ if(exception != null) {
+ MessagingUtils.errorDialog("Error executing command",
+ source,
+ "Could not execute command with id " + commandId ,
+ pluginId,
+ exception,
+ true);
+ }
+ }
+ }
}