diff options
author | Henri Sara <hesara@vaadin.com> | 2015-11-05 10:51:56 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2016-08-08 06:47:17 +0000 |
commit | 0e1a271cc5e465a774f0d729fc9ad38b300757de (patch) | |
tree | bfc9113541d6b2a638442e33886e59b7a283a59b /server | |
parent | 2879cfcdff148002a59d5e6c486fc769ecba5aa3 (diff) | |
download | vaadin-framework-0e1a271cc5e465a774f0d729fc9ad38b300757de.tar.gz vaadin-framework-0e1a271cc5e465a774f0d729fc9ad38b300757de.zip |
Use shared state in ComboBox (#19229)
This change uses shared state for the read-only flag, text
input allowed flag and input prompt.
Change-Id: If770a3d9be96d10c3a19654b398bc2f5ddfb7e67
Diffstat (limited to 'server')
-rw-r--r-- | server/src/main/java/com/vaadin/ui/ComboBox.java | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/server/src/main/java/com/vaadin/ui/ComboBox.java b/server/src/main/java/com/vaadin/ui/ComboBox.java index 562173a9bf..a6a562f2d2 100644 --- a/server/src/main/java/com/vaadin/ui/ComboBox.java +++ b/server/src/main/java/com/vaadin/ui/ComboBox.java @@ -34,7 +34,6 @@ import com.vaadin.event.FieldEvents.FocusListener; import com.vaadin.server.PaintException; import com.vaadin.server.PaintTarget; import com.vaadin.server.Resource; -import com.vaadin.shared.ui.combobox.ComboBoxConstants; import com.vaadin.shared.ui.combobox.ComboBoxState; import com.vaadin.shared.ui.combobox.FilteringMode; @@ -75,8 +74,6 @@ public class ComboBox extends AbstractSelect implements public String getStyle(ComboBox source, Object itemId); } - private String inputPrompt = null; - /** * Holds value of property pageLength. 0 disables paging. */ @@ -166,7 +163,7 @@ public class ComboBox extends AbstractSelect implements * @return the current input prompt, or null if not enabled */ public String getInputPrompt() { - return inputPrompt; + return getState(false).inputPrompt; } /** @@ -177,8 +174,7 @@ public class ComboBox extends AbstractSelect implements * the desired input prompt, or null to disable */ public void setInputPrompt(String inputPrompt) { - this.inputPrompt = inputPrompt; - markAsDirty(); + getState().inputPrompt = inputPrompt; } private boolean isFilteringNeeded() { @@ -190,15 +186,6 @@ public class ComboBox extends AbstractSelect implements public void paintContent(PaintTarget target) throws PaintException { isPainting = true; try { - if (inputPrompt != null) { - target.addAttribute(ComboBoxConstants.ATTR_INPUTPROMPT, - inputPrompt); - } - - if (!textInputAllowed) { - target.addAttribute(ComboBoxConstants.ATTR_NO_TEXT_INPUT, true); - } - // clear caption change listeners getCaptionChangeListener().clear(); @@ -375,8 +362,7 @@ public class ComboBox extends AbstractSelect implements * selection */ public void setTextInputAllowed(boolean textInputAllowed) { - this.textInputAllowed = textInputAllowed; - markAsDirty(); + getState().textInputAllowed = textInputAllowed; } /** @@ -388,7 +374,7 @@ public class ComboBox extends AbstractSelect implements * @return */ public boolean isTextInputAllowed() { - return textInputAllowed; + return getState(false).textInputAllowed; } @Override @@ -396,6 +382,11 @@ public class ComboBox extends AbstractSelect implements return (ComboBoxState) super.getState(); } + @Override + protected ComboBoxState getState(boolean markAsDirty) { + return (ComboBoxState) super.getState(markAsDirty); + } + /** * Returns the filtered options for the current page using a container * filter. |