コード例 #1
0
 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);
     }
   }
 }
コード例 #2
0
 /** Selection changed... */
 protected void handleSelectionChanged() {
   final Object newValue = doGetValue();
   if (Util.equals(myCurrentValue, newValue)) return;
   fireValueChange(Diffs.createValueDiff(myCurrentValue, myCurrentValue = newValue));
 }
コード例 #3
0
  public final void setActionDefinitionId(final String id) {
    // Get the old values.
    final boolean oldChecked = isChecked();
    final String oldDescription = getDescription();
    final boolean oldEnabled = isEnabled();
    final boolean oldHandled = isHandled();
    final ImageDescriptor oldDefaultImage = getImageDescriptor();
    final ImageDescriptor oldDisabledImage = getDisabledImageDescriptor();
    final ImageDescriptor oldHoverImage = getHoverImageDescriptor();
    final String oldText = getText();

    // Update the command.
    final Command oldBaseCommand = command.getCommand();
    oldBaseCommand.removeCommandListener(commandListener);
    final ICommandService commandService =
        (ICommandService) serviceLocator.getService(ICommandService.class);
    final Command newBaseCommand = commandService.getCommand(id);
    command = new ParameterizedCommand(newBaseCommand, null);
    newBaseCommand.addCommandListener(commandListener);

    // Get the new values.
    final boolean newChecked = isChecked();
    final String newDescription = getDescription();
    final boolean newEnabled = isEnabled();
    final boolean newHandled = isHandled();
    final ImageDescriptor newDefaultImage = getImageDescriptor();
    final ImageDescriptor newDisabledImage = getDisabledImageDescriptor();
    final ImageDescriptor newHoverImage = getHoverImageDescriptor();
    final String newText = getText();

    // Fire property change events, as necessary.
    if (newChecked != oldChecked) {
      if (oldChecked) {
        firePropertyChange(IAction.CHECKED, Boolean.TRUE, Boolean.FALSE);
      } else {
        firePropertyChange(IAction.CHECKED, Boolean.FALSE, Boolean.TRUE);
      }
    }

    if (!Util.equals(oldDescription, newDescription)) {
      firePropertyChange(IAction.DESCRIPTION, oldDescription, newDescription);
      firePropertyChange(IAction.TOOL_TIP_TEXT, oldDescription, newDescription);
    }

    if (newEnabled != oldEnabled) {
      if (oldEnabled) {
        firePropertyChange(IAction.ENABLED, Boolean.TRUE, Boolean.FALSE);
      } else {
        firePropertyChange(IAction.ENABLED, Boolean.FALSE, Boolean.TRUE);
      }
    }

    if (newHandled != oldHandled) {
      if (oldHandled) {
        firePropertyChange(IAction.HANDLED, Boolean.TRUE, Boolean.FALSE);
      } else {
        firePropertyChange(IAction.HANDLED, Boolean.FALSE, Boolean.TRUE);
      }
    }

    if (!Util.equals(oldDefaultImage, newDefaultImage)) {
      firePropertyChange(IAction.IMAGE, oldDefaultImage, newDefaultImage);
    }

    if (!Util.equals(oldDisabledImage, newDisabledImage)) {
      firePropertyChange(IAction.IMAGE, oldDisabledImage, newDisabledImage);
    }

    if (!Util.equals(oldHoverImage, newHoverImage)) {
      firePropertyChange(IAction.IMAGE, oldHoverImage, newHoverImage);
    }

    if (!Util.equals(oldText, newText)) {
      firePropertyChange(IAction.TEXT, oldText, newText);
    }
  }