@Override public void setValue(final Object value) { if (loadState()) { state.setValue(value); } }
@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); } } } }
@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); } } }
@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 void saveCurrentState(SelectInProgress selectInProgress) { State state = new State(); state.setValue(selectInProgress); state.setId(ID_SELECTS_IN_PROGRESS); addState(ID_SELECTS_IN_PROGRESS, state); }
/** * 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; }
state.setValue((checked) ? Boolean.TRUE : Boolean.FALSE); command.addState(IMenuStateIds.STYLE, state); final State state = new ToggleState(); final boolean checked = readBoolean(element, ATT_STATE, false); state.setValue((checked) ? Boolean.TRUE : Boolean.FALSE); command.addState(IMenuStateIds.STYLE, state);