コード例 #1
0
ファイル: MiComboBox.java プロジェクト: justacoder/mica
  public void setValue(String value) {
    if (value != null) {
      value = MiSystem.getProperty(value, value);
    }

    if (Utility.isEqualTo(value, textField.getValue())) {
      return;
    }

    if (restrictingValuesToThoseInList) {
      if ((list.getIndexOfItem(value, restrictionIgnoresCase) == -1)
          && (list.getNumberOfItems() > 0)) {
        if (restrictionWarnsOnly) {
          textField.setValue(value);
          list.getSelectionManager().deSelectAll();
        } else {
          throw new IllegalArgumentException(
              MiDebug.getMicaClassName(this)
                  + ": Rejecting value: \""
                  + value
                  + "\" because it is not present in list"
                  + " (see MiComboBox.setRestrictingValuesToThoseInList()).\n"
                  + "Values present in list are: "
                  + getContents());
        }
      }
    }
    textField.setValue(value);
    if (!list.getContents().contains(value)) list.getSelectionManager().deSelectAll();
    else list.setValue(textField.getValue());
  }