Package org.eclipse.core.commands

Examples of org.eclipse.core.commands.State


      command.define(name, tooltip, category, null);

      // TODO Decide the command state.
      final String style = readOptional(element, ATT_STYLE);
      if (STYLE_RADIO.equals(style)) {
        final State state = new RadioState();
        // TODO How to set the id?
        final boolean checked = readBoolean(element, ATT_STATE, false);
        state.setValue((checked) ? Boolean.TRUE : Boolean.FALSE);
        command.addState(IMenuStateIds.STYLE, state);

      } else if (STYLE_TOGGLE.equals(style)) {
        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);
      }
    }
    // this allows us to look up a "commandId" give the contributionId
    // and the actionId
View Full Code Here


    return null;
  }

  public final 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;
    }
View Full Code Here

  public final String getToolTipText() {
    return getDescription();
  }

  public final 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;
  }
View Full Code Here

      firePropertyChange(IAction.TEXT, oldText, newText);
    }
  }

  public final 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);
        }
      }
    }
  }
View Full Code Here

      }
    }
  }

  public final void setDescription(final String text) {
    final State state = command.getCommand().getState(
        INamedHandleStateIds.DESCRIPTION);
    if (state instanceof TextState) {
      final String currentValue = (String) state.getValue();
      if (!Util.equals(text, currentValue)) {
        state.setValue(text);
      }
    }
  }
View Full Code Here

  public final void setMenuCreator(final IMenuCreator creator) {
    // TODO Pulldown. This is complicated
  }

  public final void setText(final String text) {
    final State state = command.getCommand().getState(
        INamedHandleStateIds.NAME);
    if (state instanceof TextState) {
      final String currentValue = (String) state.getValue();
      if (!Util.equals(text, currentValue)) {
        state.setValue(text);
      }
    }
  }
View Full Code Here

        continue;
      }

      if (checkClass(stateElement, warningsToLog,
          "State must have an associated class", id)) { //$NON-NLS-1$
        final State state = new CommandStateProxy(stateElement,
            ATT_CLASS, PrefUtil.getInternalPreferenceStore(),
            CommandService.createPreferenceKey(command, id));
        command.addState(id, state);
      }
    }
View Full Code Here

    for (int i = 0; i < commands.length; i++) {
      final Command command = commands[i];
      final String[] stateIds = command.getStateIds();
      for (int j = 0; j < stateIds.length; j++) {
        final String stateId = stateIds[j];
        final State state = command.getState(stateId);
        if (state instanceof PersistentState) {
          final PersistentState persistentState = (PersistentState) state;
          if (persistentState.shouldPersist()) {
            persistentState.save(PrefUtil
                .getInternalPreferenceStore(),
View Full Code Here

  private boolean isLinkedWithEditor() {
    ICommandService service = (ICommandService) PlatformUI.getWorkbench()
        .getService(ICommandService.class);
    Command command = service.getCommand("org.eclipse.wst.xml.ui.cmnd.contentmodel.sych"); //$NON-NLS-1$
    State state = command.getState("org.eclipse.ui.commands.toggleState"); //$NON-NLS-1$

    return ((Boolean) state.getValue()).booleanValue();
  }
View Full Code Here

   
    @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();
    }
View Full Code Here

TOP

Related Classes of org.eclipse.core.commands.State

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.