检查 gxt simplecombobox 中是否存在硬编码值

Checking to see whether a hardcoded value is present in a gxt simplecombobox

我在 Java 中使用 gxt 2.0.3,我创建了一个 SimpleComboBox,然后用 2 个字符串填充它。

final SimpleComboBox<String> accessedComboBox = new SimpleComboBox<String>();
accessedComboBox.setTriggerAction(TriggerAction.ALL);
accessedComboBox.setEmptyText("Select a type");     
accessedComboBox.add("Method 1");
accessedComboBox.add("Method 2");

我还有一个附加到不同 SimpleComboBox 的侦听器,根据选择的内容,我需要从上面的 accessedComboBox 添加或删除值

if (typeComboBox.getSimpleValue() == "Type 1")
{
    //Remove desktop app option
    accessedComboBox.remove("Method 2");
}
else
{
    if (accessedComboBox.??) { // <--- Check to see whether desktop app is an option
        //if not then add it
        accessedComboBox.add("Method 2");
    }       
}

我不知道要使用什么函数来检查 SimpleComboBox 中是否已经存在一个选项。我已经看过 this documentation,但我仍然没有运气。

有人可以帮忙吗?

不确定你是否明白了。这有点古怪,但您可以从 ListStore 中获取字符串值。像这样:

for (SimpleComboValue<String> value : accessedComboBox.getStore().getModels()) {
   if (!value.getValue().equals("Method 1")){
       accessedComboBox.add("Method 1");
   }
}