Search in sources :

Example 46 with ActionHandler

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

the class MarkupEditor method setAction.

@Override
public void setAction(String actionID, IAction action) {
    if (action != null && action.getActionDefinitionId() != null && !isCommandAction(action)) {
        // bug 336679: don't activate handlers for CommandAction.
        // We do this by class name so that we don't rely on internals
        IHandlerService handlerService = getSite().getService(IHandlerService.class);
        handlerService.activateHandler(action.getActionDefinitionId(), new ActionHandler(action));
    }
    super.setAction(actionID, action);
}
Also used : IHandlerService(org.eclipse.ui.handlers.IHandlerService) ActionHandler(org.eclipse.jface.commands.ActionHandler)

Example 47 with ActionHandler

use of org.eclipse.jface.commands.ActionHandler in project erlide_eclipse by erlang.

the class ErlangOutlinePage method createControl.

@Override
public void createControl(final Composite parent) {
    final Tree tree = new Tree(parent, SWT.MULTI);
    fOutlineViewer = new TreeViewer(tree);
    fOutlineViewer.setAutoExpandLevel(0);
    fOutlineViewer.setUseHashlookup(true);
    fOutlineViewer.setContentProvider(fEditor.createOutlineContentProvider());
    fOutlineViewer.setLabelProvider(fEditor.createOutlineLabelProvider());
    fOutlineViewer.addPostSelectionChangedListener(this);
    fOutlineViewer.setInput(fModule);
    final IPageSite site = getSite();
    fOpenAndLinkWithEditorHelper = new OpenAndLinkWithEditorHelper(fOutlineViewer, fEditor, site.getPage());
    final IContextService service = site.getService(IContextService.class);
    if (service != null) {
        service.activateContext("org.erlide.ui.erlangOutlineAndNavigatorScope");
    }
    final MenuManager manager = new MenuManager();
    manager.setRemoveAllWhenShown(true);
    manager.addMenuListener(this::contextMenuAboutToShow);
    final Menu menu = manager.createContextMenu(tree);
    tree.setMenu(menu);
    site.registerContextMenu(ErlangCore.PLUGIN_ID + ".outline", manager, fOutlineViewer);
    fActionGroups = new CompositeActionGroup(new ActionGroup[] { new ErlangSearchActionGroup(this) });
    // register global actions
    final IActionBars actionBars = site.getActionBars();
    actionBars.setGlobalActionHandler(ITextEditorActionConstants.UNDO, fEditor.getAction(ITextEditorActionConstants.UNDO));
    actionBars.setGlobalActionHandler(ITextEditorActionConstants.REDO, fEditor.getAction(ITextEditorActionConstants.REDO));
    fActionGroups.fillActionBars(actionBars);
    registerToolbarActions(actionBars);
    final IHandlerService handlerService = site.getService(IHandlerService.class);
    if (handlerService != null) {
        handlerService.activateHandler(IWorkbenchCommandConstants.NAVIGATE_TOGGLE_LINK_WITH_EDITOR, new ActionHandler(fToggleLinkingAction));
    }
    fPartListener = new IPartListener() {

        @Override
        public void partOpened(final IWorkbenchPart part) {
            // JC borde filter-metoden ovan r�cka?
            addFilters();
        }

        @Override
        public void partDeactivated(final IWorkbenchPart part) {
        }

        @Override
        public void partClosed(final IWorkbenchPart part) {
        }

        @Override
        public void partBroughtToTop(final IWorkbenchPart part) {
        }

        @Override
        public void partActivated(final IWorkbenchPart part) {
            addFilters();
        }
    };
    getSite().getPage().addPartListener(fPartListener);
}
Also used : CompositeActionGroup(org.erlide.ui.actions.CompositeActionGroup) ErlangSearchActionGroup(org.erlide.ui.actions.ErlangSearchActionGroup) TreeViewer(org.eclipse.jface.viewers.TreeViewer) IPartListener(org.eclipse.ui.IPartListener) IPageSite(org.eclipse.ui.part.IPageSite) IHandlerService(org.eclipse.ui.handlers.IHandlerService) ActionGroup(org.eclipse.ui.actions.ActionGroup) ErlangSearchActionGroup(org.erlide.ui.actions.ErlangSearchActionGroup) CompositeActionGroup(org.erlide.ui.actions.CompositeActionGroup) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Tree(org.eclipse.swt.widgets.Tree) IContextService(org.eclipse.ui.contexts.IContextService) Menu(org.eclipse.swt.widgets.Menu) ActionHandler(org.eclipse.jface.commands.ActionHandler) IActionBars(org.eclipse.ui.IActionBars)

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