protected String getInputControlDisplayName() {
   String type = getInputControlType();
   String displayName = null;
   if (CONTROL_TYPE_CHOICE_SET.findChoice(type) != null) {
     displayName = CONTROL_TYPE_CHOICE_SET.findChoice(type).getDisplayName();
   } else {
     if (ParameterDialog.PARAM_CONTROL_COMBO.equals(type)) {
       displayName = ParameterDialog.DISPLAY_NAME_CONTROL_COMBO;
     } else if (ParameterDialog.PARAM_CONTROL_LIST.equals(type)) {
       displayName = ParameterDialog.DISPLAY_NAME_CONTROL_LIST;
     }
   }
   return displayName;
 }
示例#2
0
  /**
   * Gets choice array of the given choise set.
   *
   * @param set The given choice set.
   * @return String[][]: The choice array of the key, which contains he names (labels) and
   *     underlying values, will be arranged as: { {name1, value1}, {name2, value2}, ...}
   */
  private String[][] getChoiceArray(IChoiceSet set, boolean addAuto) {
    IChoice[] choices = set.getChoices();

    String[][] names = null;

    if (choices.length > 0) {
      int offset = 0;

      if (addAuto) {
        offset = 1;

        names = new String[choices.length + 1][2];
        names[0][0] = ChoiceSetFactory.CHOICE_AUTO;
        names[0][1] = ""; // $NON-NLS-1$
      } else {
        names = new String[choices.length][2];
      }

      for (int i = 0; i < choices.length; i++) {
        names[i + offset][0] = choices[i].getDisplayName();
        names[i + offset][1] = choices[i].getName();
      }
    } else if (addAuto) {
      names =
          new String[][] {
            {
              ChoiceSetFactory.CHOICE_AUTO, "" // $NON-NLS-1$
            }
          };
    }

    return names;
  }
  protected void inwardUpdate() {
    String[] choices = new String[4];

    String originalSelection = controlTypeChooser.getText();
    if (DesignChoiceConstants.PARAM_TYPE_BOOLEAN.equals(getDataType())) {
      choices[0] =
          CONTROL_TYPE_CHOICE_SET
              .findChoice(DesignChoiceConstants.PARAM_CONTROL_CHECK_BOX)
              .getDisplayName();
    } else {
      choices[0] =
          CONTROL_TYPE_CHOICE_SET
              .findChoice(DesignChoiceConstants.PARAM_CONTROL_TEXT_BOX)
              .getDisplayName();
    }
    choices[1] = ParameterDialog.DISPLAY_NAME_CONTROL_COMBO;
    choices[2] = ParameterDialog.DISPLAY_NAME_CONTROL_LIST;

    choices[3] =
        CONTROL_TYPE_CHOICE_SET
            .findChoice(DesignChoiceConstants.PARAM_CONTROL_RADIO_BUTTON)
            .getDisplayName();

    controlTypeChooser.setItems(choices);
    if (originalSelection.length() == 0) { // initialize
      controlTypeChooser.setText(getInputControlDisplayName());
    } else {
      int index = controlTypeChooser.indexOf(originalSelection);
      if (index == -1) { // The original control type cannot be
        // supported
        controlTypeChooser.select(0);
        controlTypeChooser.notifyListeners(SWT.Selection, new Event());
      }
      controlTypeChooser.setText(originalSelection);
    }
  }
  public void setColorValue(String value) {
    predefinedColor = null;
    if (choiceSet != null) {
      IChoice choice = choiceSet.findChoice(value);
      if (choice != null) {
        predefinedColor = choice.getDisplayName();
      }
    }

    int[] rgbValues = ColorUtil.getRGBs(value);
    if (rgbValues == null) {
      setRGB(null);
    } else {
      setRGB(new RGB(rgbValues[0], rgbValues[1], rgbValues[2]));
    }
  }
 protected void outwardUpdate() {
   String displayText = controlTypeChooser.getText();
   if (StringUtil.isBlank(displayText)) {
     return;
   }
   if (ParameterDialog.DISPLAY_NAME_CONTROL_COMBO.equals(displayText)) {
     this.setProperty(ParameterDialog.CONTROLTYPE_VALUE, ParameterDialog.PARAM_CONTROL_COMBO);
     return;
   }
   if (ParameterDialog.DISPLAY_NAME_CONTROL_LIST.equals(displayText)) {
     this.setProperty(ParameterDialog.CONTROLTYPE_VALUE, ParameterDialog.PARAM_CONTROL_LIST);
     return;
   }
   this.setProperty(
       ParameterDialog.CONTROLTYPE_VALUE,
       CONTROL_TYPE_CHOICE_SET.findChoiceByDisplayName(displayText).getName());
 }