Search in sources :

Example 16 with ParameterizedCommand

use of org.eclipse.core.commands.ParameterizedCommand in project translationstudio8 by heartsome.

the class KeyAssistHandler method execute.

public Object execute(ExecutionEvent event) throws ExecutionException {
    final IWorkbench workbench = PlatformUI.getWorkbench();
    IBindingService bindingService = (IBindingService) workbench.getService(IBindingService.class);
    BindingService service = (BindingService) bindingService;
    ArrayList<Binding> lstBinding = new ArrayList<Binding>(Arrays.asList(bindingService.getBindings()));
    List<String> lstRemove = Constants.lstRemove;
    Iterator<Binding> it = lstBinding.iterator();
    while (it.hasNext()) {
        Binding binding = it.next();
        ParameterizedCommand pCommand = binding.getParameterizedCommand();
        if (pCommand == null || lstRemove.contains(pCommand.getCommand().getId())) {
            it.remove();
        }
    }
    service.getKeyboard().openKeyAssistShell(lstBinding);
    return null;
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) Binding(org.eclipse.jface.bindings.Binding) IBindingService(org.eclipse.ui.keys.IBindingService) BindingService(org.eclipse.ui.internal.keys.BindingService) ArrayList(java.util.ArrayList) IBindingService(org.eclipse.ui.keys.IBindingService) ParameterizedCommand(org.eclipse.core.commands.ParameterizedCommand)

Example 17 with ParameterizedCommand

use of org.eclipse.core.commands.ParameterizedCommand in project eclipse.platform.text by eclipse.

the class ShowInSystemExplorerHyperlink method open.

@Override
public void open() {
    ECommandService commandService = PlatformUI.getWorkbench().getService(ECommandService.class);
    EHandlerService handlerService = PlatformUI.getWorkbench().getService(EHandlerService.class);
    Command command = commandService.getCommand(ShowInSystemExplorerHandler.ID);
    if (command.isDefined()) {
        ParameterizedCommand parameterizedCommand = commandService.createCommand(ShowInSystemExplorerHandler.ID, Collections.singletonMap(ShowInSystemExplorerHandler.RESOURCE_PATH_PARAMETER, fileLocation));
        if (handlerService.canExecute(parameterizedCommand)) {
            handlerService.executeHandler(parameterizedCommand);
        }
    }
}
Also used : EHandlerService(org.eclipse.e4.core.commands.EHandlerService) ParameterizedCommand(org.eclipse.core.commands.ParameterizedCommand) Command(org.eclipse.core.commands.Command) ParameterizedCommand(org.eclipse.core.commands.ParameterizedCommand) ECommandService(org.eclipse.e4.core.commands.ECommandService)

Aggregations

ParameterizedCommand (org.eclipse.core.commands.ParameterizedCommand)17 Binding (org.eclipse.jface.bindings.Binding)11 KeyBinding (org.eclipse.jface.bindings.keys.KeyBinding)9 Command (org.eclipse.core.commands.Command)7 BindingElement (org.eclipse.ui.internal.keys.model.BindingElement)7 ICommandService (org.eclipse.ui.commands.ICommandService)6 Iterator (java.util.Iterator)4 NotDefinedException (org.eclipse.core.commands.common.NotDefinedException)4 IHandlerService (org.eclipse.ui.handlers.IHandlerService)4 ArrayList (java.util.ArrayList)3 Collection (java.util.Collection)3 EvaluationContext (org.eclipse.core.expressions.EvaluationContext)3 IEvaluationContext (org.eclipse.core.expressions.IEvaluationContext)3 IBindingService (org.eclipse.ui.keys.IBindingService)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 Set (java.util.Set)2 TriggerSequence (org.eclipse.jface.bindings.TriggerSequence)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2