import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ui.VFilterSelect;
import com.vaadin.terminal.gwt.client.ui.VListSelect;
-import com.vaadin.terminal.gwt.client.ui.VPasswordField;
import com.vaadin.terminal.gwt.client.ui.VSplitPanelHorizontal;
import com.vaadin.terminal.gwt.client.ui.VSplitPanelVertical;
-import com.vaadin.terminal.gwt.client.ui.VTextArea;
-import com.vaadin.terminal.gwt.client.ui.VTextField;
import com.vaadin.terminal.gwt.client.ui.VUnknownComponent;
import com.vaadin.terminal.gwt.client.ui.VView;
import com.vaadin.terminal.gwt.client.ui.VWindow;
return VListSelect.class;
}
}
- } else if (widgetClass == VTextField.class) {
- if (uidl.hasAttribute("multiline")) {
- return VTextArea.class;
- } else if (uidl.hasAttribute("secret")) {
- return VPasswordField.class;
- }
} else if (widgetClass == VSplitPanelHorizontal.class
&& uidl.hasAttribute("vertical")) {
return VSplitPanelVertical.class;
*/
if (fullyqualifiedName.equals("com.vaadin.ui.Select")) {
loadImplementation(VListSelect.class);
- } else if (fullyqualifiedName.equals("com.vaadin.ui.TextField")) {
- loadImplementation(VTextArea.class);
- loadImplementation(VPasswordField.class);
} else if (fullyqualifiedName.equals("com.vaadin.ui.SplitPanel")) {
loadImplementation(VSplitPanelVertical.class);
}
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.VTextField;
import com.vaadin.ui.ClientWidget.LoadStyle;
@ClientWidget(value = VTextField.class, loadStyle = LoadStyle.EAGER)
public class TextField extends AbstractTextField {
- /**
- * Tells if input is used to enter sensitive information that is not echoed
- * to display. Typically passwords.
- */
- @Deprecated
- private boolean secret = false;
-
- /**
- * Number of visible rows in a multiline TextField. Value 0 implies a
- * single-line text-editor.
- */
- @Deprecated
- private int rows = 0;
-
- /**
- * Tells if word-wrapping should be used in multiline mode.
- */
- @Deprecated
- private boolean wordwrap = true;
-
/**
* Constructs an empty <code>TextField</code> with no caption.
*/
*
* @param caption
* the caption <code>String</code> for the editor.
- * @param text
+ * @param value
* the initial text content of the editor.
*/
public TextField(String caption, String value) {
setCaption(caption);
}
- /**
- * Gets the secret property. If a field is used to enter secret information
- * the information is not echoed to display.
- *
- * @return <code>true</code> if the field is used to enter secret
- * information, <code>false</code> otherwise.
- *
- * @deprecated Starting from 6.5 use {@link PasswordField} instead for
- * secret text input.
- */
- @Deprecated
- public boolean isSecret() {
- return secret;
- }
-
- /**
- * Sets the secret property on and off. If a field is used to enter secret
- * information the information is not echoed to display.
- *
- * @param secret
- * the value specifying if the field is used to enter secret
- * information.
- * @deprecated Starting from 6.5 use {@link PasswordField} instead for
- * secret text input.
- */
- @Deprecated
- public void setSecret(boolean secret) {
- if (this.secret != secret) {
- this.secret = secret;
- requestRepaint();
- }
- }
-
- @Override
- public void paintContent(PaintTarget target) throws PaintException {
- if (isSecret()) {
- target.addAttribute("secret", true);
- }
-
- final int rows = getRows();
- if (rows != 0) {
- target.addAttribute("rows", rows);
- target.addAttribute("multiline", true);
-
- if (!isWordwrap()) {
- // Wordwrap is only painted if turned off to minimize
- // communications
- target.addAttribute("wordwrap", false);
- }
- }
-
- super.paintContent(target);
-
- }
-
- /**
- * Gets the number of rows in the editor. If the number of rows is set to 0,
- * the actual number of displayed rows is determined implicitly by the
- * adapter.
- *
- * @return number of explicitly set rows.
- * @deprecated Starting from 6.5 use {@link TextArea} for a multi-line text
- * input.
- *
- */
- @Deprecated
- public int getRows() {
- return rows;
- }
-
- /**
- * Sets the number of rows in the editor.
- *
- * @param rows
- * the number of rows for this editor.
- *
- * @deprecated Starting from 6.5 use {@link TextArea} for a multi-line text
- * input.
- */
- @Deprecated
- public void setRows(int rows) {
- if (rows < 0) {
- rows = 0;
- }
- if (this.rows != rows) {
- this.rows = rows;
- requestRepaint();
- }
- }
-
- /**
- * Tests if the editor is in word-wrap mode.
- *
- * @return <code>true</code> if the component is in the word-wrap mode,
- * <code>false</code> if not.
- * @deprecated Starting from 6.5 use {@link TextArea} for a multi-line text
- * input.
- */
- @Deprecated
- public boolean isWordwrap() {
- return wordwrap;
- }
-
- /**
- * Sets the editor's word-wrap mode on or off.
- *
- * @param wordwrap
- * the boolean value specifying if the editor should be in
- * word-wrap mode after the call or not.
- *
- * @deprecated Starting from 6.5 use {@link TextArea} for a multi-line text
- * input.
- */
- @Deprecated
- public void setWordwrap(boolean wordwrap) {
- if (this.wordwrap != wordwrap) {
- this.wordwrap = wordwrap;
- requestRepaint();
- }
- }
-
- /**
- * Sets the height of the {@link TextField} instance.
- *
- * <p>
- * Setting height for {@link TextField} also has a side-effect that puts
- * {@link TextField} into multiline mode (aka "textarea"). Multiline mode
- * can also be achieved by calling {@link #setRows(int)}. The height value
- * overrides the number of rows set by {@link #setRows(int)}.
- * <p>
- * If you want to set height of single line {@link TextField}, call
- * {@link #setRows(int)} with value 0 after setting the height. Setting rows
- * to 0 resets the side-effect.
- * <p>
- * Starting from 6.5 you should use {@link TextArea} instead of
- * {@link TextField} for multiline text input.
- *
- *
- * @see com.vaadin.ui.AbstractComponent#setHeight(float, int)
- */
- @Override
- public void setHeight(float height, int unit) {
- super.setHeight(height, unit);
- if (height > 1 && getClass() == TextField.class) {
- /*
- * In html based terminals we most commonly want to make component
- * to be textarea if height is defined. Setting row field above 0
- * will render component as textarea.
- */
-
- setRows(2);
- }
- }
-
- /**
- * Sets the height of the {@link TextField} instance.
- *
- * <p>
- * Setting height for {@link TextField} also has a side-effect that puts
- * {@link TextField} into multiline mode (aka "textarea"). Multiline mode
- * can also be achieved by calling {@link #setRows(int)}. The height value
- * overrides the number of rows set by {@link #setRows(int)}.
- * <p>
- * If you want to set height of single line {@link TextField}, call
- * {@link #setRows(int)} with value 0 after setting the height. Setting rows
- * to 0 resets the side-effect.
- *
- * @see com.vaadin.ui.AbstractComponent#setHeight(java.lang.String)
- */
- @Override
- public void setHeight(String height) {
- // will call setHeight(float, int) the actually does the magic. Method
- // is overridden just to document side-effects.
- super.setHeight(height);
- }
-
}
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
+import com.vaadin.ui.PasswordField;
import com.vaadin.ui.Root;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
FormLayout formLayout = new FormLayout();
final TextField userField = new TextField("Username");
userField.setDebugId("user");
- final TextField passwordField = new TextField("Password");
+ final PasswordField passwordField = new PasswordField("Password");
passwordField.setDebugId("pwd");
- passwordField.setSecret(true);
Button login = new Button("login");
login.setDebugId("loginButton");
login.setClickShortcut(KeyCode.ENTER);
login.addListener(new ClickListener() {
public void buttonClick(final ClickEvent event) {
- String username = (String) userField.getValue();
- String password = (String) passwordField.getValue();
+ String username = userField.getValue();
+ String password = passwordField.getValue();
setUser(username);
showMainWindow();
+++ /dev/null
-package com.vaadin.tests.components.formlayout;\r
-\r
-import com.vaadin.data.Property.ValueChangeEvent;\r
-import com.vaadin.data.Property.ValueChangeListener;\r
-import com.vaadin.tests.components.TestBase;\r
-import com.vaadin.ui.CheckBox;\r
-import com.vaadin.ui.FormLayout;\r
-import com.vaadin.ui.TextField;\r
-\r
-public class FormLayoutReplaceComponent extends TestBase {\r
-\r
- @Override\r
- protected void setup() {\r
- addComponent(new FL());\r
-\r
- }\r
-\r
- public class FL extends FormLayout implements ValueChangeListener {\r
-\r
- private TextField messages;\r
- private CheckBox control;\r
-\r
- @SuppressWarnings("deprecation")\r
- public FL() {\r
- setCaption("Test");\r
- control = new CheckBox("Messages On/Off");\r
- control.addListener(this);\r
- control.setImmediate(true);\r
- addComponent(control);\r
-\r
- // The bug is in replaceComponent, triggered when VTextField is\r
- // replaced by VTextArea so cannot replace this with TextArea.\r
- messages = new TextField("Messages");\r
- messages.setRows(10);\r
- messages.setColumns(40);\r
- messages.setVisible(false);\r
- messages.setEnabled(false);\r
- addComponent(messages);\r
- }\r
-\r
- public void valueChange(ValueChangeEvent event) {\r
- if (event.getProperty() == control) {\r
- messages.setVisible(control.getValue());\r
- }\r
-\r
- }\r
- }\r
-\r
- @Override\r
- protected String getDescription() {\r
- return "Check or uncheck the CheckBox to show/hide the messages field inside the FormLayout.";\r
- }\r
-\r
- @Override\r
- protected Integer getTicketNumber() {\r
- return 6308;\r
- }\r
-\r
-}
import com.vaadin.ui.NativeSelect;\r
import com.vaadin.ui.Notification;\r
import com.vaadin.ui.Root;\r
-import com.vaadin.ui.TextField;\r
+import com.vaadin.ui.TextArea;\r
\r
public class Notifications extends TestBase implements ClickListener {\r
\r
private static final String CAPTION = "CAPTION";\r
- private TextField tf;\r
+ private TextArea tf;\r
private NativeSelect type;\r
\r
@SuppressWarnings("deprecation")\r
@Override\r
protected void setup() {\r
- tf = new TextField("Text", "Hello world");\r
+ tf = new TextArea("Text", "Hello world");\r
tf.setRows(10);\r
addComponent(tf);\r
type = new NativeSelect();\r
}\r
\r
public void buttonClick(ClickEvent event) {\r
- Notification n = new Notification((String) tf.getValue(),\r
+ Notification n = new Notification(tf.getValue(),\r
(Integer) type.getValue());\r
Root.getCurrentRoot().showNotification(n);\r
\r
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Panel;
+import com.vaadin.ui.TextArea;
import com.vaadin.ui.TextField;
public class SelectionAndCursorPosition extends TestBase {
- TextField tf = new TextField();
+ TextField tf = createTextField();
+ TextArea ta = createTextArea();
@Override
protected void setup() {
-
- tf.setCaption("Text field");
- tf.setValue("So we have some text to select");
- tf.setWidth("400px");
-
FormLayout fl = new FormLayout();
Panel panel = new Panel(fl);
panel.setCaption("Hackers panel");
CheckBox ml = new CheckBox("Multiline");
ml.setImmediate(true);
ml.addListener(new Property.ValueChangeListener() {
- @SuppressWarnings("deprecation")
public void valueChange(ValueChangeEvent event) {
- if (tf.getHeight() < 0) {
- tf.setHeight("50px");
+ if (tf.getApplication() == null) {
+ replaceComponent(ta, tf);
} else {
- tf.setSizeUndefined();
- tf.setRows(0);
+ replaceComponent(tf, ta);
}
- tf.setWidth("400px");
}
});
fl.addComponent(ml);
b = new Button("select");
b.addListener(new ClickListener() {
public void buttonClick(ClickEvent event) {
- int startPos = Integer.parseInt((String) start.getValue());
- int lenght = Integer.parseInt((String) length.getValue());
+ int startPos = Integer.parseInt(start.getValue());
+ int lenght = Integer.parseInt(length.getValue());
tf.setSelectionRange(startPos, lenght);
}
});
b = new Button("set");
b.addListener(new ClickListener() {
public void buttonClick(ClickEvent event) {
- int startPos = Integer.parseInt((String) pos.getValue());
+ int startPos = Integer.parseInt(pos.getValue());
tf.setCursorPosition(startPos);
}
});
}
+ private static TextField createTextField() {
+ TextField tf = new TextField();
+ tf.setCaption("Text field");
+ tf.setValue("So we have some text to select");
+ tf.setWidth("400px");
+
+ return tf;
+ }
+
+ private static TextArea createTextArea() {
+ TextArea ta = new TextArea();
+ ta.setCaption("Text area");
+ ta.setValue("So we have some text to select");
+ ta.setWidth("400px");
+ ta.setHeight("50px");
+
+ return ta;
+ }
+
@Override
protected String getDescription() {
return "For usability reasons it is often essential that developer "
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.Component;
import com.vaadin.ui.CssLayout;
+import com.vaadin.ui.TextArea;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
vl.setHeight("40px");
vl.setWidth("200px");
- tf = new TextField();
- tf.setRows(2); // make it text area, instead of oneliner
- tf.setSizeFull();
- vl.addComponent(tf);
+ TextArea ta = new TextArea();
+ ta.setRows(2); // make it text area, instead of oneliner
+ ta.setSizeFull();
+ vl.addComponent(ta);
vl.setCaption("Fullsize textarea in 100px height 200px width box");
cssLayout.addComponent(vl);
package com.vaadin.tests.components.textfield;\r
\r
-import java.util.LinkedHashMap;\r
-\r
import com.vaadin.event.FieldEvents.TextChangeListener;\r
import com.vaadin.tests.components.abstractfield.AbstractTextFieldTest;\r
import com.vaadin.ui.TextField;\r
public class TextFieldTest extends AbstractTextFieldTest<TextField> implements\r
TextChangeListener {\r
\r
- private Command<TextField, Boolean> secretCommand = new Command<TextField, Boolean>() {\r
- @SuppressWarnings("deprecation")\r
- public void execute(TextField c, Boolean value, Object data) {\r
- c.setSecret(value);\r
- }\r
- };\r
-\r
- private Command<TextField, Boolean> wordwrapCommand = new Command<TextField, Boolean>() {\r
- @SuppressWarnings("deprecation")\r
- public void execute(TextField c, Boolean value, Object data) {\r
- c.setWordwrap(value);\r
- }\r
- };\r
-\r
- private Command<TextField, Integer> rowsCommand = new Command<TextField, Integer>() {\r
- @SuppressWarnings("deprecation")\r
- public void execute(TextField c, Integer value, Object data) {\r
- c.setRows(value);\r
- }\r
- };\r
-\r
@Override\r
protected Class<TextField> getTestClass() {\r
return TextField.class;\r
@Override\r
protected void createActions() {\r
super.createActions();\r
- createSecretAction(CATEGORY_FEATURES);\r
- createWordwrapAction(CATEGORY_FEATURES);\r
- createRowsAction(CATEGORY_FEATURES);\r
- }\r
-\r
- private void createRowsAction(String category) {\r
- LinkedHashMap<String, Integer> options = createIntegerOptions(20);\r
- createSelectAction("Rows", category, options, "0", rowsCommand);\r
- }\r
-\r
- private void createSecretAction(String category) {\r
- createBooleanAction("Secret", category, false, secretCommand);\r
- }\r
-\r
- private void createWordwrapAction(String category) {\r
- createBooleanAction("Wordwrap", category, false, wordwrapCommand);\r
}\r
\r
}\r
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.FormLayout;
-import com.vaadin.ui.TextField;
+import com.vaadin.ui.TextArea;
public class FormLayoutWithInvisibleComponent extends TestBase {
- private TextField messages;
+ private TextArea messages;
@Override
protected String getDescription() {
control.setImmediate(true);
formLayout.addComponent(control);
- messages = new TextField("Messages hidden");
+ messages = new TextArea("Messages hidden");
messages.setRows(10);
messages.setColumns(40);
messages.setVisible(false);
+++ /dev/null
-package com.vaadin.tests.layouts;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.AbsoluteLayout;
-import com.vaadin.ui.AbstractLayout;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.CssLayout;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.VerticalLayout;
-
-@SuppressWarnings("deprecation")
-public class WidgetImplementationSwap extends TestBase {
-
- @Override
- protected void setup() {
- setTheme("tests-tickets");
-
- {
- final AbstractLayout layout = new AbsoluteLayout();
- layout.setCaption(layout.getClass().getSimpleName());
- layout.setStyleName("borders");
- layout.setWidth("500px");
- layout.setHeight("50px");
- addComponent(layout);
- final TextField tf = new TextField();
- layout.addComponent(tf);
- Button b = new Button("-> TextArea", new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- if (tf.getRows() == 0) {
- tf.setRows(3);
- event.getButton().setCaption("Move");
- } else {
- layout.setCaption(layout.getClass().getSimpleName()
- + " done");
- event.getButton().setCaption("done");
- }
-
- }
- });
- addComponent(b);
- }
- {
- final AbstractLayout layout = new VerticalLayout();
- layout.setCaption(layout.getClass().getSimpleName());
- layout.setStyleName("borders");
- layout.setWidth("500px");
- layout.setHeight("50px");
- addComponent(layout);
- final TextField tf = new TextField();
- layout.addComponent(tf);
- Button b = new Button("-> TextArea", new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- if (tf.getRows() == 0) {
- tf.setRows(3);
- event.getButton().setCaption("Move");
- } else {
- layout.setCaption(layout.getClass().getSimpleName()
- + " done");
- event.getButton().setCaption("done");
- }
-
- }
- });
- addComponent(b);
- }
-
- {
- final AbstractLayout layout = new HorizontalLayout();
- layout.setCaption(layout.getClass().getSimpleName());
- layout.setStyleName("borders");
- layout.setWidth("500px");
- layout.setHeight("50px");
- addComponent(layout);
- final TextField tf = new TextField();
- layout.addComponent(tf);
- Button b = new Button("-> TextArea", new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- if (tf.getRows() == 0) {
- tf.setRows(3);
- event.getButton().setCaption("Move");
- } else {
- layout.setCaption(layout.getClass().getSimpleName()
- + " done");
- event.getButton().setCaption("done");
- }
-
- }
- });
- addComponent(b);
- }
-
- {
- final AbstractLayout layout = new GridLayout();
- layout.setCaption(layout.getClass().getSimpleName());
- layout.setStyleName("borders");
- layout.setWidth("500px");
- layout.setHeight("50px");
- addComponent(layout);
- final TextField tf = new TextField();
- layout.addComponent(tf);
- Button b = new Button("-> TextArea", new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- if (tf.getRows() == 0) {
- tf.setRows(3);
- event.getButton().setCaption("Move");
- } else {
- layout.setCaption(layout.getClass().getSimpleName()
- + " done");
- event.getButton().setCaption("done");
- }
-
- }
- });
- addComponent(b);
- }
-
- {
- final AbstractLayout layout = new CssLayout();
- layout.setCaption(layout.getClass().getSimpleName());
- layout.setStyleName("borders");
- layout.setWidth("500px");
- layout.setHeight("50px");
- addComponent(layout);
- final TextField tf = new TextField();
- layout.addComponent(tf);
- Button b = new Button("-> TextArea", new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- if (tf.getRows() == 0) {
- tf.setRows(3);
- event.getButton().setCaption("Move");
- } else {
- layout.setCaption(layout.getClass().getSimpleName()
- + " done");
- event.getButton().setCaption("done");
- }
-
- }
- });
- addComponent(b);
- }
-
- }
-
- @Override
- protected String getDescription() {
- return "First click turns TextField into a TextArea (on the client); second click modifies the layout - widget should still be a TextArea.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 5457;
- }
-
-}