Search in sources :

Example 86 with IHandlerService

use of org.eclipse.ui.handlers.IHandlerService in project netxms by netxms.

the class AbstractCommandResults method createActions.

/**
 * Create actions
 */
protected void createActions() {
    final IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class);
    actionClear = new Action(Messages.get().LocalCommandResults_ClearConsole, SharedIcons.CLEAR_LOG) {

        @Override
        public void run() {
            console.clear();
        }
    };
    // $NON-NLS-1$
    actionClear.setActionDefinitionId("org.netxms.ui.eclipse.objecttools.commands.clear_output");
    handlerService.activateHandler(actionClear.getActionDefinitionId(), new ActionHandler(actionClear));
    actionScrollLock = new Action(Messages.get().LocalCommandResults_ScrollLock, Action.AS_CHECK_BOX) {

        @Override
        public void run() {
            console.setAutoScroll(!actionScrollLock.isChecked());
        }
    };
    // $NON-NLS-1$
    actionScrollLock.setImageDescriptor(Activator.getImageDescriptor("icons/scroll_lock.gif"));
    actionScrollLock.setChecked(false);
    // $NON-NLS-1$
    actionScrollLock.setActionDefinitionId("org.netxms.ui.eclipse.objecttools.commands.scroll_lock");
    handlerService.activateHandler(actionScrollLock.getActionDefinitionId(), new ActionHandler(actionScrollLock));
    actionCopy = new Action(Messages.get().LocalCommandResults_Copy) {

        @Override
        public void run() {
            console.copy();
        }
    };
    actionCopy.setEnabled(false);
    // $NON-NLS-1$
    actionCopy.setActionDefinitionId("org.netxms.ui.eclipse.objecttools.commands.copy");
    handlerService.activateHandler(actionCopy.getActionDefinitionId(), new ActionHandler(actionCopy));
    actionSelectAll = new Action(Messages.get().LocalCommandResults_SelectAll) {

        @Override
        public void run() {
            console.selectAll();
        }
    };
    // $NON-NLS-1$
    actionSelectAll.setActionDefinitionId("org.netxms.ui.eclipse.objecttools.commands.select_all");
    handlerService.activateHandler(actionSelectAll.getActionDefinitionId(), new ActionHandler(actionSelectAll));
}
Also used : Action(org.eclipse.jface.action.Action) IHandlerService(org.eclipse.ui.handlers.IHandlerService) ActionHandler(org.eclipse.jface.commands.ActionHandler)

Example 87 with IHandlerService

use of org.eclipse.ui.handlers.IHandlerService in project netxms by netxms.

the class NodePollerView method createActions.

/**
 * Create actions
 */
private void createActions() {
    final IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class);
    actionRestart = new Action(Messages.get().NodePollerView_ActionRestart, SharedIcons.RESTART) {

        @Override
        public void run() {
            startPoll();
        }
    };
    // $NON-NLS-1$
    actionRestart.setActionDefinitionId("org.netxms.ui.eclipse.objectmanager.commands.restart_poller");
    handlerService.activateHandler(actionRestart.getActionDefinitionId(), new ActionHandler(actionRestart));
    actionClearOutput = new Action(Messages.get().NodePollerView_ActionClear, SharedIcons.CLEAR_LOG) {

        @Override
        public void run() {
            // $NON-NLS-1$
            textArea.setText("");
        }
    };
    // $NON-NLS-1$
    actionClearOutput.setActionDefinitionId("org.netxms.ui.eclipse.objectmanager.commands.clear_output");
    handlerService.activateHandler(actionClearOutput.getActionDefinitionId(), new ActionHandler(actionClearOutput));
}
Also used : Action(org.eclipse.jface.action.Action) IHandlerService(org.eclipse.ui.handlers.IHandlerService) ActionHandler(org.eclipse.jface.commands.ActionHandler)

Example 88 with IHandlerService

use of org.eclipse.ui.handlers.IHandlerService in project netxms by netxms.

the class ObjectToolsEditor method createActions.

/**
 * Create actions
 */
private void createActions() {
    final IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class);
    actionShowFilter = new Action("Show filter", Action.AS_CHECK_BOX) {

        @Override
        public void run() {
            enableFilter(!initShowFilter);
            actionShowFilter.setChecked(initShowFilter);
        }
    };
    actionShowFilter.setChecked(initShowFilter);
    // $NON-NLS-1$
    actionShowFilter.setActionDefinitionId("org.netxms.ui.eclipse.objecttools.commands.showFilter");
    handlerService.activateHandler(actionShowFilter.getActionDefinitionId(), new ActionHandler(actionShowFilter));
    actionRefresh = new RefreshAction() {

        @Override
        public void run() {
            refreshToolList();
        }
    };
    actionNew = new Action(Messages.get().ObjectToolsEditor_New) {

        @Override
        public void run() {
            createTool();
        }
    };
    actionNew.setImageDescriptor(SharedIcons.ADD_OBJECT);
    actionEdit = new PropertyDialogAction(getSite(), viewer) {

        @Override
        public void run() {
            IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
            if (selection.size() != 1)
                return;
            final long toolId = ((ObjectTool) selection.getFirstElement()).getId();
            // If there will be error, adapter factory will show error message to user
            if (Platform.getAdapterManager().getAdapter(selection.getFirstElement(), ObjectToolDetails.class) == null)
                return;
            super.run();
            ObjectToolDetails details = ObjectToolsAdapterFactory.getDetailsFromCache(toolId);
            if ((details != null) && details.isModified()) {
                saveObjectTool(details);
            }
        }
    };
    actionEdit.setImageDescriptor(SharedIcons.EDIT);
    actionDelete = new Action(Messages.get().ObjectToolsEditor_Delete) {

        @Override
        public void run() {
            deleteTools();
        }
    };
    actionDelete.setImageDescriptor(SharedIcons.DELETE_OBJECT);
    actionDisable = new Action(Messages.get().ObjectToolsEditor_Disable) {

        @Override
        public void run() {
            setSelectedDisabled();
        }
    };
    actionEnable = new Action(Messages.get().ObjectToolsEditor_Enable) {

        @Override
        public void run() {
            setSelectedEnabled();
        }
    };
    actionClone = new Action(Messages.get().ObjectToolsEditor_Clone) {

        @Override
        public void run() {
            cloneTool();
        }
    };
}
Also used : PropertyDialogAction(org.eclipse.ui.dialogs.PropertyDialogAction) RefreshAction(org.netxms.ui.eclipse.actions.RefreshAction) Action(org.eclipse.jface.action.Action) IHandlerService(org.eclipse.ui.handlers.IHandlerService) RefreshAction(org.netxms.ui.eclipse.actions.RefreshAction) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ActionHandler(org.eclipse.jface.commands.ActionHandler) ObjectToolDetails(org.netxms.client.objecttools.ObjectToolDetails) PropertyDialogAction(org.eclipse.ui.dialogs.PropertyDialogAction)

Example 89 with IHandlerService

use of org.eclipse.ui.handlers.IHandlerService in project netxms by netxms.

the class MibExplorer method createActions.

/**
 * Create actions
 */
private void createActions() {
    final IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class);
    actionRefresh = new RefreshAction() {

        @Override
        public void run() {
            mibBrowser.refreshTree();
        }
    };
    actionWalk = new Action(Messages.get().MibExplorer_Walk) {

        @Override
        public void run() {
            doWalk();
        }
    };
    actionWalk.setEnabled(currentNode != null);
    actionSetNode = new Action(Messages.get().MibExplorer_SetNodeObject) {

        @Override
        public void run() {
            ObjectSelectionDialog dlg = new ObjectSelectionDialog(MibExplorer.this.getSite().getShell(), null, ObjectSelectionDialog.createNodeSelectionFilter(false));
            dlg.enableMultiSelection(false);
            if (dlg.open() == Window.OK) {
                setNode((AbstractNode) dlg.getSelectedObjects().get(0));
            }
        }
    };
    actionSelect = new Action("Select in MIB tree") {

        @Override
        public void run() {
            selectInTree();
        }
    };
    actionSelect.setEnabled(false);
    actionExportToCsv = new ExportToCsvAction(this, viewer, true);
    actionShowFilter = new Action("Show filter", Action.AS_CHECK_BOX) {

        @Override
        public void run() {
            enableFilter(!initShowFilter);
            actionShowFilter.setChecked(initShowFilter);
        }
    };
    actionShowFilter.setChecked(initShowFilter);
    // $NON-NLS-1$
    actionShowFilter.setActionDefinitionId("org.netxms.ui.eclipse.snmp.commands.showFilter");
    handlerService.activateHandler(actionShowFilter.getActionDefinitionId(), new ActionHandler(actionShowFilter));
}
Also used : ObjectSelectionDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog) ExportToCsvAction(org.netxms.ui.eclipse.actions.ExportToCsvAction) RefreshAction(org.netxms.ui.eclipse.actions.RefreshAction) Action(org.eclipse.jface.action.Action) IHandlerService(org.eclipse.ui.handlers.IHandlerService) RefreshAction(org.netxms.ui.eclipse.actions.RefreshAction) AbstractNode(org.netxms.client.objects.AbstractNode) ExportToCsvAction(org.netxms.ui.eclipse.actions.ExportToCsvAction) ActionHandler(org.eclipse.jface.commands.ActionHandler)

Example 90 with IHandlerService

use of org.eclipse.ui.handlers.IHandlerService in project netxms by netxms.

the class MappingTableEditor method createActions.

/**
 * Create actions
 */
private void createActions() {
    final IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class);
    actionRefresh = new RefreshAction(this) {

        @Override
        public void run() {
            if (modified)
                if (!MessageDialogHelper.openQuestion(getSite().getShell(), Messages.get().MappingTableEditor_RefreshConfirmation, Messages.get().MappingTableEditor_RefreshConfirmationText))
                    return;
            refresh();
        }
    };
    actionNewRow = new Action(Messages.get().MappingTableEditor_NewRow, SharedIcons.ADD_OBJECT) {

        @Override
        public void run() {
            addNewRow();
        }
    };
    actionNewRow.setEnabled(false);
    // $NON-NLS-1$
    actionNewRow.setActionDefinitionId("org.netxms.ui.eclipse.serverconfig.commands.add_new_row");
    handlerService.activateHandler(actionNewRow.getActionDefinitionId(), new ActionHandler(actionNewRow));
    actionDelete = new Action(Messages.get().MappingTableEditor_Delete, SharedIcons.DELETE_OBJECT) {

        @Override
        public void run() {
            deleteRows();
        }
    };
    actionDelete.setEnabled(false);
    // $NON-NLS-1$
    actionDelete.setActionDefinitionId("org.netxms.ui.eclipse.serverconfig.commands.delete_rows");
    handlerService.activateHandler(actionDelete.getActionDefinitionId(), new ActionHandler(actionDelete));
    actionSave = new Action(Messages.get().MappingTableEditor_Save, SharedIcons.SAVE) {

        @Override
        public void run() {
            new SaveJob().start();
        }
    };
    actionSave.setEnabled(false);
}
Also used : Action(org.eclipse.jface.action.Action) RefreshAction(org.netxms.ui.eclipse.actions.RefreshAction) IHandlerService(org.eclipse.ui.handlers.IHandlerService) RefreshAction(org.netxms.ui.eclipse.actions.RefreshAction) ActionHandler(org.eclipse.jface.commands.ActionHandler)

Aggregations

IHandlerService (org.eclipse.ui.handlers.IHandlerService)102 ActionHandler (org.eclipse.jface.commands.ActionHandler)44 Action (org.eclipse.jface.action.Action)41 RefreshAction (org.netxms.ui.eclipse.actions.RefreshAction)25 IEvaluationContext (org.eclipse.core.expressions.IEvaluationContext)18 Command (org.eclipse.core.commands.Command)17 ICommandService (org.eclipse.ui.commands.ICommandService)17 ExecutionEvent (org.eclipse.core.commands.ExecutionEvent)15 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)14 AbstractHandler (org.eclipse.core.commands.AbstractHandler)10 ParameterizedCommand (org.eclipse.core.commands.ParameterizedCommand)9 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)9 SelectionEvent (org.eclipse.swt.events.SelectionEvent)9 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)9 IHandler (org.eclipse.core.commands.IHandler)8 EvaluationContext (org.eclipse.core.expressions.EvaluationContext)8 ArrayList (java.util.ArrayList)7 ExecutionException (org.eclipse.core.commands.ExecutionException)7 IAction (org.eclipse.jface.action.IAction)7 IContextService (org.eclipse.ui.contexts.IContextService)7