]> source.dussan.org Git - vaadin-framework.git/commitdiff
Non-immediate mode works like it should when not in immediate mode.
authorMarc Englund <marc.englund@itmill.com>
Fri, 25 Jan 2008 15:06:55 +0000 (15:06 +0000)
committerMarc Englund <marc.englund@itmill.com>
Fri, 25 Jan 2008 15:06:55 +0000 (15:06 +0000)
Un-focusing the component will not revert value if the value is valid.

svn changeset:3659/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/client/ui/IFilterSelect.java

index 5ab45205b153b7ea4aa4f29f47ae1fb3a62ee823..2bd7cee311be672bcffdc08e17b17cfd01b4de89 100644 (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();
         }
+
     }
 }