public IWorkbenchAction getGlobalAction(ActionFactory actionFactory) { IWorkbenchAction action = globalActions.get(actionFactory); if (action == null) { IWorkbenchWindow window = getWindow(); action = actionFactory.create(window); if (action != null) { // hopefully action isn't ever null here if (actionFactory == ActionFactory.DYNAMIC_HELP) { action.setImageDescriptor(RcpPlugin.getImageDescriptor("icons/related_help_16_16.gif")); } else if (actionFactory == ActionFactory.SAVE) { action.setImageDescriptor(RcpPlugin.getImageDescriptor("icons/save.png")); action.setDisabledImageDescriptor(RcpPlugin.getImageDescriptor("icons/save-disabled.png")); } else if (actionFactory == ActionFactory.SAVE_ALL) { action.setImageDescriptor(RcpPlugin.getImageDescriptor("icons/save-all.png")); action.setDisabledImageDescriptor(RcpPlugin.getImageDescriptor("icons/save-all-disabled.png")); } else if (actionFactory == ActionFactory.SAVE_AS) { action.setImageDescriptor(RcpPlugin.getImageDescriptor("icons/save-as.png")); action.setDisabledImageDescriptor(RcpPlugin.getImageDescriptor("icons/save-as-disabled.png")); } register(action); globalActions.put(actionFactory, action); } } return action; }
/** * Create the "Help" menu. * * @param window * @return the help MenuManager */ protected IMenuManager createHelpMenu() { IMenuManager menu = new MenuManager(IDEWorkbenchMessages.Workbench_help, IWorkbenchActionConstants.M_HELP); menu.add(new GroupMarker(IWorkbenchActionConstants.HELP_START)); menu.add(new Separator()); menu.add(getGlobalAction(ActionFactory.DYNAMIC_HELP)); menu.add(getGlobalAction(ActionFactory.HELP_CONTENTS)); menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); menu.add(new GroupMarker(IWorkbenchActionConstants.HELP_END)); menu.add(new Separator()); IWorkbenchAction about = getGlobalAction(ActionFactory.ABOUT); ActionContributionItem aboutItem = new ActionContributionItem(about); menu.add(aboutItem); if (Platform.OS_MACOSX.equals(Platform.getOS())) { aboutItem.setVisible(false); } return menu; }
protected void makeActions(IWorkbenchWindow window) { openPerspectiveAction = ActionFactory.OPEN_PERSPECTIVE_DIALOG.create(window); register(openPerspectiveAction); IWorkbenchAction refreshAction=ActionFactory.REFRESH.create(window); register(refreshAction); }
public CutDeleteAction(final DisplayEditor editor, final boolean cut_or_delete) { super(editor, cut_or_delete ? ActionFactory.CUT.getCommandId() : ActionFactory.DELETE.getCommandId()); IWorkbenchAction action = ActionFactory.DELETE.create(PlatformUI.getWorkbench().getActiveWorkbenchWindow()); setText(action.getText()); setImageDescriptor(action.getImageDescriptor()); action = null; }
@Override public void dispose() { for (IWorkbenchAction action : global_actions) action.dispose(); global_actions.clear(); }
private CommandContributionItem createActionFactoryCommandContributionItem(ActionFactory factory) { IWorkbenchWindow window = getWindow(); CommandContributionItemParameter parameter = new CommandContributionItemParameter(window, factory.getId(), factory.getCommandId(), SWT.PUSH); IWorkbenchAction action = factory.create(window); parameter.icon = action.getImageDescriptor(); parameter.disabledIcon = action.getDisabledImageDescriptor(); parameter.label = action.getText(); parameter.tooltip = action.getToolTipText(); window.getPartService().removePartListener((RetargetAction)action); return new CommandContributionItem(parameter); }
/** * Create the "Window" menu. * file/new * @return */ protected IMenuManager createWindowMenu() { IWorkbenchWindow window = getWindow(); MenuManager menu = new MenuManager(IDEWorkbenchMessages.Workbench_window, IWorkbenchActionConstants.M_WINDOW); menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS+"2")); menu.add(new Separator()); MenuManager perspectiveMenu = new MenuManager("Open Perspective", "openPerspective"); IContributionItem perspectiveList = ContributionItemFactory.PERSPECTIVES_SHORTLIST.create(window); perspectiveMenu.add(perspectiveList); menu.add(perspectiveMenu); MenuManager viewMenu = new MenuManager("Show View", "showView"); IContributionItem viewList = ContributionItemFactory.VIEWS_SHORTLIST.create(window); viewMenu.add(viewList); menu.add(viewMenu); menu.add(ActionFactory.RESET_PERSPECTIVE.create(window)); menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); IWorkbenchAction newWindowAction = ActionFactory.OPEN_NEW_WINDOW.create(window); newWindowAction.setText("New Window"); menu.add(newWindowAction); IWorkbenchAction preferences = ActionFactory.PREFERENCES.create(window); String oldText = preferences.getText(); if (!oldText.contains("...")) { preferences.setText(oldText+"..."); } ActionContributionItem preferenceItem = new ActionContributionItem(preferences); menu.add(preferenceItem); if (Platform.OS_MACOSX.equals(Platform.getOS())) { preferenceItem.setVisible(false); } menu.add(ContributionItemFactory.OPEN_WINDOWS.create(window)); return menu; }
private void copyAttributes(IAction actionHandler, ActionFactory actionFactory) { IWorkbenchWindow workbenchWindow = getSite().getWorkbenchWindow(); IWorkbenchAction factoryAction = actionFactory.create(workbenchWindow); // the following two lines are commented out to suppress shortcuts on the context menu // actionHandler.setAccelerator(factoryAction.getAccelerator()); // actionHandler.setActionDefinitionId(factoryAction.getActionDefinitionId()); actionHandler.setDescription(factoryAction.getDescription()); actionHandler.setDisabledImageDescriptor(factoryAction.getDisabledImageDescriptor()); actionHandler.setHoverImageDescriptor(factoryAction.getHoverImageDescriptor()); actionHandler.setId(factoryAction.getId()); actionHandler.setImageDescriptor(factoryAction.getImageDescriptor()); actionHandler.setText(factoryAction.getText()); actionHandler.setToolTipText(factoryAction.getToolTipText()); }
public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); IWorkbenchAction savePerspectiveAction = ActionFactory.SAVE_PERSPECTIVE.create(window); savePerspectiveAction.run(); return null; }
protected IWorkbenchAction makeAction(IWorkbenchWindow window, ActionFactory af) { IWorkbenchAction action = af.create(window); register(action); return action; }
@SuppressWarnings("restriction") public static void addImportWizardSubmenu(IMenuManager menu, IWorkbenchAction action, IWorkbenchWindow workbenchWindow, ISelection selection){ addWizardSubmenu(menu, action, WizardUtils.SUBMENU_IMPORT_WIZARD_CATEGORY, org.eclipse.ui.internal.wizards.ImportWizardRegistry.getInstance(), "Import", workbenchWindow, selection); }
@SuppressWarnings("restriction") public static void addExportWizardSubmenu(IMenuManager menu, IWorkbenchAction action, IWorkbenchWindow workbenchWindow, ISelection selection ){ addWizardSubmenu(menu, action, WizardUtils.SUBMENU_EXPORT_WIZARD_CATEGORY, org.eclipse.ui.internal.wizards.ExportWizardRegistry.getInstance(), "Export", workbenchWindow, selection); }
public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); IWorkbenchAction resetPerspectiveAction = ActionFactory.RESET_PERSPECTIVE.create(window); resetPerspectiveAction.run(); return null; }
/** * Creates and executes and action in the Eclipse UI thread. * * @see Runnable#run() * @see Display#asyncExec(Runnable) * @see #runFactoryAction(ActionFactory) **/ public void run() { IWorkbenchWindow activeWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); IWorkbenchAction action = actionFactory.create(activeWindow); action.run(); }