Search in sources :

Example 26 with ActionHandler

use of org.eclipse.jface.commands.ActionHandler in project netxms by netxms.

the class EventObjectList method createActions.

/**
 * Create actions
 */
private void createActions() {
    actionNew = new Action(Messages.get().EventConfigurator_NewEvent, SharedIcons.ADD_OBJECT) {

        @Override
        public void run() {
            createNewEventTemplate();
        }
    };
    // $NON-NLS-1$
    actionNew.setActionDefinitionId("org.netxms.ui.eclipse.eventmanager.commands.new_event_template");
    actionEdit = new // $NON-NLS-1$
    Action(// $NON-NLS-1$
    Messages.get().EventConfigurator_Properties, // $NON-NLS-1$
    SharedIcons.EDIT) {

        @Override
        public void run() {
            editEventTemplate();
        }
    };
    actionEdit.setEnabled(false);
    actionDelete = new Action(Messages.get().EventConfigurator_Delete, SharedIcons.DELETE_OBJECT) {

        @Override
        public void run() {
            deleteEventTemplate();
        }
    };
    actionDelete.setEnabled(false);
    actionShowFilter = new Action(Messages.get().EventConfigurator_ShowFilter, Action.AS_CHECK_BOX) {

        @Override
        public void run() {
            enableFilter(actionShowFilter.isChecked());
        }
    };
    actionRemove = new Action("&Remove from group") {

        @Override
        public void run() {
            removeFromGroup();
        }
    };
    actionShowGroups = new Action("&Show event groups", Action.AS_CHECK_BOX) {

        @Override
        public void run() {
            showEventGroups();
        }
    };
    actionShowGroups.setChecked(showGroups);
    actionNewGroup = new Action("&Add new event group") {

        @Override
        public void run() {
            createNewEventGroup();
        }
    };
    actionShowFilter.setImageDescriptor(SharedIcons.FILTER);
    actionShowFilter.setChecked(filterEnabled);
    // $NON-NLS-1$
    actionShowFilter.setActionDefinitionId("org.netxms.ui.eclipse.eventmanager.commands.show_filter");
    if (viewPart != null) {
        final IHandlerService handlerService = (IHandlerService) viewPart.getSite().getService(IHandlerService.class);
        // $NON-NLS-1$
        actionNew.setActionDefinitionId("org.netxms.ui.eclipse.eventmanager.commands.new_event_template");
        handlerService.activateHandler(actionNew.getActionDefinitionId(), new ActionHandler(actionNew));
        // $NON-NLS-1$
        actionShowFilter.setActionDefinitionId("org.netxms.ui.eclipse.eventmanager.commands.show_filter");
        handlerService.activateHandler(actionShowFilter.getActionDefinitionId(), new ActionHandler(actionShowFilter));
        actionRefresh = new RefreshAction(viewPart) {

            @Override
            public void run() {
                refreshView();
            }
        };
    } else {
        actionRefresh = new RefreshAction() {

            @Override
            public void run() {
                refreshView();
            }
        };
    }
}
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 27 with ActionHandler

use of org.eclipse.jface.commands.ActionHandler in project netxms by netxms.

the class AgentFileViewer method createActions.

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

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

        @Override
        public void run() {
            viewer.setScrollLock(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().AgentFileViewer_Copy) {

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

        @Override
        public void run() {
            viewer.selectAll();
        }
    };
    // $NON-NLS-1$
    actionSelectAll.setActionDefinitionId("org.netxms.ui.eclipse.filemanager.commands.select_all");
    handlerService.activateHandler(actionSelectAll.getActionDefinitionId(), new ActionHandler(actionSelectAll));
    actionFind = new Action(Messages.get().AgentFileViewer_Find, SharedIcons.FIND) {

        @Override
        public void run() {
            viewer.showSearchBar();
        }
    };
    // $NON-NLS-1$
    actionFind.setActionDefinitionId("org.netxms.ui.eclipse.filemanager.commands.find");
    handlerService.activateHandler(actionFind.getActionDefinitionId(), new ActionHandler(actionFind));
}
Also used : Action(org.eclipse.jface.action.Action) IHandlerService(org.eclipse.ui.handlers.IHandlerService) ActionHandler(org.eclipse.jface.commands.ActionHandler)

Example 28 with ActionHandler

use of org.eclipse.jface.commands.ActionHandler in project netxms by netxms.

the class AbstractNetworkMapView method createActions.

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

        @Override
        public void run() {
            refreshMap();
        }
    };
    actionShowLinkDirection = new Action("Show link direction", Action.AS_CHECK_BOX) {

        @Override
        public void run() {
            labelProvider.setShowLinkDirection(!labelProvider.isShowLinkDirection());
            setChecked(labelProvider.isShowLinkDirection());
            updateObjectPositions();
            saveLayout();
            viewer.refresh();
        }
    };
    actionShowLinkDirection.setChecked(labelProvider.isShowLinkDirection());
    actionShowStatusBackground = new Action(Messages.get().AbstractNetworkMapView_ShowStatusBkgnd, Action.AS_CHECK_BOX) {

        @Override
        public void run() {
            labelProvider.setShowStatusBackground(!labelProvider.isShowStatusBackground());
            setChecked(labelProvider.isShowStatusBackground());
            updateObjectPositions();
            saveLayout();
            viewer.refresh();
        }
    };
    actionShowStatusBackground.setChecked(labelProvider.isShowStatusBackground());
    actionShowStatusBackground.setEnabled(labelProvider.getObjectFigureType() == MapObjectDisplayMode.ICON);
    actionShowStatusIcon = new Action(Messages.get().AbstractNetworkMapView_ShowStatusIcon, Action.AS_CHECK_BOX) {

        @Override
        public void run() {
            labelProvider.setShowStatusIcons(!labelProvider.isShowStatusIcons());
            setChecked(labelProvider.isShowStatusIcons());
            updateObjectPositions();
            saveLayout();
            viewer.refresh();
        }
    };
    actionShowStatusIcon.setChecked(labelProvider.isShowStatusIcons());
    actionShowStatusIcon.setEnabled(labelProvider.getObjectFigureType() == MapObjectDisplayMode.ICON);
    actionShowStatusFrame = new Action(Messages.get().AbstractNetworkMapView_ShowStatusFrame, Action.AS_CHECK_BOX) {

        @Override
        public void run() {
            labelProvider.setShowStatusFrame(!labelProvider.isShowStatusFrame());
            setChecked(labelProvider.isShowStatusFrame());
            updateObjectPositions();
            saveLayout();
            viewer.refresh();
        }
    };
    actionShowStatusFrame.setChecked(labelProvider.isShowStatusFrame());
    actionShowStatusFrame.setEnabled(labelProvider.getObjectFigureType() == MapObjectDisplayMode.ICON);
    actionZoomIn = new Action(Messages.get().AbstractNetworkMapView_ZoomIn, SharedIcons.ZOOM_IN) {

        @Override
        public void run() {
            viewer.zoomIn();
        }
    };
    // $NON-NLS-1$
    actionZoomIn.setId("org.netxms.ui.eclipse.networkmaps.localActions.AbstractMap.ZoomIn");
    // $NON-NLS-1$
    actionZoomIn.setActionDefinitionId("org.netxms.ui.eclipse.networkmaps.localCommands.AbstractMap.ZoomIn");
    handlerService.activateHandler(actionZoomIn.getActionDefinitionId(), new ActionHandler(actionZoomIn));
    actionZoomOut = new Action(Messages.get().AbstractNetworkMapView_ZoomOut, SharedIcons.ZOOM_OUT) {

        @Override
        public void run() {
            viewer.zoomOut();
        }
    };
    // $NON-NLS-1$
    actionZoomOut.setId("org.netxms.ui.eclipse.networkmaps.localActions.AbstractMap.ZoomOut");
    // $NON-NLS-1$
    actionZoomOut.setActionDefinitionId("org.netxms.ui.eclipse.networkmaps.localCommands.AbstractMap.ZoomOut");
    handlerService.activateHandler(actionZoomOut.getActionDefinitionId(), new ActionHandler(actionZoomOut));
    actionZoomFit = new // $NON-NLS-1$
    Action(// $NON-NLS-1$
    Messages.get().AbstractNetworkMapView_ZoomFit, // $NON-NLS-1$
    Activator.getImageDescriptor("icons/fit.png")) {

        @Override
        public void run() {
            viewer.zoomFit();
        }
    };
    // $NON-NLS-1$
    actionZoomFit.setId("org.netxms.ui.eclipse.networkmaps.localActions.AbstractMap.ZoomToFit");
    // $NON-NLS-1$
    actionZoomFit.setActionDefinitionId("org.netxms.ui.eclipse.networkmaps.localCommands.AbstractMap.ZoomToFit");
    handlerService.activateHandler(actionZoomFit.getActionDefinitionId(), new ActionHandler(actionZoomFit));
    actionZoomTo = viewer.createZoomActions(handlerService);
    actionSetAlgorithm = new Action[layoutAlgorithmNames.length];
    for (int i = 0; i < layoutAlgorithmNames.length; i++) {
        final MapLayoutAlgorithm alg = MapLayoutAlgorithm.getByValue(i);
        actionSetAlgorithm[i] = new Action(layoutAlgorithmNames[i], Action.AS_RADIO_BUTTON) {

            @Override
            public void run() {
                setLayoutAlgorithm(alg, true);
                viewer.setInput(mapPage);
            }
        };
        actionSetAlgorithm[i].setChecked(layoutAlgorithm.getValue() == i);
        actionSetAlgorithm[i].setEnabled(automaticLayoutEnabled);
    }
    actionAlwaysFitLayout = new Action(Messages.get().AbstractNetworkMapView_AlwaysFitLayout, Action.AS_CHECK_BOX) {

        @Override
        public void run() {
            alwaysFitLayout = actionAlwaysFitLayout.isChecked();
            setLayoutAlgorithm(layoutAlgorithm, true);
            IDialogSettings settings = Activator.getDefault().getDialogSettings();
            // $NON-NLS-1$
            settings.put(viewId + ".alwaysFitLayout", alwaysFitLayout);
        }
    };
    actionAlwaysFitLayout.setChecked(alwaysFitLayout);
    actionSetRouter = new Action[connectionRouterNames.length];
    for (int i = 0; i < connectionRouterNames.length; i++) {
        final int alg = i + 1;
        actionSetRouter[i] = new Action(connectionRouterNames[i], Action.AS_RADIO_BUTTON) {

            @Override
            public void run() {
                setConnectionRouter(alg, true);
            }
        };
        actionSetRouter[i].setChecked(routingAlgorithm == alg);
    }
    actionEnableAutomaticLayout = new Action(Messages.get().AbstractNetworkMapView_EnableAutoLayout, Action.AS_CHECK_BOX) {

        @Override
        public void run() {
            if (automaticLayoutEnabled) {
                setManualLayout();
            } else {
                setAutomaticLayout();
            }
            setChecked(automaticLayoutEnabled);
        }
    };
    actionEnableAutomaticLayout.setChecked(automaticLayoutEnabled);
    actionSaveLayout = new Action(Messages.get().AbstractNetworkMapView_SaveLayout) {

        @Override
        public void run() {
            updateObjectPositions();
            saveLayout();
        }
    };
    actionSaveLayout.setImageDescriptor(SharedIcons.SAVE);
    actionSaveLayout.setEnabled(!automaticLayoutEnabled);
    actionOpenDrillDownObject = new Action("Open drill-down object") {

        @Override
        public void run() {
            openDrillDownObject();
        }
    };
    actionOpenDrillDownObject.setEnabled(false);
    actionFiguresIcons = new Action(Messages.get().AbstractNetworkMapView_Icons, Action.AS_RADIO_BUTTON) {

        @Override
        public void run() {
            setObjectDisplayMode(MapObjectDisplayMode.ICON, true);
        }
    };
    actionFiguresSmallLabels = new Action(Messages.get().AbstractNetworkMapView_SmallLabels, Action.AS_RADIO_BUTTON) {

        @Override
        public void run() {
            setObjectDisplayMode(MapObjectDisplayMode.SMALL_LABEL, true);
        }
    };
    actionFiguresLargeLabels = new Action(Messages.get().AbstractNetworkMapView_LargeLabels, Action.AS_RADIO_BUTTON) {

        @Override
        public void run() {
            setObjectDisplayMode(MapObjectDisplayMode.LARGE_LABEL, true);
        }
    };
    actionFiguresStatusIcons = new Action(Messages.get().AbstractNetworkMapView_StatusIcons, Action.AS_RADIO_BUTTON) {

        @Override
        public void run() {
            setObjectDisplayMode(MapObjectDisplayMode.STATUS, true);
        }
    };
    actionFiguresFloorPlan = new Action("Floor plan", Action.AS_RADIO_BUTTON) {

        @Override
        public void run() {
            setObjectDisplayMode(MapObjectDisplayMode.FLOOR_PLAN, true);
        }
    };
    actionShowGrid = new Action(Messages.get().AbstractNetworkMapView_ShowGrid, Action.AS_CHECK_BOX) {

        @Override
        public void run() {
            viewer.showGrid(actionShowGrid.isChecked());
        }
    };
    // $NON-NLS-1$
    actionShowGrid.setImageDescriptor(Activator.getImageDescriptor("icons/grid.png"));
    actionShowGrid.setChecked(viewer.isGridVisible());
    // $NON-NLS-1$
    actionShowGrid.setId("org.netxms.ui.eclipse.networkmaps.localActions.AbstractMap.ShowGrid");
    // $NON-NLS-1$
    actionShowGrid.setActionDefinitionId("org.netxms.ui.eclipse.networkmaps.localCommands.AbstractMap.ShowGrid");
    handlerService.activateHandler(actionShowGrid.getActionDefinitionId(), new ActionHandler(actionShowGrid));
    actionSnapToGrid = new Action(Messages.get().AbstractNetworkMapView_SnapToGrid, Action.AS_CHECK_BOX) {

        @Override
        public void run() {
            viewer.setSnapToGrid(actionSnapToGrid.isChecked());
        }
    };
    // $NON-NLS-1$
    actionSnapToGrid.setImageDescriptor(Activator.getImageDescriptor("icons/snap_to_grid.png"));
    actionSnapToGrid.setChecked(viewer.isSnapToGrid());
    actionAlignToGrid = new // $NON-NLS-1$
    Action(// $NON-NLS-1$
    Messages.get().AbstractNetworkMapView_AlignToGrid, // $NON-NLS-1$
    Activator.getImageDescriptor("icons/align_to_grid.gif")) {

        @Override
        public void run() {
            viewer.alignToGrid(false);
            updateObjectPositions();
        }
    };
    // $NON-NLS-1$
    actionAlignToGrid.setId("org.netxms.ui.eclipse.networkmaps.localActions.AbstractMap.AlignToGrid");
    // $NON-NLS-1$
    actionAlignToGrid.setActionDefinitionId("org.netxms.ui.eclipse.networkmaps.localCommands.AbstractMap.AlignToGrid");
    handlerService.activateHandler(actionAlignToGrid.getActionDefinitionId(), new ActionHandler(actionAlignToGrid));
    actionShowObjectDetails = new Action(Messages.get().AbstractNetworkMapView_ShowObjDetails) {

        @Override
        public void run() {
            showObjectDetails();
        }
    };
    actionHideLinkLabels = new Action(Messages.get().AbstractNetworkMapView_HideLinkLabels, Action.AS_CHECK_BOX) {

        @Override
        public void run() {
            labelProvider.setConnectionLabelsVisible(!actionHideLinkLabels.isChecked());
            viewer.refresh(true);
        }
    };
    // $NON-NLS-1$
    actionHideLinkLabels.setImageDescriptor(Activator.getImageDescriptor("icons/hide_link.png"));
    actionHideLinks = new Action(Messages.get().AbstractNetworkMapView_HideLinks, Action.AS_CHECK_BOX) {

        @Override
        public void run() {
            labelProvider.setConnectionsVisible(!actionHideLinks.isChecked());
            viewer.refresh(true);
        }
    };
    // $NON-NLS-1$
    actionHideLinks.setImageDescriptor(Activator.getImageDescriptor("icons/hide_net_link.png"));
    actionSelectAllObjects = new Action(Messages.get().AbstractNetworkMapView_SelectAllObjects) {

        @Override
        public void run() {
            viewer.setSelection(new StructuredSelection(mapPage.getObjectElements()));
        }
    };
    // $NON-NLS-1$
    actionSelectAllObjects.setId("org.netxms.ui.eclipse.networkmaps.localActions.AbstractMap.SelectAllObjects");
    // $NON-NLS-1$
    actionSelectAllObjects.setActionDefinitionId("org.netxms.ui.eclipse.networkmaps.localCommands.AbstractMap.SelectAllObjects");
    handlerService.activateHandler(actionSelectAllObjects.getActionDefinitionId(), new ActionHandler(actionSelectAllObjects));
    actionLockLink = new Action("Locked") {

        @Override
        public void run() {
            changeLinkLock();
        }
    };
}
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) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) MapLayoutAlgorithm(org.netxms.client.maps.MapLayoutAlgorithm) ActionHandler(org.eclipse.jface.commands.ActionHandler) Point(org.eclipse.draw2d.geometry.Point)

Example 29 with ActionHandler

use of org.eclipse.jface.commands.ActionHandler in project netxms by netxms.

the class ObjectBrowser method createActions.

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

        @Override
        public void run() {
            objectTree.refresh();
        }
    };
    actionMoveObject = new Action(Messages.get().ObjectBrowser_MoveObject) {

        @Override
        public void run() {
            moveObject(SubtreeType.INFRASTRUCTURE);
        }
    };
    // $NON-NLS-1$
    actionMoveObject.setId("org.netxms.ui.eclipse.objectbrowser.actions.moveObject");
    actionMoveTemplate = new Action(Messages.get().ObjectBrowser_MoveTemplate) {

        @Override
        public void run() {
            moveObject(SubtreeType.TEMPLATES);
        }
    };
    // $NON-NLS-1$
    actionMoveTemplate.setId("org.netxms.ui.eclipse.objectbrowser.actions.moveTemplate");
    actionMoveBusinessService = new Action(Messages.get().ObjectBrowser_MoveService) {

        @Override
        public void run() {
            moveObject(SubtreeType.BUSINESS_SERVICES);
        }
    };
    // $NON-NLS-1$
    actionMoveBusinessService.setId("org.netxms.ui.eclipse.objectbrowser.actions.moveBusinessService");
    actionMoveDashboard = new Action(Messages.get().ObjectBrowser_MoveDashboard) {

        @Override
        public void run() {
            moveObject(SubtreeType.DASHBOARDS);
        }
    };
    // $NON-NLS-1$
    actionMoveDashboard.setId("org.netxms.ui.eclipse.objectbrowser.actions.moveDashboard");
    actionMoveMap = new Action(Messages.get().ObjectBrowser_MoveMap) {

        @Override
        public void run() {
            moveObject(SubtreeType.MAPS);
        }
    };
    // $NON-NLS-1$
    actionMoveMap.setId("org.netxms.ui.eclipse.objectbrowser.actions.moveMap");
    actionMovePolicy = new Action(Messages.get().ObjectBrowser_MovePolicy) {

        @Override
        public void run() {
            moveObject(SubtreeType.POLICIES);
        }
    };
    // $NON-NLS-1$
    actionMovePolicy.setId("org.netxms.ui.eclipse.objectbrowser.actions.movePolicy");
    actionHideUnmanaged = new Action(Messages.get().ObjectBrowser_HideUnmanaged, Action.AS_CHECK_BOX) {

        @Override
        public void run() {
            objectTree.setHideUnmanaged(actionHideUnmanaged.isChecked());
        }
    };
    // $NON-NLS-1$
    actionHideUnmanaged.setId("org.netxms.ui.eclipse.objectbrowser.actions.hideUnmanaged");
    actionHideUnmanaged.setChecked(objectTree.isHideUnmanaged());
    actionHideTemplateChecks = new Action(Messages.get().ObjectBrowser_HideCheckTemplates, Action.AS_CHECK_BOX) {

        @Override
        public void run() {
            objectTree.setHideTemplateChecks(actionHideTemplateChecks.isChecked());
        }
    };
    // $NON-NLS-1$
    actionHideTemplateChecks.setId("org.netxms.ui.eclipse.objectbrowser.actions.hideTemplateChecks");
    actionHideTemplateChecks.setChecked(objectTree.isHideTemplateChecks());
    actionHideSubInterfaces = new Action(Messages.get().ObjectBrowser_HideSubInterfaces, Action.AS_CHECK_BOX) {

        @Override
        public void run() {
            objectTree.setHideSubInterfaces(actionHideSubInterfaces.isChecked());
        }
    };
    // $NON-NLS-1$
    actionHideSubInterfaces.setId("org.netxms.ui.eclipse.objectbrowser.actions.hideSubInterfaces");
    actionHideSubInterfaces.setChecked(objectTree.isHideSubInterfaces());
    actionShowFilter = new Action(Messages.get().ObjectBrowser_ShowFilter, Action.AS_CHECK_BOX) {

        @Override
        public void run() {
            objectTree.enableFilter(actionShowFilter.isChecked());
        }
    };
    // $NON-NLS-1$
    actionShowFilter.setId("org.netxms.ui.eclipse.objectbrowser.actions.showFilter");
    actionShowFilter.setChecked(objectTree.isFilterEnabled());
    // $NON-NLS-1$
    actionShowFilter.setActionDefinitionId("org.netxms.ui.eclipse.objectbrowser.commands.show_object_filter");
    final ActionHandler showFilterHandler = new ActionHandler(actionShowFilter);
    handlerService.activateHandler(actionShowFilter.getActionDefinitionId(), showFilterHandler);
    actionShowStatusIndicator = new Action(Messages.get().ObjectBrowser_ShowStatusIndicator, Action.AS_CHECK_BOX) {

        @Override
        public void run() {
            objectTree.enableStatusIndicator(actionShowStatusIndicator.isChecked());
        }
    };
    // $NON-NLS-1$
    actionShowStatusIndicator.setId("org.netxms.ui.eclipse.objectbrowser.actions.showStatusIndicator");
    actionShowStatusIndicator.setChecked(objectTree.isStatusIndicatorEnabled());
    // $NON-NLS-1$
    actionShowStatusIndicator.setActionDefinitionId("org.netxms.ui.eclipse.objectbrowser.commands.show_status_indicator");
    final ActionHandler showStatusIndicatorHandler = new ActionHandler(actionShowStatusIndicator);
    handlerService.activateHandler(actionShowStatusIndicator.getActionDefinitionId(), showStatusIndicatorHandler);
    actionRenameObject = new Action(Messages.get().ObjectBrowser_Rename) {

        @Override
        public void run() {
            TreeItem[] selection = objectTree.getTreeControl().getSelection();
            if (selection.length != 1)
                return;
            objectTree.getTreeViewer().editElement(selection[0].getData(), 0);
        }
    };
    // $NON-NLS-1$
    actionRenameObject.setId("org.netxms.ui.eclipse.objectbrowser.actions.rename");
    // $NON-NLS-1$
    actionRenameObject.setActionDefinitionId("org.netxms.ui.eclipse.objectbrowser.commands.rename_object");
    final ActionHandler renameObjectHandler = new ActionHandler(actionRenameObject);
    handlerService.activateHandler(actionRenameObject.getActionDefinitionId(), renameObjectHandler);
}
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 30 with ActionHandler

use of org.eclipse.jface.commands.ActionHandler in project netxms by netxms.

the class PredefinedMap method createActions.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.netxms.ui.eclipse.networkmaps.views.NetworkMap#createActions()
	 */
@Override
protected void createActions() {
    super.createActions();
    final IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class);
    actionAddObject = new Action(Messages.get().PredefinedMap_AddObject) {

        @Override
        public void run() {
            addObjectToMap();
        }
    };
    // $NON-NLS-1$
    actionAddObject.setId("org.netxms.ui.eclipse.networkmaps.localActions.PredefinedMap.AddObject");
    // $NON-NLS-1$
    actionAddObject.setActionDefinitionId("org.netxms.ui.eclipse.networkmaps.localCommands.PredefinedMap.AddObject");
    handlerService.activateHandler(actionAddObject.getActionDefinitionId(), new ActionHandler(actionAddObject));
    actionAddDCIContainer = new Action(Messages.get().PredefinedMap_AddDciContainer) {

        @Override
        public void run() {
            addDCIContainerToMap();
        }
    };
    // $NON-NLS-1$
    actionAddDCIContainer.setId("org.netxms.ui.eclipse.networkmaps.localActions.PredefinedMap.AddDCIContainer");
    // $NON-NLS-1$
    actionAddDCIContainer.setActionDefinitionId("org.netxms.ui.eclipse.networkmaps.localCommands.PredefinedMap.AddDCIContainer");
    handlerService.activateHandler(actionAddDCIContainer.getActionDefinitionId(), new ActionHandler(actionAddDCIContainer));
    actionAddDCIImage = new Action(Messages.get().PredefinedMap_AddDciImage) {

        @Override
        public void run() {
            addDCIImageToMap();
        }
    };
    // $NON-NLS-1$
    actionAddDCIImage.setId("org.netxms.ui.eclipse.networkmaps.localActions.PredefinedMap.AddDCIImage");
    // $NON-NLS-1$
    actionAddDCIImage.setActionDefinitionId("org.netxms.ui.eclipse.networkmaps.localCommands.PredefinedMap.AddDCIImage");
    handlerService.activateHandler(actionAddDCIImage.getActionDefinitionId(), new ActionHandler(actionAddDCIImage));
    actionAddGroupBox = new Action(Messages.get().PredefinedMap_GroupBox) {

        @Override
        public void run() {
            addGroupBoxDecoration();
        }
    };
    actionAddImage = new Action(Messages.get().PredefinedMap_Image) {

        @Override
        public void run() {
            addImageDecoration();
        }
    };
    actionLinkObjects = new // $NON-NLS-1$
    Action(// $NON-NLS-1$
    Messages.get().PredefinedMap_LinkObjects, // $NON-NLS-1$
    Activator.getImageDescriptor("icons/link_add.png")) {

        @Override
        public void run() {
            linkSelectedObjects();
        }
    };
    // $NON-NLS-1$
    actionLinkObjects.setId("org.netxms.ui.eclipse.networkmaps.localActions.PredefinedMap.LinkObjects");
    // $NON-NLS-1$
    actionLinkObjects.setActionDefinitionId("org.netxms.ui.eclipse.networkmaps.localCommands.PredefinedMap.LinkObjects");
    handlerService.activateHandler(actionLinkObjects.getActionDefinitionId(), new ActionHandler(actionLinkObjects));
    actionRemove = new Action(Messages.get().PredefinedMap_RemoveFromMap, SharedIcons.DELETE_OBJECT) {

        @Override
        public void run() {
            removeSelectedElements();
        }
    };
    // $NON-NLS-1$
    actionRemove.setId("org.netxms.ui.eclipse.networkmaps.localActions.PredefinedMap.Remove");
    // $NON-NLS-1$
    actionRemove.setActionDefinitionId("org.netxms.ui.eclipse.networkmaps.localCommands.PredefinedMap.Remove");
    handlerService.activateHandler(actionRemove.getActionDefinitionId(), new ActionHandler(actionRemove));
    actionDCIContainerProperties = new Action(Messages.get().PredefinedMap_Properties) {

        @Override
        public void run() {
            showDCIContainerProperties();
        }
    };
    actionDCIImageProperties = new Action(Messages.get().PredefinedMap_Properties) {

        @Override
        public void run() {
            showDCIImageProperties();
        }
    };
    actionMapProperties = new Action(Messages.get().PredefinedMap_MapProperties) {

        @Override
        public void run() {
            showMapProperties();
        }
    };
    actionLinkProperties = new Action(Messages.get().PredefinedMap_Properties) {

        @Override
        public void run() {
            showLinkProperties();
        }
    };
    actionAddTextBox = new Action("Text box") {

        @Override
        public void run() {
            addTextBoxToMap();
        }
    };
    actionTextBoxProperties = new Action("Text box properties") {

        @Override
        public void run() {
            showTextBoxProperties();
        }
    };
    actionGroupBoxEdit = new Action("Group box properties") {

        @Override
        public void run() {
            editGroupBox();
        }
    };
}
Also used : Action(org.eclipse.jface.action.Action) IHandlerService(org.eclipse.ui.handlers.IHandlerService) ActionHandler(org.eclipse.jface.commands.ActionHandler)

Aggregations

ActionHandler (org.eclipse.jface.commands.ActionHandler)47 IHandlerService (org.eclipse.ui.handlers.IHandlerService)45 Action (org.eclipse.jface.action.Action)36 RefreshAction (org.netxms.ui.eclipse.actions.RefreshAction)23 IAction (org.eclipse.jface.action.IAction)6 IContextService (org.eclipse.ui.contexts.IContextService)5 ExportToCsvAction (org.netxms.ui.eclipse.actions.ExportToCsvAction)5 ArrayList (java.util.ArrayList)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 FocusEvent (org.eclipse.swt.events.FocusEvent)3 FocusListener (org.eclipse.swt.events.FocusListener)3 ActiveShellExpression (org.eclipse.ui.ActiveShellExpression)3 IHandlerActivation (org.eclipse.ui.handlers.IHandlerActivation)3 IActionBars (org.eclipse.ui.IActionBars)2 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)2 ServerAction (org.netxms.client.ServerAction)2 BorderColorAction (com.archimatetool.editor.diagram.actions.BorderColorAction)1 BringForwardAction (com.archimatetool.editor.diagram.actions.BringForwardAction)1 BringToFrontAction (com.archimatetool.editor.diagram.actions.BringToFrontAction)1 ConnectionLineWidthAction (com.archimatetool.editor.diagram.actions.ConnectionLineWidthAction)1