Search in sources :

Example 56 with IHandlerService

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

the class CheckForUpdateAction method activateStandardHandler.

public static void activateStandardHandler(IWorkbenchWindow window) {
    if (p2UpdateHandlerActivation == null) {
        return;
    }
    IHandlerService srv = window.getService(IHandlerService.class);
    srv.deactivateHandler(p2UpdateHandlerActivation);
    p2UpdateHandlerActivation = null;
}
Also used : IHandlerService(org.eclipse.ui.handlers.IHandlerService)

Example 57 with IHandlerService

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

the class CheckForUpdateAction method deactivateStandardHandler.

public static void deactivateStandardHandler(IWorkbenchWindow window) {
    if (p2UpdateHandlerActivation != null) {
        return;
    }
    IHandlerService srv = window.getService(IHandlerService.class);
    p2UpdateHandlerActivation = srv.activateHandler(CheckForUpdateAction.P2_UPDATE_COMMAND, new AbstractHandler() {

        @Override
        public Object execute(ExecutionEvent event) throws ExecutionException {
            new CheckForUpdateAction().run();
            return null;
        }
    });
}
Also used : IHandlerService(org.eclipse.ui.handlers.IHandlerService) ExecutionEvent(org.eclipse.core.commands.ExecutionEvent) AbstractHandler(org.eclipse.core.commands.AbstractHandler)

Example 58 with IHandlerService

use of org.eclipse.ui.handlers.IHandlerService in project eclipse.platform.text by eclipse.

the class ContentAssistHandler method deactivateHandler.

/**
 * Unregister the {@link IHandlerActivation} from the shell.
 */
private void deactivateHandler() {
    IHandlerService handlerService = PlatformUI.getWorkbench().getAdapter(IHandlerService.class);
    if (handlerService != null)
        handlerService.deactivateHandler(fHandlerActivation);
    fHandlerActivation = null;
}
Also used : IHandlerService(org.eclipse.ui.handlers.IHandlerService)

Example 59 with IHandlerService

use of org.eclipse.ui.handlers.IHandlerService in project xtext-xtend by eclipse.

the class ShowHierarchyTest method invokeTestingHandler.

@SuppressWarnings("cast")
private TestingTypeHierarchyHandler invokeTestingHandler(XtextEditor xtextEditor, String commandID) throws Exception {
    IHandlerService handlerService = (IHandlerService) xtextEditor.getSite().getService(IHandlerService.class);
    final ICommandService commandService = (ICommandService) xtextEditor.getSite().getService(ICommandService.class);
    Command command = commandService.getCommand("org.eclipse.xtext.xbase.ui.hierarchy.OpenTypeHierarchy");
    TestingTypeHierarchyHandler testingHandler = new TestingTypeHierarchyHandler();
    getInjector().injectMembers(testingHandler);
    IHandler originalHandler = command.getHandler();
    command.setHandler(testingHandler);
    final ExecutionEvent event = new ExecutionEvent(command, Collections.EMPTY_MAP, null, handlerService.getCurrentState());
    command.executeWithChecks(event);
    command.setHandler(originalHandler);
    return testingHandler;
}
Also used : IHandlerService(org.eclipse.ui.handlers.IHandlerService) Command(org.eclipse.core.commands.Command) ExecutionEvent(org.eclipse.core.commands.ExecutionEvent) IHandler(org.eclipse.core.commands.IHandler) ICommandService(org.eclipse.ui.commands.ICommandService)

Example 60 with IHandlerService

use of org.eclipse.ui.handlers.IHandlerService in project archi by archimatetool.

the class AbstractDiagramEditor method createActions.

/**
 * Add some extra Actions - *after* the graphical viewer has been created
 */
@SuppressWarnings("unchecked")
protected void createActions(GraphicalViewer viewer) {
    ActionRegistry registry = getActionRegistry();
    IAction action;
    // Zoom Manager tweaking
    ZoomManager zoomManager = (ZoomManager) getAdapter(ZoomManager.class);
    double[] zoomLevels = { .25, .5, .75, 1, 1.5, 2, 3, 4, 6, 8 };
    zoomManager.setZoomLevels(zoomLevels);
    List<String> zoomContributionLevels = new ArrayList<String>();
    zoomContributionLevels.add(ZoomManager.FIT_ALL);
    zoomContributionLevels.add(ZoomManager.FIT_WIDTH);
    zoomContributionLevels.add(ZoomManager.FIT_HEIGHT);
    zoomManager.setZoomLevelContributions(zoomContributionLevels);
    // Zoom Actions
    IAction zoomIn = new ZoomInAction(zoomManager);
    IAction zoomOut = new ZoomOutAction(zoomManager);
    IAction zoomNormal = new ZoomNormalAction(zoomManager);
    registry.registerAction(zoomIn);
    registry.registerAction(zoomOut);
    registry.registerAction(zoomNormal);
    // Add these zoom actions to the key binding service
    IHandlerService service = getEditorSite().getService(IHandlerService.class);
    service.activateHandler(zoomIn.getActionDefinitionId(), new ActionHandler(zoomIn));
    service.activateHandler(zoomOut.getActionDefinitionId(), new ActionHandler(zoomOut));
    service.activateHandler(zoomNormal.getActionDefinitionId(), new ActionHandler(zoomNormal));
    // Add our own Select All Action so we can select connections as well
    action = new SelectAllAction(this);
    registry.registerAction(action);
    // Add our own Print Action
    action = new PrintDiagramAction(this);
    registry.registerAction(action);
    // Direct Edit Rename
    action = new DirectEditAction(this);
    // Set this for Global Handler
    action.setId(ActionFactory.RENAME.getId());
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    getUpdateCommandStackActions().add((UpdateAction) action);
    // Change the Delete Action label
    action = registry.getAction(ActionFactory.DELETE.getId());
    action.setText(Messages.AbstractDiagramEditor_2);
    action.setToolTipText(action.getText());
    getUpdateCommandStackActions().add((UpdateAction) action);
    // Paste
    PasteAction pasteAction = new PasteAction(this, viewer);
    registry.registerAction(pasteAction);
    getSelectionActions().add(pasteAction.getId());
    // Paste Special
    PasteSpecialAction pasteSpecialAction = new PasteSpecialAction(this, viewer);
    registry.registerAction(pasteSpecialAction);
    getSelectionActions().add(pasteSpecialAction.getId());
    // Cut
    action = new CutAction(this, pasteAction);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    getUpdateCommandStackActions().add((UpdateAction) action);
    // Copy
    action = new CopyAction(this, pasteAction);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    getUpdateCommandStackActions().add((UpdateAction) action);
    // Use Grid Action
    action = new ToggleGridEnabledAction();
    registry.registerAction(action);
    // Show Grid Action
    action = new ToggleGridVisibleAction();
    registry.registerAction(action);
    // Snap to Alignment Guides
    action = new ToggleSnapToAlignmentGuidesAction();
    registry.registerAction(action);
    // Ruler
    // IAction showRulers = new ToggleRulerVisibilityAction(getGraphicalViewer());
    // registry.registerAction(showRulers);
    action = new MatchWidthAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    action = new MatchHeightAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.LEFT);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.RIGHT);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.TOP);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.BOTTOM);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.CENTER);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.MIDDLE);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    // Default Size
    action = new DefaultEditPartSizeAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    getUpdateCommandStackActions().add((UpdateAction) action);
    // Reset Aspect Ratio
    action = new ResetAspectRatioAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    getUpdateCommandStackActions().add((UpdateAction) action);
    // Properties
    action = new PropertiesAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    // Fill Colour
    action = new FillColorAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    getUpdateCommandStackActions().add((UpdateAction) action);
    // Connection Line Width
    action = new ConnectionLineWidthAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    getUpdateCommandStackActions().add((UpdateAction) action);
    // Connection Line Color
    action = new LineColorAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    getUpdateCommandStackActions().add((UpdateAction) action);
    // Font
    action = new FontAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    getUpdateCommandStackActions().add((UpdateAction) action);
    // Font Colour
    action = new FontColorAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    getUpdateCommandStackActions().add((UpdateAction) action);
    // Opacity
    action = new OpacityAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    getUpdateCommandStackActions().add((UpdateAction) action);
    // Export As Image
    action = new ExportAsImageAction(viewer);
    registry.registerAction(action);
    // Export As Image to Clipboard
    action = new ExportAsImageToClipboardAction(viewer);
    registry.registerAction(action);
    // Connection Router types
    action = new ConnectionRouterAction.BendPointConnectionRouterAction(this);
    registry.registerAction(action);
    // Doesn't work with Connection to Connection
    // action = new ConnectionRouterAction.ShortestPathConnectionRouterAction(this);
    registry.registerAction(action);
    action = new ConnectionRouterAction.ManhattanConnectionRouterAction(this);
    registry.registerAction(action);
    // Send Backward
    action = new SendBackwardAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    getUpdateCommandStackActions().add((UpdateAction) action);
    // Bring Forward
    action = new BringForwardAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    getUpdateCommandStackActions().add((UpdateAction) action);
    // Send to Back
    action = new SendToBackAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    getUpdateCommandStackActions().add((UpdateAction) action);
    // Bring To Front
    action = new BringToFrontAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    getUpdateCommandStackActions().add((UpdateAction) action);
    // Text Alignment Actions
    for (TextAlignmentAction a : TextAlignmentAction.createActions(this)) {
        registry.registerAction(a);
        getSelectionActions().add(a.getId());
        getUpdateCommandStackActions().add(a);
    }
    // Text Position Actions
    for (TextPositionAction a : TextPositionAction.createActions(this)) {
        registry.registerAction(a);
        getSelectionActions().add(a.getId());
        getUpdateCommandStackActions().add(a);
    }
    // Lock Object
    action = new LockObjectAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    getUpdateCommandStackActions().add((UpdateAction) action);
    // Border Color
    action = new BorderColorAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    getUpdateCommandStackActions().add((UpdateAction) action);
    // Full Screen
    if (!PlatformUtils.isMac()) {
        action = new FullScreenAction(this);
        registry.registerAction(action);
    }
    // Select Element in Tree
    action = new SelectElementInTreeAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
}
Also used : MatchHeightAction(org.eclipse.gef.ui.actions.MatchHeightAction) ZoomOutAction(org.eclipse.gef.ui.actions.ZoomOutAction) ArrayList(java.util.ArrayList) LineColorAction(com.archimatetool.editor.diagram.actions.LineColorAction) ConnectionRouterAction(com.archimatetool.editor.diagram.actions.ConnectionRouterAction) TextPositionAction(com.archimatetool.editor.diagram.actions.TextPositionAction) FullScreenAction(com.archimatetool.editor.diagram.actions.FullScreenAction) ActionRegistry(org.eclipse.gef.ui.actions.ActionRegistry) PropertiesAction(com.archimatetool.editor.diagram.actions.PropertiesAction) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) ZoomNormalAction(com.archimatetool.editor.diagram.actions.ZoomNormalAction) DirectEditAction(org.eclipse.gef.ui.actions.DirectEditAction) ZoomInAction(org.eclipse.gef.ui.actions.ZoomInAction) MatchWidthAction(org.eclipse.gef.ui.actions.MatchWidthAction) FillColorAction(com.archimatetool.editor.diagram.actions.FillColorAction) SendToBackAction(com.archimatetool.editor.diagram.actions.SendToBackAction) ToggleGridEnabledAction(com.archimatetool.editor.diagram.actions.ToggleGridEnabledAction) BringForwardAction(com.archimatetool.editor.diagram.actions.BringForwardAction) ConnectionLineWidthAction(com.archimatetool.editor.diagram.actions.ConnectionLineWidthAction) TextAlignmentAction(com.archimatetool.editor.diagram.actions.TextAlignmentAction) IHandlerService(org.eclipse.ui.handlers.IHandlerService) SelectAllAction(com.archimatetool.editor.diagram.actions.SelectAllAction) ExportAsImageToClipboardAction(com.archimatetool.editor.diagram.actions.ExportAsImageToClipboardAction) OpacityAction(com.archimatetool.editor.diagram.actions.OpacityAction) ActionHandler(org.eclipse.jface.commands.ActionHandler) PrintDiagramAction(com.archimatetool.editor.diagram.actions.PrintDiagramAction) CutAction(com.archimatetool.editor.diagram.actions.CutAction) PasteSpecialAction(com.archimatetool.editor.diagram.actions.PasteSpecialAction) FontColorAction(com.archimatetool.editor.diagram.actions.FontColorAction) ResetAspectRatioAction(com.archimatetool.editor.diagram.actions.ResetAspectRatioAction) BringToFrontAction(com.archimatetool.editor.diagram.actions.BringToFrontAction) SelectElementInTreeAction(com.archimatetool.editor.diagram.actions.SelectElementInTreeAction) IAction(org.eclipse.jface.action.IAction) CopyAction(com.archimatetool.editor.diagram.actions.CopyAction) TextAlignmentAction(com.archimatetool.editor.diagram.actions.TextAlignmentAction) AlignmentAction(org.eclipse.gef.ui.actions.AlignmentAction) ToggleGridVisibleAction(com.archimatetool.editor.diagram.actions.ToggleGridVisibleAction) FontAction(com.archimatetool.editor.diagram.actions.FontAction) SendBackwardAction(com.archimatetool.editor.diagram.actions.SendBackwardAction) DefaultEditPartSizeAction(com.archimatetool.editor.diagram.actions.DefaultEditPartSizeAction) PasteAction(com.archimatetool.editor.diagram.actions.PasteAction) BorderColorAction(com.archimatetool.editor.diagram.actions.BorderColorAction) ZoomManager(org.eclipse.gef.editparts.ZoomManager) ToggleSnapToAlignmentGuidesAction(com.archimatetool.editor.diagram.actions.ToggleSnapToAlignmentGuidesAction) ExportAsImageAction(com.archimatetool.editor.diagram.actions.ExportAsImageAction) LockObjectAction(com.archimatetool.editor.diagram.actions.LockObjectAction)

Aggregations

IHandlerService (org.eclipse.ui.handlers.IHandlerService)102 ActionHandler (org.eclipse.jface.commands.ActionHandler)44 Action (org.eclipse.jface.action.Action)41 RefreshAction (org.netxms.ui.eclipse.actions.RefreshAction)25 IEvaluationContext (org.eclipse.core.expressions.IEvaluationContext)18 Command (org.eclipse.core.commands.Command)17 ICommandService (org.eclipse.ui.commands.ICommandService)17 ExecutionEvent (org.eclipse.core.commands.ExecutionEvent)15 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)14 AbstractHandler (org.eclipse.core.commands.AbstractHandler)10 ParameterizedCommand (org.eclipse.core.commands.ParameterizedCommand)9 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)9 SelectionEvent (org.eclipse.swt.events.SelectionEvent)9 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)9 IHandler (org.eclipse.core.commands.IHandler)8 EvaluationContext (org.eclipse.core.expressions.EvaluationContext)8 ArrayList (java.util.ArrayList)7 ExecutionException (org.eclipse.core.commands.ExecutionException)7 IAction (org.eclipse.jface.action.IAction)7 IContextService (org.eclipse.ui.contexts.IContextService)7