Search in sources :

Example 1 with CommandAction

use of org.eclipse.ui.internal.actions.CommandAction in project netxms by netxms.

the class ApplicationActionBarAdvisor method makeActions.

/* (non-Javadoc)
	 * @see org.eclipse.ui.application.ActionBarAdvisor#makeActions(org.eclipse.ui.IWorkbenchWindow)
	 */
@Override
protected void makeActions(final IWorkbenchWindow window) {
    contribItemShowView = ContributionItemFactory.VIEWS_SHORTLIST.create(window);
    contribItemOpenPerspective = ContributionItemFactory.PERSPECTIVES_SHORTLIST.create(window);
    actionExit = ActionFactory.QUIT.create(window);
    register(actionExit);
    actionAbout = new Action(String.format(Messages.get().ApplicationActionBarAdvisor_AboutActionName, BrandingManager.getInstance().getConsoleProductName())) {

        @Override
        public void run() {
            Dialog dlg = BrandingManager.getInstance().getAboutDialog(window.getShell());
            if (dlg != null) {
                dlg.open();
            } else {
                MessageDialogHelper.openInformation(window.getShell(), Messages.get().ApplicationActionBarAdvisor_AboutTitle, String.format(Messages.get().ApplicationActionBarAdvisor_AboutText, NXCommon.VERSION + " (" + BuildNumber.TEXT + ")"));
            }
        }
    };
    actionShowPreferences = ActionFactory.PREFERENCES.create(window);
    register(actionShowPreferences);
    actionCustomizePerspective = ActionFactory.EDIT_ACTION_SETS.create(window);
    register(actionCustomizePerspective);
    actionSavePerspective = ActionFactory.SAVE_PERSPECTIVE.create(window);
    register(actionSavePerspective);
    actionResetPerspective = ActionFactory.RESET_PERSPECTIVE.create(window);
    register(actionResetPerspective);
    actionClosePerspective = ActionFactory.CLOSE_PERSPECTIVE.create(window);
    register(actionClosePerspective);
    actionCloseAllPerspectives = ActionFactory.CLOSE_ALL_PERSPECTIVES.create(window);
    register(actionCloseAllPerspectives);
    actionMinimize = ActionFactory.MINIMIZE.create(window);
    register(actionMinimize);
    actionMaximize = ActionFactory.MAXIMIZE.create(window);
    register(actionMaximize);
    actionClose = new CommandAction(window, IWorkbenchCommandConstants.WINDOW_CLOSE_PART);
    register(actionClose);
    actionPrevView = ActionFactory.PREVIOUS_PART.create(window);
    register(actionPrevView);
    actionNextView = ActionFactory.NEXT_PART.create(window);
    register(actionNextView);
    actionShowViewMenu = ActionFactory.SHOW_VIEW_MENU.create(window);
    register(actionShowViewMenu);
    actionOpenProgressView = new Action() {

        @Override
        public void run() {
            IWorkbench wb = PlatformUI.getWorkbench();
            if (wb != null) {
                IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
                if (win != null) {
                    IWorkbenchPage page = win.getActivePage();
                    if (page != null) {
                        try {
                            // $NON-NLS-1$
                            page.showView("org.eclipse.ui.views.ProgressView");
                        } catch (PartInitException e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
        }
    };
    actionOpenProgressView.setText(Messages.get().ApplicationActionBarAdvisor_Progress);
    // $NON-NLS-1$
    actionOpenProgressView.setImageDescriptor(Activator.getImageDescriptor("icons/pview.gif"));
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IWorkbenchAction(org.eclipse.ui.actions.ActionFactory.IWorkbenchAction) Action(org.eclipse.jface.action.Action) CommandAction(org.eclipse.ui.internal.actions.CommandAction) Dialog(org.eclipse.jface.dialogs.Dialog) CommandAction(org.eclipse.ui.internal.actions.CommandAction) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException)

Aggregations

Action (org.eclipse.jface.action.Action)1 Dialog (org.eclipse.jface.dialogs.Dialog)1 IWorkbench (org.eclipse.ui.IWorkbench)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1 PartInitException (org.eclipse.ui.PartInitException)1 IWorkbenchAction (org.eclipse.ui.actions.ActionFactory.IWorkbenchAction)1 CommandAction (org.eclipse.ui.internal.actions.CommandAction)1