Search in sources :

Example 26 with IHandlerService

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

the class EventProcessingPolicyEditor method createActions.

/**
 * Create actions
 */
private void createActions() {
    final IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class);
    actionHorizontal = new Action(Messages.get().EventProcessingPolicyEditor_LayoutH, Action.AS_RADIO_BUTTON) {

        @Override
        public void run() {
            verticalLayout = false;
            updateLayout();
        }
    };
    actionHorizontal.setChecked(!verticalLayout);
    // $NON-NLS-1$
    actionHorizontal.setImageDescriptor(Activator.getImageDescriptor("icons/h_layout.gif"));
    actionVertical = new Action(Messages.get().EventProcessingPolicyEditor_LayoutV, Action.AS_RADIO_BUTTON) {

        @Override
        public void run() {
            verticalLayout = true;
            updateLayout();
        }
    };
    actionVertical.setChecked(verticalLayout);
    // $NON-NLS-1$
    actionVertical.setImageDescriptor(Activator.getImageDescriptor("icons/v_layout.gif"));
    actionSave = new Action(Messages.get().EventProcessingPolicyEditor_Save) {

        @Override
        public void run() {
            savePolicy();
        }
    };
    actionSave.setImageDescriptor(SharedIcons.SAVE);
    actionSave.setEnabled(false);
    actionCollapseAll = new Action(Messages.get().EventProcessingPolicyEditor_CollapseAll) {

        @Override
        public void run() {
            setAllRulesCollapsed(true);
        }
    };
    actionCollapseAll.setImageDescriptor(SharedIcons.COLLAPSE_ALL);
    actionExpandAll = new Action(Messages.get().EventProcessingPolicyEditor_ExpandAll) {

        @Override
        public void run() {
            setAllRulesCollapsed(false);
        }
    };
    actionExpandAll.setImageDescriptor(SharedIcons.EXPAND_ALL);
    actionDelete = new Action(Messages.get().EventProcessingPolicyEditor_Delete) {

        @Override
        public void run() {
            deleteSelectedRules();
        }
    };
    actionDelete.setImageDescriptor(SharedIcons.DELETE_OBJECT);
    actionDelete.setEnabled(false);
    actionInsertBefore = new Action(Messages.get().EventProcessingPolicyEditor_InsertBefore) {

        @Override
        public void run() {
            insertRule(lastSelectedRule - 1);
        }
    };
    actionInsertAfter = new Action(Messages.get().EventProcessingPolicyEditor_InsertAfter) {

        @Override
        public void run() {
            insertRule(lastSelectedRule);
        }
    };
    actionCut = new Action(Messages.get().EventProcessingPolicyEditor_Cut) {

        @Override
        public void run() {
            cutRules();
        }
    };
    actionCut.setImageDescriptor(SharedIcons.CUT);
    actionCut.setEnabled(false);
    actionCopy = new Action(Messages.get().EventProcessingPolicyEditor_Copy) {

        @Override
        public void run() {
            copyRules();
        }
    };
    actionCopy.setImageDescriptor(SharedIcons.COPY);
    actionCopy.setEnabled(false);
    actionPaste = new Action(Messages.get().EventProcessingPolicyEditor_Paste) {

        @Override
        public void run() {
            pasteRules();
        }
    };
    actionPaste.setImageDescriptor(SharedIcons.PASTE);
    actionPaste.setEnabled(false);
    actionEnableRule = new Action(Messages.get().EventProcessingPolicyEditor_Enable) {

        @Override
        public void run() {
            enableRules(true);
        }
    };
    actionDisableRule = new Action(Messages.get().EventProcessingPolicyEditor_Disable) {

        @Override
        public void run() {
            enableRules(false);
        }
    };
    actionShowFilter = new Action(Messages.get().EventProcessingPolicyEditor_ShowFilter, Action.AS_CHECK_BOX) {

        @Override
        public void run() {
            enableFilter(actionShowFilter.isChecked());
        }
    };
    actionAddRule = new Action("&Add new rule") {

        @Override
        public void run() {
            insertRule(ruleEditors.size());
        }
    };
    actionAddRule.setImageDescriptor(SharedIcons.ADD_OBJECT);
    actionShowFilter.setChecked(filterEnabled);
    // $NON-NLS-1$
    actionShowFilter.setActionDefinitionId("org.netxms.ui.eclipse.epp.commands.show_rule_filter");
    final ActionHandler showFilterHandler = new ActionHandler(actionShowFilter);
    handlerService.activateHandler(actionShowFilter.getActionDefinitionId(), showFilterHandler);
}
Also used : ServerAction(org.netxms.client.ServerAction) Action(org.eclipse.jface.action.Action) IHandlerService(org.eclipse.ui.handlers.IHandlerService) ActionHandler(org.eclipse.jface.commands.ActionHandler)

Example 27 with IHandlerService

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

the class LastValues method createActions.

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

        @Override
        public void run() {
            dataView.refresh();
        }
    };
    actionAutoUpdate = new Action(Messages.get().LastValues_AutoRefresh, Action.AS_CHECK_BOX) {

        @Override
        public void run() {
            dataView.setAutoRefreshEnabled(actionAutoUpdate.isChecked());
        }
    };
    actionAutoUpdate.setChecked(dataView.isAutoRefreshEnabled());
    actionShowFilter = new Action(Messages.get().LastValues_ShowFilter, Action.AS_CHECK_BOX) {

        @Override
        public void run() {
            dataView.enableFilter(!dataView.isFilterEnabled());
            actionShowFilter.setChecked(dataView.isFilterEnabled());
        }
    };
    actionShowFilter.setImageDescriptor(SharedIcons.FILTER);
    actionShowFilter.setChecked(initShowFilter);
    // $NON-NLS-1$
    actionShowFilter.setActionDefinitionId("org.netxms.ui.eclipse.datacollection.commands.show_dci_filter");
    handlerService.activateHandler(actionShowFilter.getActionDefinitionId(), new ActionHandler(actionShowFilter));
}
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)

Example 28 with IHandlerService

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

the class SummaryTableManager method createActions.

/**
 */
private void createActions() {
    final IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class);
    // create show filter action
    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.datacollection.commands.show_dci_filter");
    handlerService.activateHandler(actionShowFilter.getActionDefinitionId(), new ActionHandler(actionShowFilter));
    // create refresh action
    actionRefresh = new RefreshAction(this) {

        @Override
        public void run() {
            refresh();
        }
    };
    // create add action for single value table
    actionCreateSingleValue = new Action("Create new summary table...", SharedIcons.ADD_OBJECT) {

        @Override
        public void run() {
            createSummaryTable(false);
        }
    };
    actionCreateTableValue = new Action("Create new summary table for table DCIs...", Activator.getImageDescriptor("icons/new.png")) {

        @Override
        public void run() {
            createSummaryTable(true);
        }
    };
    // create edit action
    actionEdit = new Action(Messages.get().SummaryTableManager_ActionEdit, SharedIcons.EDIT) {

        @Override
        public void run() {
            editSummaryTable();
        }
    };
    actionEdit.setEnabled(false);
    // create delete action
    actionDelete = new Action(Messages.get().SummaryTableManager_ActionDelete, SharedIcons.DELETE_OBJECT) {

        @Override
        public void run() {
            deleteSelection();
        }
    };
    actionDelete.setEnabled(false);
}
Also used : 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) ActionHandler(org.eclipse.jface.commands.ActionHandler)

Example 29 with IHandlerService

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

the class DataCollectionEditor method createActions.

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

        @Override
        public void run() {
            viewer.setInput(dciConfig.getItems());
        }
    };
    actionCreateItem = new // $NON-NLS-1$
    Action(// $NON-NLS-1$
    Messages.get().DataCollectionEditor_NewParam, // $NON-NLS-1$
    Activator.getImageDescriptor("icons/new.png")) {

        @Override
        public void run() {
            createItem();
        }
    };
    actionCreateTable = new Action(Messages.get().DataCollectionEditor_NewTable) {

        @Override
        public void run() {
            createTable();
        }
    };
    actionEdit = new Action(Messages.get().DataCollectionEditor_ActionEdit, SharedIcons.EDIT) {

        @Override
        public void run() {
            editSelectedObject();
        }
    };
    actionEdit.setText(Messages.get().DataCollectionEditor_Edit);
    // $NON-NLS-1$
    actionEdit.setImageDescriptor(Activator.getImageDescriptor("icons/edit.png"));
    actionEdit.setEnabled(false);
    actionDelete = new // $NON-NLS-1$
    Action(// $NON-NLS-1$
    Messages.get().DataCollectionEditor_Delete, // $NON-NLS-1$
    Activator.getImageDescriptor("icons/delete.png")) {

        @Override
        public void run() {
            deleteItems();
        }
    };
    actionDelete.setEnabled(false);
    actionCopy = new Action(Messages.get().DataCollectionEditor_Copy) {

        @Override
        public void run() {
            copyItems(false);
        }
    };
    actionCopy.setEnabled(false);
    actionMove = new Action(Messages.get().DataCollectionEditor_Move) {

        @Override
        public void run() {
            copyItems(true);
        }
    };
    actionMove.setEnabled(false);
    actionConvert = new Action(Messages.get().DataCollectionEditor_Convert) {

        @Override
        public void run() {
            convertToTemplate();
        }
    };
    actionConvert.setEnabled(false);
    actionDuplicate = new Action(Messages.get().DataCollectionEditor_Duplicate) {

        @Override
        public void run() {
            duplicateItems();
        }
    };
    actionDuplicate.setEnabled(false);
    actionActivate = new // $NON-NLS-1$
    Action(// $NON-NLS-1$
    Messages.get().DataCollectionEditor_Activate, // $NON-NLS-1$
    Activator.getImageDescriptor("icons/active.gif")) {

        @Override
        public void run() {
            setItemStatus(DataCollectionObject.ACTIVE);
            actionActivate.setEnabled(false);
            actionDisable.setEnabled(true);
        }
    };
    actionActivate.setEnabled(false);
    actionDisable = new // $NON-NLS-1$
    Action(// $NON-NLS-1$
    Messages.get().DataCollectionEditor_Disable, // $NON-NLS-1$
    Activator.getImageDescriptor("icons/disabled.gif")) {

        @Override
        public void run() {
            setItemStatus(DataCollectionObject.DISABLED);
            actionActivate.setEnabled(true);
            actionDisable.setEnabled(false);
        }
    };
    actionDisable.setEnabled(false);
    actionShowFilter = new Action(Messages.get().DataCollectionEditor_ShowFilter, Action.AS_CHECK_BOX) {

        @Override
        public void run() {
            enableFilter(actionShowFilter.isChecked());
        }
    };
    actionShowFilter.setImageDescriptor(SharedIcons.FILTER);
    actionShowFilter.setChecked(getBooleanFromSettings("DataCollectionEditor.showFilter", true));
    // $NON-NLS-1$
    actionShowFilter.setActionDefinitionId("org.netxms.ui.eclipse.datacollection.commands.show_dci_filter");
    handlerService.activateHandler(actionShowFilter.getActionDefinitionId(), new ActionHandler(actionShowFilter));
    actionExportToCsv = new ExportToCsvAction(this, viewer, true);
    actionExportAllToCsv = new ExportToCsvAction(this, viewer, false);
}
Also used : 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) ActionHandler(org.eclipse.jface.commands.ActionHandler) ExportToCsvAction(org.netxms.ui.eclipse.actions.ExportToCsvAction)

Example 30 with IHandlerService

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

the class AbstractTraceView method createActions.

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

        @Override
        public void run() {
            traceWidget.clear();
        }
    };
    actionShowFilter = new Action("Show &filter", Action.AS_CHECK_BOX) {

        @Override
        public void run() {
            traceWidget.enableFilter(!traceWidget.isFilterEnabled());
            actionShowFilter.setChecked(traceWidget.isFilterEnabled());
        }
    };
    actionShowFilter.setImageDescriptor(SharedIcons.FILTER);
    actionShowFilter.setChecked(initShowFilter);
    actionShowFilter.setId("org.netxms.ui.eclipse.library.actions.showSnmpFilter");
    actionShowFilter.setActionDefinitionId("org.netxms.ui.eclipse.library.commands.show_filter");
    final ActionHandler showFilterHandler = new ActionHandler(actionShowFilter);
    handlerService.activateHandler(actionShowFilter.getActionDefinitionId(), showFilterHandler);
}
Also used : Action(org.eclipse.jface.action.Action) IHandlerService(org.eclipse.ui.handlers.IHandlerService) ActionHandler(org.eclipse.jface.commands.ActionHandler)

Aggregations

IHandlerService (org.eclipse.ui.handlers.IHandlerService)107 ActionHandler (org.eclipse.jface.commands.ActionHandler)45 Action (org.eclipse.jface.action.Action)41 RefreshAction (org.netxms.ui.eclipse.actions.RefreshAction)25 IEvaluationContext (org.eclipse.core.expressions.IEvaluationContext)19 Command (org.eclipse.core.commands.Command)18 ICommandService (org.eclipse.ui.commands.ICommandService)18 ExecutionEvent (org.eclipse.core.commands.ExecutionEvent)16 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)15 AbstractHandler (org.eclipse.core.commands.AbstractHandler)11 ParameterizedCommand (org.eclipse.core.commands.ParameterizedCommand)10 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)10 SelectionEvent (org.eclipse.swt.events.SelectionEvent)10 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)10 EvaluationContext (org.eclipse.core.expressions.EvaluationContext)9 IHandler (org.eclipse.core.commands.IHandler)8 IAction (org.eclipse.jface.action.IAction)8 GridLayout (org.eclipse.swt.layout.GridLayout)8 IContextService (org.eclipse.ui.contexts.IContextService)8 ArrayList (java.util.ArrayList)7