summaryrefslogtreecommitdiffstats
path: root/client/src
diff options
context:
space:
mode:
authorHenri Sara <hesara@vaadin.com>2013-05-10 13:39:17 +0300
committerVaadin Code Review <review@vaadin.com>2013-05-10 13:27:57 +0000
commit19e27a15ca765de477fbe929a1cb6a7412c523f7 (patch)
tree2df9d3f79d3eede97aa2081b6cdd9ab5f0a26cf0 /client/src
parentbdb793187c513121cc3b4732b053ba549d94e7b8 (diff)
downloadvaadin-framework-19e27a15ca765de477fbe929a1cb6a7412c523f7.tar.gz
vaadin-framework-19e27a15ca765de477fbe929a1cb6a7412c523f7.zip
Move suggestion popup width calculation from connector to VFilterSelect
Change-Id: I846b71c453524ecc525c6ab6c528dffcc7715558
Diffstat (limited to 'client/src')
-rw-r--r--client/src/com/vaadin/client/ui/VFilterSelect.java23
-rw-r--r--client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java14
2 files changed, 25 insertions, 12 deletions
diff --git a/client/src/com/vaadin/client/ui/VFilterSelect.java b/client/src/com/vaadin/client/ui/VFilterSelect.java
index cd6ca290cc..b83197ed2d 100644
--- a/client/src/com/vaadin/client/ui/VFilterSelect.java
+++ b/client/src/com/vaadin/client/ui/VFilterSelect.java
@@ -1622,6 +1622,29 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
}
/**
+ * Update minimum width for FilterSelect textarea based on input prompt and
+ * suggestions.
+ * <p>
+ * For internal use only. May be removed or replaced in the future.
+ */
+ public void updateSuggestionPopupMinWidth() {
+ // used only to calculate minimum width
+ String captions = Util.escapeHTML(inputPrompt);
+
+ for (FilterSelectSuggestion suggestion : currentSuggestions) {
+ // Collect captions so we can calculate minimum width for
+ // textarea
+ if (captions.length() > 0) {
+ captions += "|";
+ }
+ captions += Util.escapeHTML(suggestion.getReplacementString());
+ }
+
+ // Calculate minimum textarea width
+ suggestionPopupMinWidth = minWidth(captions);
+ }
+
+ /**
* Calculate minimum width for FilterSelect textarea.
* <p>
* For internal use only. May be removed or replaced in the future.
diff --git a/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java b/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java
index 98d2651849..e96d27032b 100644
--- a/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java
+++ b/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java
@@ -20,7 +20,6 @@ import java.util.Iterator;
import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.Paintable;
import com.vaadin.client.UIDL;
-import com.vaadin.client.Util;
import com.vaadin.client.ui.AbstractFieldConnector;
import com.vaadin.client.ui.SimpleManagedLayout;
import com.vaadin.client.ui.VFilterSelect;
@@ -124,9 +123,6 @@ public class ComboBoxConnector extends AbstractFieldConnector implements
getWidget().totalMatches = 0;
}
- // used only to calculate minimum popup width
- String captions = Util.escapeHTML(getWidget().inputPrompt);
-
for (final Iterator<?> i = options.getChildIterator(); i.hasNext();) {
final UIDL optionUidl = (UIDL) i.next();
final FilterSelectSuggestion suggestion = getWidget().new FilterSelectSuggestion(
@@ -152,12 +148,6 @@ public class ComboBoxConnector extends AbstractFieldConnector implements
getWidget().currentSuggestion = suggestion;
getWidget().setSelectedItemIcon(suggestion.getIconUri());
}
-
- // Collect captions so we can calculate minimum width for textarea
- if (captions.length() > 0) {
- captions += "|";
- }
- captions += Util.escapeHTML(suggestion.getReplacementString());
}
if ((!getWidget().waitingForFilteringResponse || getWidget().popupOpenerClicked)
@@ -222,8 +212,8 @@ public class ComboBoxConnector extends AbstractFieldConnector implements
}
}
- // Calculate minumum textarea width
- getWidget().suggestionPopupMinWidth = getWidget().minWidth(captions);
+ // Calculate minimum textarea width
+ getWidget().updateSuggestionPopupMinWidth();
getWidget().popupOpenerClicked = false;