summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2012-05-03 21:51:30 +0300
committerArtur Signell <artur@vaadin.com>2012-05-11 22:18:23 +0300
commit2e6c788c14013ebca8cdea7da9d0ff7e7547df09 (patch)
tree628c09d7de10b995f267b0df0484f873107e039f /src
parent3387e8e2370a37f3e2d32d87dbe700def12dee65 (diff)
downloadvaadin-framework-2e6c788c14013ebca8cdea7da9d0ff7e7547df09.tar.gz
vaadin-framework-2e6c788c14013ebca8cdea7da9d0ff7e7547df09.zip
Moved most of TextField/TextArea/PasswordField paintContent to state
Removed deprecated value formatter from AbstractTextField (#8672)
Diffstat (limited to 'src')
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/passwordfield/PasswordFieldConnector.java7
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/textarea/TextAreaConnector.java21
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/textarea/TextAreaState.java33
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/textarea/VTextArea.java58
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/textfield/AbstractTextFieldState.java58
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/textfield/TextFieldConnector.java34
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/textfield/VTextField.java79
-rw-r--r--src/com/vaadin/ui/AbstractTextField.java128
-rw-r--r--src/com/vaadin/ui/TextArea.java48
9 files changed, 215 insertions, 251 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/passwordfield/PasswordFieldConnector.java b/src/com/vaadin/terminal/gwt/client/ui/passwordfield/PasswordFieldConnector.java
index 1d1ec58fbb..29a1aeef79 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/passwordfield/PasswordFieldConnector.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/passwordfield/PasswordFieldConnector.java
@@ -6,8 +6,6 @@ package com.vaadin.terminal.gwt.client.ui.passwordfield;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.Widget;
-import com.vaadin.terminal.gwt.client.ApplicationConnection;
-import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.ui.Connect;
import com.vaadin.terminal.gwt.client.ui.textfield.TextFieldConnector;
import com.vaadin.ui.PasswordField;
@@ -16,11 +14,6 @@ import com.vaadin.ui.PasswordField;
public class PasswordFieldConnector extends TextFieldConnector {
@Override
- public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
- super.updateFromUIDL(uidl, client);
- }
-
- @Override
protected Widget createWidget() {
return GWT.create(VPasswordField.class);
}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/textarea/TextAreaConnector.java b/src/com/vaadin/terminal/gwt/client/ui/textarea/TextAreaConnector.java
index 0f3ae0ad4f..ea32ae49c6 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/textarea/TextAreaConnector.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/textarea/TextAreaConnector.java
@@ -5,10 +5,8 @@
package com.vaadin.terminal.gwt.client.ui.textarea;
import com.google.gwt.core.client.GWT;
-import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.Widget;
-import com.vaadin.terminal.gwt.client.ApplicationConnection;
-import com.vaadin.terminal.gwt.client.UIDL;
+import com.vaadin.terminal.gwt.client.communication.StateChangeEvent;
import com.vaadin.terminal.gwt.client.ui.Connect;
import com.vaadin.terminal.gwt.client.ui.textfield.TextFieldConnector;
import com.vaadin.ui.TextArea;
@@ -17,17 +15,16 @@ import com.vaadin.ui.TextArea;
public class TextAreaConnector extends TextFieldConnector {
@Override
- public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
- // Call parent renderer explicitly
- super.updateFromUIDL(uidl, client);
+ public TextAreaState getState() {
+ return (TextAreaState) super.getState();
+ }
- if (uidl.hasAttribute("rows")) {
- getWidget().setRows(uidl.getIntAttribute("rows"));
- }
+ @Override
+ public void onStateChanged(StateChangeEvent stateChangeEvent) {
+ super.onStateChanged(stateChangeEvent);
- if (getWidget().getMaxLength() >= 0) {
- getWidget().sinkEvents(Event.ONKEYUP);
- }
+ getWidget().setRows(getState().getRows());
+ getWidget().setWordwrap(getState().isWordwrap());
}
@Override
diff --git a/src/com/vaadin/terminal/gwt/client/ui/textarea/TextAreaState.java b/src/com/vaadin/terminal/gwt/client/ui/textarea/TextAreaState.java
new file mode 100644
index 0000000000..02aa2070f1
--- /dev/null
+++ b/src/com/vaadin/terminal/gwt/client/ui/textarea/TextAreaState.java
@@ -0,0 +1,33 @@
+package com.vaadin.terminal.gwt.client.ui.textarea;
+
+import com.vaadin.terminal.gwt.client.ui.textfield.AbstractTextFieldState;
+
+public class TextAreaState extends AbstractTextFieldState {
+
+ /**
+ * Number of visible rows in the text area. The default is 5.
+ */
+ private int rows = 5;
+
+ /**
+ * Tells if word-wrapping should be used in the text area.
+ */
+ private boolean wordwrap = true;
+
+ public int getRows() {
+ return rows;
+ }
+
+ public void setRows(int rows) {
+ this.rows = rows;
+ }
+
+ public boolean isWordwrap() {
+ return wordwrap;
+ }
+
+ public void setWordwrap(boolean wordwrap) {
+ this.wordwrap = wordwrap;
+ }
+
+}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/textarea/VTextArea.java b/src/com/vaadin/terminal/gwt/client/ui/textarea/VTextArea.java
index c600b2fd1e..aede1ef002 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/textarea/VTextArea.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/textarea/VTextArea.java
@@ -5,10 +5,13 @@
package com.vaadin.terminal.gwt.client.ui.textarea;
import com.google.gwt.core.client.Scheduler;
+import com.google.gwt.dom.client.Style.Overflow;
+import com.google.gwt.dom.client.TextAreaElement;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
+import com.vaadin.terminal.gwt.client.BrowserInfo;
+import com.vaadin.terminal.gwt.client.Util;
import com.vaadin.terminal.gwt.client.ui.textfield.VTextField;
/**
@@ -22,23 +25,33 @@ import com.vaadin.terminal.gwt.client.ui.textfield.VTextField;
*/
public class VTextArea extends VTextField {
public static final String CLASSNAME = "v-textarea";
+ private boolean wordwrap = true;
public VTextArea() {
super(DOM.createTextArea());
setStyleName(CLASSNAME);
}
+ public TextAreaElement getTextAreaElement() {
+ return super.getElement().cast();
+ }
+
public void setRows(int rows) {
- setRows(getElement(), rows);
+ getTextAreaElement().setRows(rows);
}
- private native void setRows(Element e, int r)
- /*-{
- try {
- if(e.tagName.toLowerCase() == "textarea")
- e.rows = r;
- } catch (e) {}
- }-*/;
+ @Override
+ protected void setMaxLength(int newMaxLength) {
+ super.setMaxLength(newMaxLength);
+
+ boolean hasMaxLength = (newMaxLength >= 0);
+
+ if (hasMaxLength) {
+ sinkEvents(Event.ONKEYUP);
+ } else {
+ unsinkEvents(Event.ONKEYUP);
+ }
+ }
@Override
public void onBrowserEvent(Event event) {
@@ -61,4 +74,31 @@ public class VTextArea extends VTextField {
// detected in a different way.
return getImpl().getTextAreaCursorPos(getElement());
}
+
+ @Override
+ protected void setMaxLengthToElement(int newMaxLength) {
+ // There is no maxlength property for textarea. The maximum length is
+ // enforced by the KEYUP handler
+
+ }
+
+ public void setWordwrap(boolean wordwrap) {
+ if (wordwrap == this.wordwrap) {
+ return; // No change
+ }
+
+ if (wordwrap) {
+ getElement().removeAttribute("wrap");
+ getElement().getStyle().clearOverflow();
+ } else {
+ getElement().setAttribute("wrap", "off");
+ getElement().getStyle().setOverflow(Overflow.AUTO);
+ }
+ if (BrowserInfo.get().isOpera()) {
+ // Opera fails to dynamically update the wrap attribute so we detach
+ // and reattach the whole TextArea.
+ Util.detachAttach(getElement());
+ }
+ this.wordwrap = wordwrap;
+ }
}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/textfield/AbstractTextFieldState.java b/src/com/vaadin/terminal/gwt/client/ui/textfield/AbstractTextFieldState.java
new file mode 100644
index 0000000000..323e5ec67f
--- /dev/null
+++ b/src/com/vaadin/terminal/gwt/client/ui/textfield/AbstractTextFieldState.java
@@ -0,0 +1,58 @@
+package com.vaadin.terminal.gwt.client.ui.textfield;
+
+import com.vaadin.terminal.gwt.client.AbstractFieldState;
+
+public class AbstractTextFieldState extends AbstractFieldState {
+ /**
+ * Maximum character count in text field.
+ */
+ private int maxLength = -1;
+
+ /**
+ * Number of visible columns in the TextField.
+ */
+ private int columns = 0;
+
+ /**
+ * The prompt to display in an empty field. Null when disabled.
+ */
+ private String inputPrompt = null;
+
+ /**
+ * The text in the field
+ */
+ private String text = null;
+
+ public int getMaxLength() {
+ return maxLength;
+ }
+
+ public void setMaxLength(int maxLength) {
+ this.maxLength = maxLength;
+ }
+
+ public int getColumns() {
+ return columns;
+ }
+
+ public void setColumns(int columns) {
+ this.columns = columns;
+ }
+
+ public String getInputPrompt() {
+ return inputPrompt;
+ }
+
+ public void setInputPrompt(String inputPrompt) {
+ this.inputPrompt = inputPrompt;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/textfield/TextFieldConnector.java b/src/com/vaadin/terminal/gwt/client/ui/textfield/TextFieldConnector.java
index 7e9e786676..069dd1fb0d 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/textfield/TextFieldConnector.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/textfield/TextFieldConnector.java
@@ -22,6 +22,11 @@ import com.vaadin.ui.TextField;
public class TextFieldConnector extends AbstractFieldConnector implements
Paintable, BeforeShortcutActionListener {
+ @Override
+ public AbstractTextFieldState getState() {
+ return (AbstractTextFieldState) super.getState();
+ }
+
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
// Save details
getWidget().client = client;
@@ -33,14 +38,9 @@ public class TextFieldConnector extends AbstractFieldConnector implements
getWidget().setReadOnly(isReadOnly());
- getWidget().inputPrompt = uidl
- .getStringAttribute(VTextField.ATTR_INPUTPROMPT);
-
- getWidget().setMaxLength(
- uidl.hasAttribute("maxLength") ? uidl
- .getIntAttribute("maxLength") : -1);
-
- getWidget().immediate = getState().isImmediate();
+ getWidget().setInputPrompt(getState().getInputPrompt());
+ getWidget().setMaxLength(getState().getMaxLength());
+ getWidget().setImmediate(getState().isImmediate());
getWidget().listenTextChangeEvents = hasEventListener("ie");
if (getWidget().listenTextChangeEvents) {
@@ -61,13 +61,9 @@ public class TextFieldConnector extends AbstractFieldConnector implements
getWidget().sinkEvents(VTextField.TEXTCHANGE_EVENTS);
getWidget().attachCutEventListener(getWidget().getElement());
}
+ getWidget().setColumns(getState().getColumns());
- if (uidl.hasAttribute("cols")) {
- getWidget().setColumns(
- new Integer(uidl.getStringAttribute("cols")).intValue());
- }
-
- final String text = uidl.getStringVariable("text");
+ final String text = getState().getText();
/*
* We skip the text content update if field has been repainted, but text
@@ -94,16 +90,6 @@ public class TextFieldConnector extends AbstractFieldConnector implements
}
});
}
-
- // Here for backward compatibility; to be moved to TextArea.
- // Optimization: server does not send attribute for the default 'true'
- // state.
- if (uidl.hasAttribute("wordwrap")
- && uidl.getBooleanAttribute("wordwrap") == false) {
- getWidget().setWordwrap(false);
- } else {
- getWidget().setWordwrap(true);
- }
}
@Override
diff --git a/src/com/vaadin/terminal/gwt/client/ui/textfield/VTextField.java b/src/com/vaadin/terminal/gwt/client/ui/textfield/VTextField.java
index 7bd392b503..aeae165f60 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/textfield/VTextField.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/textfield/VTextField.java
@@ -4,7 +4,6 @@
package com.vaadin.terminal.gwt.client.ui.textfield;
-import com.google.gwt.dom.client.Style.Overflow;
import com.google.gwt.event.dom.client.BlurEvent;
import com.google.gwt.event.dom.client.BlurHandler;
import com.google.gwt.event.dom.client.ChangeEvent;
@@ -60,21 +59,19 @@ public class VTextField extends TextBoxBase implements Field, ChangeHandler,
*/
private boolean valueBeforeEditIsSynced = true;
- protected boolean immediate = false;
+ private boolean immediate = false;
private int maxLength = -1;
private static final String CLASSNAME_PROMPT = "prompt";
- protected static final String ATTR_INPUTPROMPT = "prompt";
public static final String ATTR_TEXTCHANGE_TIMEOUT = "iet";
public static final String VAR_CURSOR = "c";
public static final String ATTR_TEXTCHANGE_EVENTMODE = "iem";
protected static final String TEXTCHANGE_MODE_EAGER = "EAGER";
private static final String TEXTCHANGE_MODE_TIMEOUT = "TIMEOUT";
- protected String inputPrompt = null;
+ private String inputPrompt = null;
private boolean prompting = false;
private int lastCursorPos = -1;
- private boolean wordwrap = true;
public VTextField() {
this(DOM.createInputText());
@@ -264,20 +261,18 @@ public class VTextField extends TextBoxBase implements Field, ChangeHandler,
protected void setMaxLength(int newMaxLength) {
if (newMaxLength >= 0) {
maxLength = newMaxLength;
- if (getElement().getTagName().toLowerCase().equals("textarea")) {
- // NOP no maxlength property for textarea
- } else {
- getElement().setPropertyInt("maxLength", maxLength);
- }
- } else if (maxLength != -1) {
- if (getElement().getTagName().toLowerCase().equals("textarea")) {
- // NOP no maxlength property for textarea
- } else {
- getElement().removeAttribute("maxLength");
- }
+ } else {
maxLength = -1;
}
+ setMaxLengthToElement(newMaxLength);
+ }
+ protected void setMaxLengthToElement(int newMaxLength) {
+ if (newMaxLength >= 0) {
+ getElement().setPropertyInt("maxLength", newMaxLength);
+ } else {
+ getElement().removeAttribute("maxLength");
+ }
}
public int getMaxLength() {
@@ -390,48 +385,11 @@ public class VTextField extends TextBoxBase implements Field, ChangeHandler,
}
public void setColumns(int columns) {
- setColumns(getElement(), columns);
- }
-
- private native void setColumns(Element e, int c)
- /*-{
- try {
- switch(e.tagName.toLowerCase()) {
- case "input":
- //e.size = c;
- e.style.width = c+"em";
- break;
- case "textarea":
- //e.cols = c;
- e.style.width = c+"em";
- break;
- default:;
- }
- } catch (e) {}
- }-*/;
-
- // Here for backward compatibility; to be moved to TextArea
- public void setWordwrap(boolean enabled) {
- if (enabled == wordwrap) {
- return; // No change
+ if (columns <= 0) {
+ return;
}
- if (enabled) {
- getElement().removeAttribute("wrap");
- getElement().getStyle().clearOverflow();
- } else {
- getElement().setAttribute("wrap", "off");
- getElement().getStyle().setOverflow(Overflow.AUTO);
- }
- if (BrowserInfo.get().isSafari4()) {
- // Force redraw as Safari 4 does not properly update the screen
- Util.forceWebkitRedraw(getElement());
- } else if (BrowserInfo.get().isOpera()) {
- // Opera fails to dynamically update the wrap attribute so we detach
- // and reattach the whole TextArea.
- Util.detachAttach(getElement());
- }
- wordwrap = enabled;
+ setWidth(columns + "em");
}
public void onKeyDown(KeyDownEvent event) {
@@ -439,4 +397,13 @@ public class VTextField extends TextBoxBase implements Field, ChangeHandler,
valueChange(false);
}
}
+
+ public void setImmediate(boolean immediate) {
+ this.immediate = immediate;
+ }
+
+ public void setInputPrompt(String inputPrompt) {
+ this.inputPrompt = inputPrompt;
+ }
+
}
diff --git a/src/com/vaadin/ui/AbstractTextField.java b/src/com/vaadin/ui/AbstractTextField.java
index acb1d71ed8..d584374bda 100644
--- a/src/com/vaadin/ui/AbstractTextField.java
+++ b/src/com/vaadin/ui/AbstractTextField.java
@@ -4,7 +4,6 @@
package com.vaadin.ui;
-import java.text.Format;
import java.util.Map;
import com.vaadin.event.FieldEvents.BlurEvent;
@@ -19,18 +18,13 @@ import com.vaadin.event.FieldEvents.TextChangeNotifier;
import com.vaadin.terminal.PaintException;
import com.vaadin.terminal.PaintTarget;
import com.vaadin.terminal.Vaadin6Component;
+import com.vaadin.terminal.gwt.client.ui.textfield.AbstractTextFieldState;
import com.vaadin.terminal.gwt.client.ui.textfield.VTextField;
public abstract class AbstractTextField extends AbstractField<String> implements
BlurNotifier, FocusNotifier, TextChangeNotifier, Vaadin6Component {
/**
- * Value formatter used to format the string contents.
- */
- @Deprecated
- private Format format;
-
- /**
* Null representation.
*/
private String nullRepresentation = "null";
@@ -40,21 +34,6 @@ public abstract class AbstractTextField extends AbstractField<String> implements
*/
private boolean nullSettingAllowed = false;
/**
- * Maximum character count in text field.
- */
- private int maxLength = -1;
-
- /**
- * Number of visible columns in the TextField.
- */
- private int columns = 0;
-
- /**
- * The prompt to display in an empty field. Null when disabled.
- */
- private String inputPrompt = null;
-
- /**
* The text content when the last messages to the server was sent. Cleared
* when value is changed.
*/
@@ -100,32 +79,23 @@ public abstract class AbstractTextField extends AbstractField<String> implements
super();
}
- public void paintContent(PaintTarget target) throws PaintException {
-
- if (getMaxLength() >= 0) {
- target.addAttribute("maxLength", getMaxLength());
- }
-
- // Adds the number of column and rows
- final int columns = getColumns();
- if (columns != 0) {
- target.addAttribute("cols", String.valueOf(columns));
- }
+ @Override
+ public AbstractTextFieldState getState() {
+ return (AbstractTextFieldState) super.getState();
+ }
- if (getInputPrompt() != null) {
- target.addAttribute("prompt", getInputPrompt());
- }
+ @Override
+ public void updateState() {
+ super.updateState();
- // Adds the content as variable
- String value = getFormattedValue();
+ String value = getValue();
if (value == null) {
value = getNullRepresentation();
}
- if (value == null) {
- throw new IllegalStateException(
- "Null values are not allowed if the null-representation is null");
- }
- target.addVariable(this, "text", value);
+ getState().setText(value);
+ }
+
+ public void paintContent(PaintTarget target) throws PaintException {
if (selectionPosition != -1) {
target.addAttribute("selpos", selectionPosition);
@@ -153,37 +123,6 @@ public abstract class AbstractTextField extends AbstractField<String> implements
}
- /**
- * Gets the formatted string value. Sets the field value by using the
- * assigned Format.
- *
- * @return the Formatted value.
- * @see #setFormat(Format)
- * @see Format
- * @deprecated
- */
- @Deprecated
- protected String getFormattedValue() {
- Object v = getValue();
- if (v == null) {
- return null;
- }
- return v.toString();
- }
-
- @Override
- public String getValue() {
- String v = super.getValue();
- if (format == null || v == null) {
- return v;
- }
- try {
- return format.format(v);
- } catch (final IllegalArgumentException e) {
- return v;
- }
- }
-
public void changeVariables(Object source, Map<String, Object> variables) {
changingVariables = true;
@@ -215,7 +154,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
if (getMaxLength() != -1 && newValue.length() > getMaxLength()) {
newValue = newValue.substring(0, getMaxLength());
}
- final String oldValue = getFormattedValue();
+ final String oldValue = getValue();
if (newValue != null
&& (oldValue == null || isNullSettingAllowed())
&& newValue.equals(getNullRepresentation())) {
@@ -228,7 +167,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
// If the modified status changes, or if we have a
// formatter, repaint is needed after all.
- if (format != null || wasModified != isModified()) {
+ if (wasModified != isModified()) {
requestRepaint();
}
}
@@ -345,31 +284,6 @@ public abstract class AbstractTextField extends AbstractField<String> implements
requestRepaint();
}
- /**
- * Gets the value formatter of TextField.
- *
- * @return the Format used to format the value.
- * @deprecated replaced by {@link com.vaadin.data.util.PropertyFormatter}
- */
- @Deprecated
- public Format getFormat() {
- return format;
- }
-
- /**
- * Gets the value formatter of TextField.
- *
- * @param format
- * the Format used to format the value. Null disables the
- * formatting.
- * @deprecated replaced by {@link com.vaadin.data.util.PropertyFormatter}
- */
- @Deprecated
- public void setFormat(Format format) {
- this.format = format;
- requestRepaint();
- }
-
@Override
protected boolean isEmpty() {
return super.isEmpty() || getValue().length() == 0;
@@ -382,7 +296,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
* @return the maxLength
*/
public int getMaxLength() {
- return maxLength;
+ return getState().getMaxLength();
}
/**
@@ -393,7 +307,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
* the maxLength to set
*/
public void setMaxLength(int maxLength) {
- this.maxLength = maxLength;
+ getState().setMaxLength(maxLength);
requestRepaint();
}
@@ -405,7 +319,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
* @return the number of columns in the editor.
*/
public int getColumns() {
- return columns;
+ return getState().getColumns();
}
/**
@@ -420,7 +334,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
if (columns < 0) {
columns = 0;
}
- this.columns = columns;
+ getState().setColumns(columns);
requestRepaint();
}
@@ -431,7 +345,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
* @return the current input prompt, or null if not enabled
*/
public String getInputPrompt() {
- return inputPrompt;
+ return getState().getInputPrompt();
}
/**
@@ -441,7 +355,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
* @param inputPrompt
*/
public void setInputPrompt(String inputPrompt) {
- this.inputPrompt = inputPrompt;
+ getState().setInputPrompt(inputPrompt);
requestRepaint();
}
diff --git a/src/com/vaadin/ui/TextArea.java b/src/com/vaadin/ui/TextArea.java
index adb980818e..4c0b563b00 100644
--- a/src/com/vaadin/ui/TextArea.java
+++ b/src/com/vaadin/ui/TextArea.java
@@ -5,26 +5,13 @@
package com.vaadin.ui;
import com.vaadin.data.Property;
-import com.vaadin.terminal.PaintException;
-import com.vaadin.terminal.PaintTarget;
+import com.vaadin.terminal.gwt.client.ui.textarea.TextAreaState;
/**
* A text field that supports multi line editing.
*/
public class TextArea extends AbstractTextField {
- private static final int DEFAULT_ROWS = 5;
-
- /**
- * Number of visible rows in the text area.
- */
- private int rows = DEFAULT_ROWS;
-
- /**
- * Tells if word-wrapping should be used in the text area.
- */
- private boolean wordwrap = true;
-
/**
* Constructs an empty TextArea.
*/
@@ -81,6 +68,11 @@ public class TextArea extends AbstractTextField {
}
+ @Override
+ public TextAreaState getState() {
+ return (TextAreaState) super.getState();
+ }
+
/**
* Sets the number of rows in the text area.
*
@@ -91,10 +83,8 @@ public class TextArea extends AbstractTextField {
if (rows < 0) {
rows = 0;
}
- if (this.rows != rows) {
- this.rows = rows;
- requestRepaint();
- }
+ getState().setRows(rows);
+ requestRepaint();
}
/**
@@ -103,7 +93,7 @@ public class TextArea extends AbstractTextField {
* @return number of explicitly set rows.
*/
public int getRows() {
- return rows;
+ return getState().getRows();
}
/**
@@ -114,10 +104,8 @@ public class TextArea extends AbstractTextField {
* word-wrap mode.
*/
public void setWordwrap(boolean wordwrap) {
- if (this.wordwrap != wordwrap) {
- this.wordwrap = wordwrap;
- requestRepaint();
- }
+ getState().setWordwrap(wordwrap);
+ requestRepaint();
}
/**
@@ -127,19 +115,7 @@ public class TextArea extends AbstractTextField {
* <code>false</code> if not.
*/
public boolean isWordwrap() {
- return wordwrap;
+ return getState().isWordwrap();
}
- @Override
- public void paintContent(PaintTarget target) throws PaintException {
- super.paintContent(target);
-
- target.addAttribute("rows", getRows());
-
- if (!isWordwrap()) {
- // Wordwrap is only painted if turned off to minimize communications
- target.addAttribute("wordwrap", false);
- }
-
- }
}