Search in sources :

Example 11 with TriggerSequence

use of org.eclipse.jface.bindings.TriggerSequence in project eclipse.platform.text by eclipse.

the class ContentAssistHandler method installCueLabelProvider.

/**
 * Create and install the {@link LabelProvider} for fContentAssistSubjectAdapter.
 */
private void installCueLabelProvider() {
    ILabelProvider labelProvider = new LabelProvider() {

        @Override
        public String getText(Object element) {
            IBindingService bindingService = PlatformUI.getWorkbench().getAdapter(IBindingService.class);
            TriggerSequence[] activeBindings = bindingService.getActiveBindingsFor(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
            if (activeBindings.length == 0)
                return ContentAssistMessages.ContentAssistHandler_contentAssistAvailable;
            return NLSUtility.format(ContentAssistMessages.ContentAssistHandler_contentAssistAvailableWithKeyBinding, activeBindings[0].format());
        }
    };
    fContentAssistSubjectAdapter.setContentAssistCueProvider(labelProvider);
}
Also used : TriggerSequence(org.eclipse.jface.bindings.TriggerSequence) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) LabelProvider(org.eclipse.jface.viewers.LabelProvider) IBindingService(org.eclipse.ui.keys.IBindingService)

Example 12 with TriggerSequence

use of org.eclipse.jface.bindings.TriggerSequence in project webtools.sourceediting by eclipse.

the class CodeAssistCyclingConfigurationBlock method getKeyboardShortcut.

private static String getKeyboardShortcut(ParameterizedCommand command) {
    IBindingService bindingService = PlatformUI.getWorkbench().getAdapter(IBindingService.class);
    fgLocalBindingManager.setBindings(bindingService.getBindings());
    try {
        Scheme activeScheme = bindingService.getActiveScheme();
        if (activeScheme != null)
            fgLocalBindingManager.setActiveScheme(activeScheme);
    } catch (NotDefinedException e) {
        Logger.logException(e);
    }
    TriggerSequence[] bindings = fgLocalBindingManager.getActiveBindingsDisregardingContextFor(command);
    if (bindings.length > 0)
        return bindings[0].format();
    return null;
}
Also used : TriggerSequence(org.eclipse.jface.bindings.TriggerSequence) Scheme(org.eclipse.jface.bindings.Scheme) NotDefinedException(org.eclipse.core.commands.common.NotDefinedException) IBindingService(org.eclipse.ui.keys.IBindingService)

Example 13 with TriggerSequence

use of org.eclipse.jface.bindings.TriggerSequence in project webtools.servertools by eclipse.

the class ServerActionProvider method addTopSection.

protected void addTopSection(IMenuManager menu, IServer server, IModule[] module) {
    MenuManager newMenu = new MenuManager(Messages.actionNew, NEW_MENU_ID);
    IAction newServerAction = new NewServerWizardAction();
    newServerAction.setText(Messages.actionNewServer);
    newMenu.add(newServerAction);
    menu.add(newMenu);
    // open action
    if (server != null && module == null) {
        menu.add(openAction);
        String text = Messages.actionShowIn;
        final IWorkbench workbench = PlatformUI.getWorkbench();
        final IBindingService bindingService = (IBindingService) workbench.getAdapter(IBindingService.class);
        final TriggerSequence[] activeBindings = bindingService.getActiveBindingsFor(SHOW_IN_MENU_ID);
        if (activeBindings.length > 0) {
            text += "\t" + activeBindings[0].format();
        }
        MenuManager showInMenu = new MenuManager(text, SHOW_IN_MENU_ID);
        showInMenu.add(showInConsoleAction);
        showInMenu.add(showInDebugAction);
        menu.add(showInMenu);
    }
}
Also used : TriggerSequence(org.eclipse.jface.bindings.TriggerSequence) NewServerWizardAction(org.eclipse.wst.server.ui.internal.actions.NewServerWizardAction) IBindingService(org.eclipse.ui.keys.IBindingService)

Example 14 with TriggerSequence

use of org.eclipse.jface.bindings.TriggerSequence in project webtools.servertools by eclipse.

the class ServersView method fillContextMenu.

protected void fillContextMenu(Shell shell, IMenuManager menu) {
    // get selection but avoid no selection or multiple selection
    IServer server = null;
    IModule[] module = null;
    IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
    if (!selection.isEmpty()) {
        Iterator iterator = selection.iterator();
        Object obj = iterator.next();
        if (obj instanceof IServer)
            server = (IServer) obj;
        if (obj instanceof ModuleServer) {
            ModuleServer ms = (ModuleServer) obj;
            server = ms.server;
            module = ms.module;
        }
        if (iterator.hasNext()) {
            server = null;
            module = null;
        }
    }
    // new action
    MenuManager newMenu = new MenuManager(Messages.actionNew);
    fillNewContextMenu(null, selection, newMenu);
    menu.add(newMenu);
    // open action
    if (server != null && module == null) {
        menu.add(openAction);
        String text = Messages.actionShowIn;
        final IWorkbench workbench = PlatformUI.getWorkbench();
        final IBindingService bindingService = (IBindingService) workbench.getAdapter(IBindingService.class);
        final TriggerSequence[] activeBindings = bindingService.getActiveBindingsFor("org.eclipse.ui.navigate.showInQuickMenu");
        if (activeBindings.length > 0) {
            text += "\t" + activeBindings[0].format();
        }
        MenuManager showInMenu = new MenuManager(text);
        showInMenu.add(showInConsoleAction);
        showInMenu.add(showInDebugAction);
        // IActionBars actionBars = getViewSite().getActionBars();
        // actionBars.setGlobalActionHandler("group.show", showInMenu);
        menu.add(showInMenu);
        menu.add(new Separator());
    } else
        menu.add(new Separator());
    if (server != null) {
        if (module == null) {
            menu.add(copyAction);
            menu.add(pasteAction);
            menu.add(deleteAction);
            menu.add(renameAction);
        } else if (module.length == 1)
            menu.add(new RemoveModuleAction(shell, server, module[0]));
        menu.add(new Separator());
    }
    if (server != null && module == null) {
        // server actions
        for (int i = 0; i < actions.length; i++) menu.add(actions[i]);
        menu.add(new Separator());
        menu.add(actionModifyModules);
        // monitor
        if (server.getServerType() != null) {
            final MenuManager menuManager = new MenuManager(Messages.actionMonitor);
            final IServer server2 = server;
            final Shell shell2 = shell;
            menuManager.addMenuListener(new IMenuListener() {

                public void menuAboutToShow(IMenuManager manager) {
                    menuManager.removeAll();
                    if (server2.getAdapter(ServerDelegate.class) != null) {
                        ServerPort[] ports = server2.getServerPorts(null);
                        if (ports != null) {
                            int size = ports.length;
                            for (int i = 0; i < size; i++) {
                                if (!ports[i].isAdvanced())
                                    menuManager.add(new MonitorServerPortAction(shell2, server2, ports[i]));
                            }
                        }
                    }
                    if (menuManager.isEmpty())
                        menuManager.add(noneAction);
                    menuManager.add(new Separator());
                    menuManager.add(monitorPropertiesAction);
                }
            });
            // add an initial menu item so that the menu appears correctly
            noneAction.setEnabled(false);
            menuManager.add(noneAction);
            menu.add(menuManager);
        }
    }
    if (server != null && module != null) {
        menu.add(new Separator());
        menu.add(new StartModuleAction(server, module));
        menu.add(new StopModuleAction(server, module));
        menu.add(new RestartModuleAction(server, module));
    }
    menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
    menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS + "-end"));
    if (server != null) {
        menu.add(new Separator());
        menu.add(propertiesAction);
    }
}
Also used : TriggerSequence(org.eclipse.jface.bindings.TriggerSequence) Point(org.eclipse.swt.graphics.Point) Iterator(java.util.Iterator) IBindingService(org.eclipse.ui.keys.IBindingService)

Example 15 with TriggerSequence

use of org.eclipse.jface.bindings.TriggerSequence in project sts4 by spring-projects.

the class GotoSymbolHandler method getKeybindings.

private String getKeybindings(ExecutionEvent event) {
    Command invokingCommand = event.getCommand();
    IBindingService service = PlatformUI.getWorkbench().getService(IBindingService.class);
    TriggerSequence[] bindings = service.getActiveBindingsFor(invokingCommand.getId());
    if (bindings != null && bindings.length > 0) {
        return bindings[0].toString();
    }
    return null;
}
Also used : TriggerSequence(org.eclipse.jface.bindings.TriggerSequence) Command(org.eclipse.core.commands.Command) IBindingService(org.eclipse.ui.keys.IBindingService)

Aggregations

TriggerSequence (org.eclipse.jface.bindings.TriggerSequence)17 IBindingService (org.eclipse.ui.keys.IBindingService)13 KeySequence (org.eclipse.jface.bindings.keys.KeySequence)7 Binding (org.eclipse.jface.bindings.Binding)4 Iterator (java.util.Iterator)3 Command (org.eclipse.core.commands.Command)3 ParameterizedCommand (org.eclipse.core.commands.ParameterizedCommand)3 NotDefinedException (org.eclipse.core.commands.common.NotDefinedException)3 KeyStroke (org.eclipse.jface.bindings.keys.KeyStroke)3 ArrayList (java.util.ArrayList)2 ParseException (org.eclipse.jface.bindings.keys.ParseException)2 VerifyKeyListener (org.eclipse.swt.custom.VerifyKeyListener)2 VerifyEvent (org.eclipse.swt.events.VerifyEvent)2 Point (org.eclipse.swt.graphics.Point)2 ICommandService (org.eclipse.ui.commands.ICommandService)2 Nullable (org.jkiss.code.Nullable)2 Collection (java.util.Collection)1 MultipleCompilationErrorsException (org.codehaus.groovy.control.MultipleCompilationErrorsException)1 SyntaxException (org.codehaus.groovy.syntax.SyntaxException)1 Scheme (org.eclipse.jface.bindings.Scheme)1