private void addCustomizeItem(final Menu menu) { final MenuItem customizeMenuItem = new MenuItem(menu, SWT.Activate); customizeMenuItem.setText(WorkbenchMessages.PerspectiveBar_customize); final IWorkbenchWindow workbenchWindow = window.getContext().get(IWorkbenchWindow.class); customizeMenuItem.addSelectionListener(widgetSelectedAdapter(event -> { if (perspSwitcherToolbar.isDisposed()) { return; } IHandlerService handlerService = workbenchWindow.getService(IHandlerService.class); IStatus status = Status.OK_STATUS; try { handlerService.executeCommand(IWorkbenchCommandConstants.WINDOW_CUSTOMIZE_PERSPECTIVE, null); } catch (ExecutionException e) { status = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, e.getMessage(), e); } catch (NotDefinedException e) { status = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, e.getMessage(), e); } catch (NotEnabledException e) { status = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, e.getMessage(), e); } catch (NotHandledException e) { } if (!status.isOK()) { StatusManager.getManager().handle(status, StatusManager.SHOW | StatusManager.LOG); } })); }
} catch (NotEnabledException e) { status = new Status(IStatus.WARNING, PlatformUI.PLUGIN_ID, e .getMessage(), e); } catch (NotHandledException e) { status = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, e
private void addResetItem(final Menu menu) { final MenuItem resetMenuItem = new MenuItem(menu, SWT.Activate); resetMenuItem.setText(WorkbenchMessages.PerspectiveBar_reset); final IWorkbenchWindow workbenchWindow = window.getContext().get(IWorkbenchWindow.class); workbenchWindow.getWorkbench().getHelpSystem().setHelp(resetMenuItem, IWorkbenchHelpContextIds.RESET_PERSPECTIVE_ACTION); resetMenuItem.addSelectionListener(widgetSelectedAdapter(event -> { if (perspSwitcherToolbar.isDisposed()) return; IHandlerService handlerService = workbenchWindow.getService(IHandlerService.class); IStatus status = Status.OK_STATUS; try { handlerService.executeCommand(IWorkbenchCommandConstants.WINDOW_RESET_PERSPECTIVE, null); } catch (ExecutionException e) { status = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, e.getMessage(), e); } catch (NotDefinedException e) { status = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, e.getMessage(), e); } catch (NotEnabledException e) { status = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, e.getMessage(), e); } catch (NotHandledException e) { } if (!status.isOK()) StatusManager.getManager().handle(status, StatusManager.SHOW | StatusManager.LOG); })); }
/** * Run command with specified id * * @param service * @param id * @param event */ public static void executeCommand(IHandlerService service, String id, Event event) { try { service.executeCommand(id, event); } catch (ExecutionException e) { Activator.handleError(e.getMessage(), e, false); } catch (NotDefinedException e) { Activator.handleError(e.getMessage(), e, false); } catch (NotEnabledException e) { Activator.handleError(e.getMessage(), e, false); } catch (NotHandledException e) { Activator.handleError(e.getMessage(), e, false); } }
private void addSaveAsItem(final Menu menu) { final MenuItem saveAsMenuItem = new MenuItem(menu, SWT.Activate); saveAsMenuItem.setText(WorkbenchMessages.PerspectiveBar_saveAs); final IWorkbenchWindow workbenchWindow = window.getContext().get(IWorkbenchWindow.class); workbenchWindow.getWorkbench().getHelpSystem().setHelp(saveAsMenuItem, IWorkbenchHelpContextIds.SAVE_PERSPECTIVE_ACTION); saveAsMenuItem.addSelectionListener(widgetSelectedAdapter(event -> { if (perspSwitcherToolbar.isDisposed()) return; IHandlerService handlerService = workbenchWindow.getService(IHandlerService.class); IStatus status = Status.OK_STATUS; try { handlerService.executeCommand(IWorkbenchCommandConstants.WINDOW_SAVE_PERSPECTIVE_AS, null); } catch (ExecutionException e) { status = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, e.getMessage(), e); } catch (NotDefinedException e) { status = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, e.getMessage(), e); } catch (NotEnabledException e) { status = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, e.getMessage(), e); } catch (NotHandledException e) { } if (!status.isOK()) StatusManager.getManager().handle(status, StatusManager.SHOW | StatusManager.LOG); })); }
public final Object execute(ExecutionEvent event) throws ExecutionException { if (!shouldRunAction()) return null; ICommandService srv = (ICommandService) getServiceLocator() .getService(ICommandService.class); Command command = srv.getCommand(commandId); try { return command.executeWithChecks(event); } catch (ExecutionException e) { Activator.handleError(e.getMessage(), e, true); } catch (NotDefinedException e) { Activator.handleError(e.getMessage(), e, true); } catch (NotEnabledException e) { Activator.handleError(e.getMessage(), e, true); } catch (NotHandledException e) { Activator.handleError(e.getMessage(), e, true); } return null; }