Search in sources :

Example 31 with IHandlerService

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

the class ScriptingConsole method createActions.

/**
 * Create actions
 */
private void createActions() {
    final IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class);
    actionClear = new Action("C&lear console", SharedIcons.CLEAR_LOG) {

        @Override
        public void run() {
            console.clearConsole();
        }
    };
    actionScrollLock = new Action("&Scroll lock", Action.AS_CHECK_BOX) {

        @Override
        public void run() {
        }
    };
    // $NON-NLS-1$
    actionScrollLock.setImageDescriptor(Activator.getImageDescriptor("icons/scroll_lock.gif"));
    actionScrollLock.setChecked(false);
    actionTerminate = new Action("&Terminate", SharedIcons.TERMINATE) {

        @Override
        public void run() {
            synchronized (mutex) {
                if (running) {
                }
            }
        }
    };
    actionTerminate.setEnabled(false);
    actionTerminate.setActionDefinitionId("org.netxms.ui.eclipse.scripting.commands.terminate_process");
    handlerService.activateHandler(actionTerminate.getActionDefinitionId(), new ActionHandler(actionTerminate));
    actionCopy = new Action("&Copy") {

        @Override
        public void run() {
            if (viewer.canDoOperation(TextConsoleViewer.COPY))
                viewer.doOperation(TextConsoleViewer.COPY);
        }
    };
    actionCopy.setEnabled(false);
    actionCopy.setActionDefinitionId("org.netxms.ui.eclipse.scripting.commands.copy");
    handlerService.activateHandler(actionCopy.getActionDefinitionId(), new ActionHandler(actionCopy));
    actionSelectAll = new Action("Select &all") {

        @Override
        public void run() {
            if (viewer.canDoOperation(TextConsoleViewer.SELECT_ALL))
                viewer.doOperation(TextConsoleViewer.SELECT_ALL);
        }
    };
    actionSelectAll.setActionDefinitionId("org.netxms.ui.eclipse.scripting.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 32 with IHandlerService

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

the class AgentFileManager method createActions.

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

        @Override
        public void run() {
            refreshFileOrDirectory();
        }
    };
    // $NON-NLS-1$
    actionRefreshDirectory.setActionDefinitionId("org.netxms.ui.eclipse.filemanager.commands.refreshFolder");
    handlerService.activateHandler(actionRefreshDirectory.getActionDefinitionId(), new ActionHandler(actionRefreshDirectory));
    actionRefreshAll = new RefreshAction(this) {

        @Override
        public void run() {
            refreshFileList();
        }
    };
    actionUploadFile = new Action(Messages.get().AgentFileManager_UploadFile) {

        @Override
        public void run() {
            uploadFile(false);
        }
    };
    // $NON-NLS-1$
    actionUploadFile.setActionDefinitionId("org.netxms.ui.eclipse.filemanager.commands.uploadFile");
    handlerService.activateHandler(actionUploadFile.getActionDefinitionId(), new ActionHandler(actionUploadFile));
    actionDelete = new Action(Messages.get().AgentFileManager_Delete, SharedIcons.DELETE_OBJECT) {

        @Override
        public void run() {
            deleteFile();
        }
    };
    // $NON-NLS-1$
    actionDelete.setActionDefinitionId("org.netxms.ui.eclipse.filemanager.commands.delete");
    handlerService.activateHandler(actionDelete.getActionDefinitionId(), new ActionHandler(actionDelete));
    actionRename = new Action(Messages.get().AgentFileManager_Rename) {

        @Override
        public void run() {
            renameFile();
        }
    };
    // $NON-NLS-1$
    actionRename.setActionDefinitionId("org.netxms.ui.eclipse.filemanager.commands.rename");
    handlerService.activateHandler(actionRename.getActionDefinitionId(), new ActionHandler(actionRename));
    actionShowFilter = new Action(Messages.get().ViewServerFile_ShowFilterAction, 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.filemanager.commands.showFilter");
    handlerService.activateHandler(actionShowFilter.getActionDefinitionId(), new ActionHandler(actionShowFilter));
    actionDownloadFile = new Action(Messages.get().AgentFileManager_Download) {

        @Override
        public void run() {
            startDownload();
        }
    };
    // $NON-NLS-1$
    actionDownloadFile.setActionDefinitionId("org.netxms.ui.eclipse.filemanager.commands.download");
    handlerService.activateHandler(actionDownloadFile.getActionDefinitionId(), new ActionHandler(actionDownloadFile));
    actionTailFile = new Action(Messages.get().AgentFileManager_FollowChanges) {

        @Override
        public void run() {
            tailFile(true, 1024);
        }
    };
    actionShowFile = new Action(Messages.get().AgentFileManager_Show) {

        @Override
        public void run() {
            tailFile(false, 0);
        }
    };
    actionCreateDirectory = new Action(Messages.get().AgentFileManager_CreateFolder) {

        @Override
        public void run() {
            createFolder();
        }
    };
    // $NON-NLS-1$
    actionCreateDirectory.setActionDefinitionId("org.netxms.ui.eclipse.filemanager.commands.newFolder");
    handlerService.activateHandler(actionCreateDirectory.getActionDefinitionId(), new ActionHandler(actionCreateDirectory));
    actionCalculateFolderSize = new Action("Calculate folder &size") {

        @Override
        public void run() {
            calculateFolderSize();
        }
    };
    // $NON-NLS-1$
    actionCalculateFolderSize.setActionDefinitionId("org.netxms.ui.eclipse.filemanager.commands.calculateFolderSize");
    handlerService.activateHandler(actionCalculateFolderSize.getActionDefinitionId(), new ActionHandler(actionCalculateFolderSize));
    actionCopyFileName = new Action("Copy file &name") {

        @Override
        public void run() {
            copyFileName();
        }
    };
    // $NON-NLS-1$
    actionCopyFileName.setActionDefinitionId("org.netxms.ui.eclipse.filemanager.commands.copyFileName");
    handlerService.activateHandler(actionCopyFileName.getActionDefinitionId(), new ActionHandler(actionCopyFileName));
    actionCopyFilePath = new Action("Copy file &path") {

        @Override
        public void run() {
            copyFilePath();
        }
    };
    // $NON-NLS-1$
    actionCopyFilePath.setActionDefinitionId("org.netxms.ui.eclipse.filemanager.commands.copyFilePath");
    handlerService.activateHandler(actionCopyFilePath.getActionDefinitionId(), new ActionHandler(actionCopyFilePath));
}
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 33 with IHandlerService

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

the class ServerFileManager method createActions.

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

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

        @Override
        public void run() {
            createFile();
        }
    };
    actionNew.setImageDescriptor(SharedIcons.ADD_OBJECT);
    actionDelete = new Action(Messages.get().ViewServerFile_DeleteFileOnServerAction) {

        @Override
        public void run() {
            deleteFile();
        }
    };
    actionDelete.setImageDescriptor(SharedIcons.DELETE_OBJECT);
    actionShowFilter = new Action(Messages.get().ViewServerFile_ShowFilterAction, Action.AS_CHECK_BOX) {

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

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

the class LogViewer method createActions.

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

        @Override
        public void run() {
            refreshData();
        }
    };
    actionRefresh.setEnabled(false);
    actionExecute = new Action(Messages.get().LogViewer_ActionExec, SharedIcons.EXECUTE) {

        @Override
        public void run() {
            doQuery();
        }
    };
    // $NON-NLS-1$
    actionExecute.setActionDefinitionId("org.netxms.ui.eclipse.logviewer.commands.execute");
    handlerService.activateHandler(actionExecute.getActionDefinitionId(), new ActionHandler(actionExecute));
    actionClearFilter = new Action(Messages.get().LogViewer_ActionClearFilter, SharedIcons.CLEAR_LOG) {

        @Override
        public void run() {
            filterBuilder.clearFilter();
        }
    };
    actionGetMoreData = new // $NON-NLS-1$
    Action(// $NON-NLS-1$
    Messages.get().LogViewer_ActionGetMoreData, // $NON-NLS-1$
    Activator.getImageDescriptor("icons/get_more_data.png")) {

        @Override
        public void run() {
            getMoreData();
        }
    };
    actionGetMoreData.setEnabled(false);
    // $NON-NLS-1$
    actionGetMoreData.setActionDefinitionId("org.netxms.ui.eclipse.logviewer.commands.get_more_data");
    handlerService.activateHandler(actionGetMoreData.getActionDefinitionId(), new ActionHandler(actionGetMoreData));
    actionShowFilter = new Action(Messages.get().LogViewer_ActionShowFilter, Action.AS_CHECK_BOX) {

        @Override
        public void run() {
            showFilter(actionShowFilter.isChecked());
        }
    };
    actionShowFilter.setChecked(true);
    // $NON-NLS-1$
    actionShowFilter.setActionDefinitionId("org.netxms.ui.eclipse.logviewer.commands.show_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 35 with IHandlerService

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

the class ScriptExecutor method createActions.

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

        @Override
        public void run() {
            intermediateSave(false);
        }
    };
    // $NON-NLS-1$
    actionSave.setActionDefinitionId("org.netxms.ui.eclipse.nxsl.commands.save");
    handlerService.activateHandler(actionSave.getActionDefinitionId(), new ActionHandler(actionSave));
    actionSaveAs = new Action(Messages.get().ScriptExecutor_SaveAs, SharedIcons.SAVE_AS) {

        @Override
        public void run() {
            createNewScript(false);
        }
    };
    // $NON-NLS-1$
    actionSaveAs.setActionDefinitionId("org.netxms.ui.eclipse.nxsl.commands.save_as");
    handlerService.activateHandler(actionSaveAs.getActionDefinitionId(), new ActionHandler(actionSaveAs));
    actionClear = new Action(Messages.get().ScriptExecutor_Clear, SharedIcons.CLEAR) {

        @Override
        public void run() {
            if (modified) {
                if (saveIfRequired(false))
                    return;
            }
            scriptCombo.deselectAll();
            scriptCombo.clearSelection();
            // $NON-NLS-1$
            scriptEditor.setText("");
            output.clear();
            form.setText(Messages.get().ScriptExecutor_Noname);
        }
    };
    actionClearOutput = new Action(Messages.get().ScriptExecutor_ClearOutput, SharedIcons.CLEAR_LOG) {

        @Override
        public void run() {
            output.clear();
        }
    };
    // $NON-NLS-1$
    actionClearOutput.setActionDefinitionId("org.netxms.ui.eclipse.nxsl.commands.clear_output");
    handlerService.activateHandler(actionClearOutput.getActionDefinitionId(), new ActionHandler(actionClearOutput));
    actionReload = new RefreshAction(this) {

        @Override
        public void run() {
            if (modified) {
                if (saveIfRequired(false))
                    return;
            }
            updateScriptList(null);
            getScriptContent();
            output.clear();
        }
    };
    actionReload.setText(Messages.get().ScriptExecutor_Reload);
    actionExecute = new Action(Messages.get().ScriptExecutor_Execute, SharedIcons.EXECUTE) {

        @Override
        public void run() {
            executeScript();
        }
    };
    // $NON-NLS-1$
    actionExecute.setActionDefinitionId("org.netxms.ui.eclipse.nxsl.commands.execute_script");
    handlerService.activateHandler(actionExecute.getActionDefinitionId(), new ActionHandler(actionExecute));
}
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)

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