Search in sources :

Example 1 with ActionHandler

use of org.eclipse.jface.commands.ActionHandler in project tdi-studio-se by Talend.

the class AbstractTalendEditor method configureGraphicalViewer.

@Override
protected void configureGraphicalViewer() {
    super.configureGraphicalViewer();
    /** * Manage the view in the Outline ** */
    ScrollingGraphicalViewer viewer = (ScrollingGraphicalViewer) getGraphicalViewer();
    viewer.setSelectionManager(new TalendSelectionManager());
    TalendScalableFreeformRootEditPart root = new TalendScalableFreeformRootEditPart(getEditorInput());
    List<String> zoomLevels = new ArrayList<String>();
    zoomLevels.add(ZoomManager.FIT_ALL);
    zoomLevels.add(ZoomManager.FIT_WIDTH);
    zoomLevels.add(ZoomManager.FIT_HEIGHT);
    root.getZoomManager().setZoomLevelContributions(zoomLevels);
    // root.getZoomManager().setZoomAnimationStyle(ZoomManager.ANIMATE_NEVER);
    IAction zoomIn = new ZoomInAction(root.getZoomManager());
    IAction zoomOut = new ZoomOutAction(root.getZoomManager());
    getActionRegistry().registerAction(zoomIn);
    getActionRegistry().registerAction(zoomOut);
    IHandlerService service = (IHandlerService) getEditorSite().getService(IHandlerService.class);
    service.activateHandler(zoomIn.getActionDefinitionId(), new ActionHandler(zoomIn));
    service.activateHandler(zoomOut.getActionDefinitionId(), new ActionHandler(zoomOut));
    IAction directEditAction = new DirectEditAction(this);
    getActionRegistry().registerAction(directEditAction);
    getSelectionActions().add(directEditAction.getId());
    IAction copyAction = new GEFCopyAction(this);
    getActionRegistry().registerAction(copyAction);
    getSelectionActions().add(copyAction.getId());
    // setAction(copyAction.getId(), copyAction);
    IAction pasteAction = new GEFPasteAction(this);
    getActionRegistry().registerAction(pasteAction);
    getSelectionActions().add(pasteAction.getId());
    // setAction(pasteAction.getId(), pasteAction);
    IAction deleteAction = new GEFDeleteAction(this);
    getActionRegistry().registerAction(deleteAction);
    getSelectionActions().add(deleteAction.getId());
    // setAction(deleteAction.getId(), deleteAction);
    IAction undoAction = new GEFUndoAction(this);
    getActionRegistry().registerAction(undoAction);
    getSelectionActions().add(undoAction.getId());
    IAction redoAction = new GEFRedoAction(this);
    getActionRegistry().registerAction(redoAction);
    getSelectionActions().add(redoAction.getId());
    IAction setRefAction = new ConnectionSetAsMainRef(this);
    getActionRegistry().registerAction(setRefAction);
    getSelectionActions().add(setRefAction.getId());
    IAction modifyMergeAction = new ModifyMergeOrderAction(this);
    getActionRegistry().registerAction(modifyMergeAction);
    getSelectionActions().add(modifyMergeAction.getId());
    IAction modifyOutputOrderAction = new ModifyOutputOrderAction(this);
    getActionRegistry().registerAction(modifyOutputOrderAction);
    getSelectionActions().add(modifyOutputOrderAction.getId());
    List<IAction> calcOrderActions = ModifyConnectionOrderAction.getOrderActions(this);
    for (IAction orderAction : calcOrderActions) {
        getActionRegistry().registerAction(orderAction);
        getSelectionActions().add(orderAction.getId());
    }
    viewer.setRootEditPart(root);
    PartFactory partFactory = new PartFactory();
    // set the factory to use for creating EditParts for elements in the model
    getGraphicalViewer().setEditPartFactory(partFactory);
    getGraphicalViewer().setKeyHandler(new NodePartKeyHander(getGraphicalViewer()).setParent(getCommonKeyHandler()));
    // GraphicalViewer graViewer = getGraphicalViewer();
    // graViewer.setKeyHandler(new GraphicalViewerKeyHandler(graViewer));
    initializeActivationCodeTrigger();
    /** * Management of the context menu ** */
    ContextMenuProvider cmProvider = new TalendEditorContextMenuProvider(this, viewer, getActionRegistry());
    viewer.setContextMenu(cmProvider);
    /** * Management of the Zoom ** */
    /*
         * ZoomManager manager = (ZoomManager) getGraphicalViewer().getProperty(ZoomManager.class.toString()); if
         * (manager != null) { manager.setZoom(getProcess().getZoom()); }
         */
    // Scroll-wheel Zoom
    getGraphicalViewer().setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.MOD1), MouseWheelZoomHandler.SINGLETON);
    /** * Snap To Grid ** */
    // Grid properties
    getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_SPACING, new Dimension(AbstractTalendEditor.GRID_SIZE, AbstractTalendEditor.GRID_SIZE));
    getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, new Boolean(true));
    // We keep grid visibility and enablement in sync
    getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, new Boolean(true));
    IAction showGrid = new ToggleGridAction(getGraphicalViewer());
    getActionRegistry().registerAction(showGrid);
    /** * Snap To Geometry ** */
    getGraphicalViewer().setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED, new Boolean(false));
    IAction snapAction = new ToggleSnapToGeometryAction(getGraphicalViewer());
    getActionRegistry().registerAction(snapAction);
    configurationSubJob(viewer);
}
Also used : ModifyMergeOrderAction(org.talend.designer.core.ui.action.ModifyMergeOrderAction) ToggleSnapToGeometryAction(org.eclipse.gef.ui.actions.ToggleSnapToGeometryAction) GEFCopyAction(org.talend.designer.core.ui.action.GEFCopyAction) GEFPasteAction(org.talend.designer.core.ui.action.GEFPasteAction) GEFDeleteAction(org.talend.designer.core.ui.action.GEFDeleteAction) ZoomOutAction(org.eclipse.gef.ui.actions.ZoomOutAction) ProcessTreePartFactory(org.talend.designer.core.ui.editor.outline.ProcessTreePartFactory) ArrayList(java.util.ArrayList) ContextMenuProvider(org.eclipse.gef.ContextMenuProvider) ScrollingGraphicalViewer(org.eclipse.gef.ui.parts.ScrollingGraphicalViewer) NodePartKeyHander(org.talend.designer.core.ui.NodePartKeyHander) ModifyOutputOrderAction(org.talend.designer.core.ui.action.ModifyOutputOrderAction) DirectEditAction(org.eclipse.gef.ui.actions.DirectEditAction) ZoomInAction(org.eclipse.gef.ui.actions.ZoomInAction) IAction(org.eclipse.jface.action.IAction) ConnectionSetAsMainRef(org.talend.designer.core.ui.action.ConnectionSetAsMainRef) ToggleGridAction(org.eclipse.gef.ui.actions.ToggleGridAction) GEFUndoAction(org.talend.designer.core.ui.action.GEFUndoAction) Dimension(org.eclipse.draw2d.geometry.Dimension) IHandlerService(org.eclipse.ui.handlers.IHandlerService) GEFRedoAction(org.talend.designer.core.ui.action.GEFRedoAction) ActionHandler(org.eclipse.jface.commands.ActionHandler)

Example 2 with ActionHandler

use of org.eclipse.jface.commands.ActionHandler in project mylyn.docs by eclipse.

the class MarkupEditorOutline method configureActionBars.

private void configureActionBars(IPageSite site) {
    IActionBars actionBars = site.getActionBars();
    IToolBarManager toolBarManager = actionBars.getToolBarManager();
    IHandlerService handlerService = (IHandlerService) site.getService(IHandlerService.class);
    CollapseAllAction collapseAllAction = new CollapseAllAction(getTreeViewer());
    toolBarManager.add(collapseAllAction);
    handlerService.activateHandler(CollapseAllHandler.COMMAND_ID, new ActionHandler(collapseAllAction));
    actionBars.updateActionBars();
}
Also used : IHandlerService(org.eclipse.ui.handlers.IHandlerService) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ActionHandler(org.eclipse.jface.commands.ActionHandler) IActionBars(org.eclipse.ui.IActionBars)

Example 3 with ActionHandler

use of org.eclipse.jface.commands.ActionHandler in project tdq-studio-se by Talend.

the class PatternTestView method activateContext.

/**
 * Activate a context that this view uses. It will be tied to this view activation events and will be removed when
 * the view is disposed.
 */
private void activateContext() {
    IContextService contextService = (IContextService) getSite().getService(IContextService.class);
    contextService.activateContext(VIEW_CONTEXT_ID);
    TestRegularAction testRegularAction = new TestRegularAction();
    IHandlerService service = (IHandlerService) getViewSite().getService(IHandlerService.class);
    service.activateHandler(testRegularAction.getActionDefinitionId(), new ActionHandler(testRegularAction));
}
Also used : IHandlerService(org.eclipse.ui.handlers.IHandlerService) IContextService(org.eclipse.ui.contexts.IContextService) ActionHandler(org.eclipse.jface.commands.ActionHandler)

Example 4 with ActionHandler

use of org.eclipse.jface.commands.ActionHandler in project polymap4-core by Polymap4.

the class CommonNavigatorActionGroup method makeActions.

/**
 */
private void makeActions() {
    FrameList frameList = commonViewer.getFrameList();
    backAction = new BackAction(frameList);
    forwardAction = new ForwardAction(frameList);
    upAction = new UpAction(frameList);
    frameList.addPropertyChangeListener(new IPropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty().equals(FrameList.P_RESET)) {
                upAction.setEnabled(false);
                backAction.setEnabled(false);
                forwardAction.setEnabled(false);
            }
            commonNavigator.updateTitle();
            IActionBars actionBars = commonNavigator.getViewSite().getActionBars();
            updateToolBar(actionBars.getToolBarManager());
        }
    });
    IHandlerService service = (IHandlerService) commonNavigator.getSite().getService(IHandlerService.class);
    INavigatorViewerDescriptor viewerDescriptor = commonViewer.getNavigatorContentService().getViewerDescriptor();
    boolean hideLinkWithEditorAction = viewerDescriptor.getBooleanConfigProperty(INavigatorViewerDescriptor.PROP_HIDE_LINK_WITH_EDITOR_ACTION);
    if (!hideLinkWithEditorAction) {
        toggleLinkingAction = new LinkEditorAction(commonNavigator, commonViewer, linkHelperService);
        // $NON-NLS-1$
        ImageDescriptor syncIcon = getImageDescriptor("elcl16/synced.gif");
        toggleLinkingAction.setImageDescriptor(syncIcon);
        toggleLinkingAction.setHoverImageDescriptor(syncIcon);
        service.activateHandler(toggleLinkingAction.getActionDefinitionId(), new ActionHandler(toggleLinkingAction));
    }
    boolean hideCollapseAllAction = viewerDescriptor.getBooleanConfigProperty(INavigatorViewerDescriptor.PROP_HIDE_COLLAPSE_ALL_ACTION);
    if (!hideCollapseAllAction) {
        collapseAllAction = new CollapseAllAction(commonViewer);
        // $NON-NLS-1$
        ImageDescriptor collapseAllIcon = getImageDescriptor("elcl16/collapseall.gif");
        collapseAllAction.setImageDescriptor(collapseAllIcon);
        collapseAllAction.setHoverImageDescriptor(collapseAllIcon);
        collapseAllHandler = new CollapseAllHandler(commonViewer);
        service.activateHandler(CollapseAllHandler.COMMAND_ID, collapseAllHandler);
    }
    filterGroup = new FilterActionGroup(commonViewer);
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) UpAction(org.eclipse.ui.internal.navigator.framelist.UpAction) FrameList(org.eclipse.ui.internal.navigator.framelist.FrameList) CollapseAllHandler(org.eclipse.ui.handlers.CollapseAllHandler) LinkEditorAction(org.eclipse.ui.internal.navigator.actions.LinkEditorAction) INavigatorViewerDescriptor(org.eclipse.ui.navigator.INavigatorViewerDescriptor) FilterActionGroup(org.eclipse.ui.internal.navigator.filters.FilterActionGroup) IHandlerService(org.eclipse.ui.handlers.IHandlerService) CollapseAllAction(org.eclipse.ui.internal.navigator.actions.CollapseAllAction) ForwardAction(org.eclipse.ui.internal.navigator.framelist.ForwardAction) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) BackAction(org.eclipse.ui.internal.navigator.framelist.BackAction) ActionHandler(org.eclipse.jface.commands.ActionHandler) IActionBars(org.eclipse.ui.IActionBars)

Example 5 with ActionHandler

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

the class AbstractTraceWidget method createActions.

/**
 * Create actions
 */
protected void createActions() {
    final IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class);
    actionPause = new Action(Messages.get().AbstractTraceView_Pause, Action.AS_CHECK_BOX) {

        @Override
        public void run() {
            setPaused(actionPause.isChecked());
        }
    };
    // $NON-NLS-1$
    actionPause.setImageDescriptor(Activator.getImageDescriptor("icons/pause.png"));
    // $NON-NLS-1$
    actionPause.setActionDefinitionId("org.netxms.ui.eclipse.library.commands.pause_trace");
    final ActionHandler pauseHandler = new ActionHandler(actionPause);
    handlerService.activateHandler(actionPause.getActionDefinitionId(), pauseHandler);
}
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