Example #1
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;
  }