Search in sources :

Example 31 with Command

use of org.eclipse.core.commands.Command 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

Command (org.eclipse.core.commands.Command)31 ICommandService (org.eclipse.ui.commands.ICommandService)24 IHandlerService (org.eclipse.ui.handlers.IHandlerService)8 ExecutionEvent (org.eclipse.core.commands.ExecutionEvent)7 ParameterizedCommand (org.eclipse.core.commands.ParameterizedCommand)7 NotDefinedException (org.eclipse.core.commands.common.NotDefinedException)7 IEvaluationContext (org.eclipse.core.expressions.IEvaluationContext)7 State (org.eclipse.core.commands.State)5 HashMap (java.util.HashMap)4 ExecutionException (org.eclipse.core.commands.ExecutionException)4 EvaluationContext (org.eclipse.core.expressions.EvaluationContext)4 IEvaluationService (org.eclipse.ui.services.IEvaluationService)4 NotEnabledException (org.eclipse.core.commands.NotEnabledException)3 NotHandledException (org.eclipse.core.commands.NotHandledException)3 Test (org.junit.Test)3 Binding (org.eclipse.jface.bindings.Binding)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2 IWorkbench (org.eclipse.ui.IWorkbench)2 RegistryToggleState (org.eclipse.ui.handlers.RegistryToggleState)2