Search in sources :

Example 36 with ICommandService

use of org.eclipse.ui.commands.ICommandService in project yamcs-studio by yamcs.

the class RCPUtils method runCommand.

public static void runCommand(String commandId) {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    ICommandService commandService = (ICommandService) window.getService(ICommandService.class);
    IEvaluationService evaluationService = (IEvaluationService) window.getService(IEvaluationService.class);
    try {
        Command cmd = commandService.getCommand(commandId);
        cmd.executeWithChecks(new ExecutionEvent(cmd, new HashMap<String, String>(), null, evaluationService.getCurrentState()));
    } catch (Exception exception) {
        log.log(Level.SEVERE, "Could not execute command " + commandId, exception);
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) Command(org.eclipse.core.commands.Command) HashMap(java.util.HashMap) ExecutionEvent(org.eclipse.core.commands.ExecutionEvent) ICommandService(org.eclipse.ui.commands.ICommandService) IEvaluationService(org.eclipse.ui.services.IEvaluationService)

Example 37 with ICommandService

use of org.eclipse.ui.commands.ICommandService in project yamcs-studio by yamcs.

the class EventLog method updateState.

private void updateState() {
    ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
    Command command = service.getCommand(EventLog.CMD_SCROLL_LOCK);
    State state = command.getState(EventLog.STATE_SCROLL_LOCK);
    enableScrollLock((Boolean) state.getValue());
}
Also used : Command(org.eclipse.core.commands.Command) State(org.eclipse.core.commands.State) ICommandService(org.eclipse.ui.commands.ICommandService)

Example 38 with ICommandService

use of org.eclipse.ui.commands.ICommandService in project yamcs-studio by yamcs.

the class ScrollLockHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchPart part = HandlerUtil.getActivePartChecked(event);
    EventLogView view = (EventLogView) part;
    ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
    Command command = service.getCommand(EventLog.CMD_SCROLL_LOCK);
    boolean oldState = HandlerUtil.toggleCommandState(command);
    view.getEventLog().enableScrollLock(!oldState);
    return null;
}
Also used : IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) Command(org.eclipse.core.commands.Command) ICommandService(org.eclipse.ui.commands.ICommandService)

Aggregations

ICommandService (org.eclipse.ui.commands.ICommandService)38 Command (org.eclipse.core.commands.Command)24 IHandlerService (org.eclipse.ui.handlers.IHandlerService)8 ExecutionEvent (org.eclipse.core.commands.ExecutionEvent)7 IEvaluationContext (org.eclipse.core.expressions.IEvaluationContext)7 ParameterizedCommand (org.eclipse.core.commands.ParameterizedCommand)6 NotDefinedException (org.eclipse.core.commands.common.NotDefinedException)6 ExecutionException (org.eclipse.core.commands.ExecutionException)4 EvaluationContext (org.eclipse.core.expressions.EvaluationContext)4 IEvaluationService (org.eclipse.ui.services.IEvaluationService)4 HashMap (java.util.HashMap)3 NotEnabledException (org.eclipse.core.commands.NotEnabledException)3 NotHandledException (org.eclipse.core.commands.NotHandledException)3 State (org.eclipse.core.commands.State)3 ISelection (org.eclipse.jface.viewers.ISelection)3 StyledText (org.eclipse.swt.custom.StyledText)3 Composite (org.eclipse.swt.widgets.Composite)3 Test (org.junit.Test)3 IXliffEditor (net.heartsome.cat.ts.ui.editors.IXliffEditor)2 IHandler (org.eclipse.core.commands.IHandler)2