@Override public int getStyle() { // TODO Pulldown. This does not currently support the pulldown style. final State state = command.getCommand().getState(IMenuStateIds.STYLE); if (state instanceof RadioState) { return IAction.AS_RADIO_BUTTON; } else if (state instanceof ToggleState) { return IAction.AS_CHECK_BOX; } return IAction.AS_PUSH_BUTTON; }
@Override public void dispose() { commandPersistence.dispose(); /* * All state on all commands neeeds to be disposed. This is so that the * state has a chance to persist any changes. */ final Command[] commands = commandManager.getAllCommands(); for (final Command command : commands) { final String[] stateIds = command.getStateIds(); for (final String stateId : stateIds) { final State state = command.getState(stateId); if (state instanceof PersistentState) { final PersistentState persistentState = (PersistentState) state; if (persistentState.shouldPersist()) { persistentState.save(PrefUtil .getInternalPreferenceStore(), createPreferenceKey(command, stateId)); } } } } commandCallbacks = null; }
@Override public boolean isChecked() { final State state = command.getCommand().getState(IMenuStateIds.STYLE); if (state instanceof ToggleState) { final Boolean currentValue = (Boolean) state.getValue(); return currentValue.booleanValue(); } return false; }
@Override public void setDescription(final String text) { final State state = command.getCommand().getState( INamedHandleStateIds.DESCRIPTION); if (state instanceof TextState) { final String currentValue = (String) state.getValue(); if (!Objects.equals(text, currentValue)) { state.setValue(text); } } }
Command command = csrv .getCommand("org.eclipse.egit.ui.RepositoriesLinkWithSelection"); //$NON-NLS-1$ reactOnSelection = (Boolean) command.getState( RegistryToggleState.STATE_ID).getValue();
@Override public void setText(final String text) { final State state = command.getCommand().getState( INamedHandleStateIds.NAME); if (state instanceof TextState) { final String currentValue = (String) state.getValue(); if (!Objects.equals(text, currentValue)) { state.setValue(text); } } }
/** * Updates the radio state of the command to the given value * * @param command * the command whose state should be updated * @param newState * the new state * * @throws ExecutionException * When the command doesn't have a radio state * @since 3.5 */ public static void updateRadioState(Command command, String newState) throws ExecutionException { State state = command.getState(RadioState.STATE_ID); if (state == null) throw new ExecutionException("The command does not have a radio state"); //$NON-NLS-1$ state.setValue(newState); }
private String getLockToolbarsText() { ECommandService commandService = context.get(ECommandService.class); Command command = commandService.getCommand(LOCK_TOOLBAR_CMD_ID); State state = command.getState(STATE_ID); if ((state != null) && (state.getValue() instanceof Boolean)) { boolean enabled = ((Boolean) state.getValue()).booleanValue(); return (enabled) ? Messages.ToolBarManagerRenderer_UnlockToolbars : Messages.ToolBarManagerRenderer_LockToolbars; } return Messages.ToolBarManagerRenderer_ToggleLockToolbars; }
@Override public void setChecked(final boolean checked) { final State state = command.getCommand().getState(IMenuStateIds.STYLE); if (state instanceof ToggleState) { final Boolean currentValue = (Boolean) state.getValue(); if (checked != currentValue.booleanValue()) { if (checked) { state.setValue(Boolean.TRUE); } else { state.setValue(Boolean.FALSE); } } } }
/** * Constructs a repositories view label provider */ public RepositoriesViewLabelProvider() { ICommandService srv = (ICommandService) PlatformUI.getWorkbench() .getService(ICommandService.class); verboseBranchModeState = srv.getCommand(ToggleBranchCommitCommand.ID) .getState(ToggleBranchCommitCommand.TOGGLE_STATE); verboseBranchModeState.addListener(this); try { this.verboseBranchMode = ((Boolean) verboseBranchModeState .getValue()).booleanValue(); } catch (Exception e) { Activator.logError(e.getMessage(), e); } }
/** * Toggles the command's state. * * @param command The command whose state needs to be toggled * @return the original value before toggling * * @throws ExecutionException * When the command doesn't contain the toggle state or when the state doesn't contain a boolean value * * @since 3.5 */ public static boolean toggleCommandState(Command command) throws ExecutionException { State state = command.getState(RegistryToggleState.STATE_ID); if(state == null) throw new ExecutionException("The command does not have a toggle state"); //$NON-NLS-1$ if(!(state.getValue() instanceof Boolean)) throw new ExecutionException("The command's toggle state doesn't contain a boolean value"); //$NON-NLS-1$ boolean oldValue = ((Boolean) state.getValue()).booleanValue(); state.setValue(Boolean.valueOf(!oldValue)); return oldValue; }
/** * Constructs this instance */ public RepositoriesViewContentProvider() { ICommandService srv = (ICommandService) PlatformUI.getWorkbench() .getService(ICommandService.class); commandState = srv.getCommand( ToggleBranchHierarchyCommand.ID) .getState(ToggleBranchHierarchyCommand.TOGGLE_STATE); commandState.addListener(this); try { this.branchHierarchyMode = ((Boolean) commandState.getValue()) .booleanValue(); } catch (Exception e) { Activator.handleError(e.getMessage(), e, false); } }
public Object execute(final ExecutionEvent event) throws ExecutionException { Command command = event.getCommand(); HandlerUtil.toggleCommandState(command); @SuppressWarnings("boxing") boolean test = (Boolean) command.getState(RegistryToggleState.STATE_ID).getValue(); getView(event).setReactOnSelection(test); return null; } }
/** * Checks whether the radio state of the command is same as the radio state * parameter's value * * @param event * The execution event that contains the application context * @return <code>true</code> whe the values are same, <code>false</code> * otherwise * * @throws ExecutionException * When the command doesn't have the radio state or the event * doesn't have the radio state parameter * @since 3.5 */ public static boolean matchesRadioState(ExecutionEvent event) throws ExecutionException { String parameter = event.getParameter(RadioState.PARAMETER_ID); if (parameter == null) throw new ExecutionException( "The event does not have the radio state parameter"); //$NON-NLS-1$ Command command = event.getCommand(); State state = command.getState(RadioState.STATE_ID); if (state == null) throw new ExecutionException("The command does not have a radio state"); //$NON-NLS-1$ if (!(state.getValue() instanceof String)) throw new ExecutionException("The command's radio state doesn't contain a String value"); //$NON-NLS-1$ return parameter.equals(state.getValue()); }
@SuppressWarnings("boxing") @Override public void createPartControl(Composite aParent) { Composite displayArea = new Composite(aParent, SWT.NONE); layout = new StackLayout(); displayArea.setLayout(layout); createEmptyArea(displayArea); super.createPartControl(displayArea); IWorkbenchWindow w = PlatformUI.getWorkbench() .getActiveWorkbenchWindow(); ICommandService csrv = (ICommandService) w .getService(ICommandService.class); Command command = csrv .getCommand("org.eclipse.egit.ui.RepositoriesLinkWithSelection"); //$NON-NLS-1$ reactOnSelection = (Boolean) command.getState( RegistryToggleState.STATE_ID).getValue(); IWorkbenchSiteProgressService service = (IWorkbenchSiteProgressService) getSite() .getService(IWorkbenchSiteProgressService.class); if (service != null) { service.showBusyForFamily(JobFamilies.REPO_VIEW_REFRESH); service.showBusyForFamily(JobFamilies.CLONE); } }
if (command.getState(id) == null) { final State state = new CommandStateProxy(stateElement, ATT_CLASS, PrefUtil.getInternalPreferenceStore(),