|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void doSelectedItemAction() { |
|
|
public void doSelectedItemAction() { |
|
|
final MenuItem item = getSelectedItem(); |
|
|
final MenuItem item = getSelectedItem(); |
|
|
if (item != null |
|
|
|
|
|
&& item.getText().toLowerCase().startsWith( |
|
|
|
|
|
lastFilter.toLowerCase())) { |
|
|
|
|
|
doItemAction(item, true); |
|
|
|
|
|
} else if (allowNewItem) { |
|
|
|
|
|
|
|
|
if (allowNewItem) { |
|
|
final String newItemValue = tb.getText(); |
|
|
final String newItemValue = tb.getText(); |
|
|
// check for exact match in menu |
|
|
// check for exact match in menu |
|
|
if (getItems().size() == 1) { |
|
|
|
|
|
final MenuItem potentialExactMatch = (MenuItem) getItems() |
|
|
|
|
|
.get(0); |
|
|
|
|
|
if (potentialExactMatch.getText().equals(newItemValue)) { |
|
|
|
|
|
selectItem(potentialExactMatch); |
|
|
|
|
|
doSelectedItemAction(); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
if (!newItemValue.equals("")) { |
|
|
|
|
|
client.updateVariable(paintableId, "newitem", |
|
|
|
|
|
newItemValue, true); |
|
|
|
|
|
|
|
|
int p = getItems().size(); |
|
|
|
|
|
if (p > 0) { |
|
|
|
|
|
for (int i = 0; i < p; i++) { |
|
|
|
|
|
final MenuItem potentialExactMatch = (MenuItem) getItems() |
|
|
|
|
|
.get(i); |
|
|
|
|
|
if (potentialExactMatch.getText().equals(newItemValue)) { |
|
|
|
|
|
selectItem(potentialExactMatch); |
|
|
|
|
|
doItemAction(potentialExactMatch, true); |
|
|
|
|
|
suggestionPopup.hide(); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!newItemValue.equals("")) { |
|
|
|
|
|
client.updateVariable(paintableId, "newitem", newItemValue, |
|
|
|
|
|
true); |
|
|
|
|
|
} |
|
|
|
|
|
} else if (item != null |
|
|
|
|
|
&& item.getText().toLowerCase().startsWith( |
|
|
|
|
|
lastFilter.toLowerCase())) { |
|
|
|
|
|
doItemAction(item, true); |
|
|
} |
|
|
} |
|
|
suggestionPopup.hide(); |
|
|
suggestionPopup.hide(); |
|
|
} |
|
|
} |