Browse Source

Non-immediate mode works like it should when not in immediate mode.

Un-focusing the component will not revert value if the value is valid.

svn changeset:3659/svn branch:trunk
tags/6.7.0.beta1
Marc Englund 16 years ago
parent
commit
afc95e6c94
1 changed files with 28 additions and 26 deletions
  1. 28
    26
      src/com/itmill/toolkit/terminal/gwt/client/ui/IFilterSelect.java

+ 28
- 26
src/com/itmill/toolkit/terminal/gwt/client/ui/IFilterSelect.java View File

@@ -369,35 +369,42 @@ public class IFilterSelect extends Composite implements Paintable,

public void doSelectedItemAction() {
final MenuItem item = getSelectedItem();
if (allowNewItem) {
final String newItemValue = tb.getText();
// check for exact match in menu
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;
}
final String enteredItemValue = tb.getText();
// check for exact match in menu
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(enteredItemValue)) {
selectItem(potentialExactMatch);
doItemAction(potentialExactMatch, true);
suggestionPopup.hide();
return;
}
}
}
if (allowNewItem) {

if (!newItemValue.equals("")) {
client.updateVariable(paintableId, "newitem", newItemValue,
true);
if (!enteredItemValue.equals("")) {
client.updateVariable(paintableId, "newitem",
enteredItemValue, immediate);
}
} else if (item != null
&& item.getText().toLowerCase().startsWith(
lastFilter.toLowerCase())) {
doItemAction(item, true);
} else {
if (currentSuggestion != null) {
tb.setText(currentSuggestion.getReplacementString());
selectedOptionKey = currentSuggestion.key;
} else {
tb.setText("");
selectedOptionKey = null;
}
}
suggestionPopup.hide();
}

}

public static final int FILTERINGMODE_OFF = 0;
@@ -728,14 +735,9 @@ public class IFilterSelect extends Composite implements Paintable,
}

public void onLostFocus(Widget sender) {
if (currentSuggestion == null
|| !tb.getText().equals(
currentSuggestion.getReplacementString())) {
if (currentSuggestion != null) {
tb.setText(currentSuggestion.getDisplayString());
} else {
tb.setText("");
}
if (suggestionPopup.isJustClosed()) {
suggestionPopup.menu.doSelectedItemAction();
}

}
}

Loading…
Cancel
Save