Search in sources :

Example 1 with State

use of org.eclipse.core.commands.State in project gfm_viewer by satyagraha.

the class ViewerSupportDefault method isLinked.

@Override
public boolean isLinked() {
    LOGGER.fine("");
    Command command = commandService.getCommand(GFM_VIEWER_PLUGIN_LINKED);
    State state = command.getState(RegistryToggleState.STATE_ID);
    return (Boolean) state.getValue();
}
Also used : Command(org.eclipse.core.commands.Command) RegistryToggleState(org.eclipse.ui.handlers.RegistryToggleState) State(org.eclipse.core.commands.State)

Example 2 with State

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

the class CommandsPropertyTester method test.

public boolean test(final Object receiver, final String property, final Object[] args, final Object expectedValue) {
    if (receiver instanceof IServiceLocator && args.length == 1 && args[0] instanceof String) {
        final IServiceLocator locator = (IServiceLocator) receiver;
        if (TOGGLE_PROPERTY_NAME.equals(property)) {
            final String commandId = args[0].toString();
            final ICommandService commandService = (ICommandService) locator.getService(ICommandService.class);
            final Command command = commandService.getCommand(commandId);
            final State state = command.getState(RegistryToggleState.STATE_ID);
            if (state != null) {
                return state.getValue().equals(expectedValue);
            }
        }
    }
    return false;
}
Also used : Command(org.eclipse.core.commands.Command) RegistryToggleState(org.eclipse.ui.handlers.RegistryToggleState) State(org.eclipse.core.commands.State) IServiceLocator(org.eclipse.ui.services.IServiceLocator) ICommandService(org.eclipse.ui.commands.ICommandService)

Example 3 with State

use of org.eclipse.core.commands.State in project gfm_viewer by satyagraha.

the class ViewerSupportDefault method isOnline.

@Override
public boolean isOnline() {
    LOGGER.fine("");
    Command command = commandService.getCommand(GFM_VIEWER_PLUGIN_ONLINE);
    State state = command.getState(RegistryToggleState.STATE_ID);
    return (Boolean) state.getValue();
}
Also used : Command(org.eclipse.core.commands.Command) RegistryToggleState(org.eclipse.ui.handlers.RegistryToggleState) State(org.eclipse.core.commands.State)

Example 4 with State

use of org.eclipse.core.commands.State in project yamcs-studio by yamcs.

the class SwitchProcessorHandler method updateElement.

/*
     * Workaround to allow checking radio items in a dynamic contribution
     *
     * https://bugs.eclipse.org/bugs/show_bug.cgi?id=398647
     */
@Override
public void updateElement(UIElement element, @SuppressWarnings("rawtypes") Map parameters) {
    ICommandService service = (ICommandService) element.getServiceLocator().getService(ICommandService.class);
    String state = (String) parameters.get(RadioState.PARAMETER_ID);
    Command command = service.getCommand(SwitchProcessorCompoundContributionItem.SWITCH_PROCESSOR_COMMAND);
    State commandState = command.getState(RadioState.STATE_ID);
    if (commandState.getValue().equals(state)) {
        element.setChecked(true);
    }
}
Also used : Command(org.eclipse.core.commands.Command) RadioState(org.eclipse.ui.handlers.RadioState) State(org.eclipse.core.commands.State) ICommandService(org.eclipse.ui.commands.ICommandService)

Example 5 with State

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

Aggregations

Command (org.eclipse.core.commands.Command)5 State (org.eclipse.core.commands.State)5 ICommandService (org.eclipse.ui.commands.ICommandService)3 RegistryToggleState (org.eclipse.ui.handlers.RegistryToggleState)3 RadioState (org.eclipse.ui.handlers.RadioState)1 IServiceLocator (org.eclipse.ui.services.IServiceLocator)1