diff options
author | Aleksi Hietanen <aleksi@vaadin.com> | 2016-08-10 12:50:44 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2016-08-18 20:05:57 +0300 |
commit | 470deb3e15d96388049f2acb6278a2af4bc81155 (patch) | |
tree | 5a3b8ffbbae2f6e62eb1c6611c16b31d81a2e7b7 /server | |
parent | f3c880194b20b9f9d192e72724865233065ccf04 (diff) | |
download | vaadin-framework-470deb3e15d96388049f2acb6278a2af4bc81155.tar.gz vaadin-framework-470deb3e15d96388049f2acb6278a2af4bc81155.zip |
Implement new PasswordField (#52)
Change-Id: I12236a856403942382633aad5992467576baa7fc
Diffstat (limited to 'server')
3 files changed, 135 insertions, 42 deletions
diff --git a/server/src/main/java/com/vaadin/ui/LoginForm.java b/server/src/main/java/com/vaadin/ui/LoginForm.java index f1270f98e9..0cd2b18cf9 100644 --- a/server/src/main/java/com/vaadin/ui/LoginForm.java +++ b/server/src/main/java/com/vaadin/ui/LoginForm.java @@ -33,7 +33,7 @@ import com.vaadin.v7.ui.LegacyTextField; /** * Login form with auto-completion and auto-fill for all major browsers. You can * derive from this class and implement the - * {@link #createContent(com.vaadin.v7.ui.LegacyTextField, com.vaadin.ui.PasswordField, com.vaadin.ui.Button)} + * {@link #createContent(com.vaadin.ui.TextField, com.vaadin.ui.PasswordField, com.vaadin.ui.Button)} * method to build the layout using the text fields and login button that are * passed to that method. The supplied components are specially treated so that * they work with password managers. @@ -41,7 +41,7 @@ import com.vaadin.v7.ui.LegacyTextField; * If you need to change the URL as part of the login procedure, call * {@link #setLoginMode(LoginMode)} with the argument {@link LoginMode#DEFERRED} * in your implementation of - * {@link #createContent(com.vaadin.v7.ui.LegacyTextField, com.vaadin.ui.PasswordField, com.vaadin.ui.Button) + * {@link #createContent(com.vaadin.ui.TextField, com.vaadin.ui.PasswordField, com.vaadin.ui.Button) * createContent}. * <p> * To customize the fields or to replace them with your own implementations, you @@ -141,9 +141,9 @@ public class LoginForm extends AbstractSingleComponentContainer { * @return the user name field * @since 7.7 */ - protected LegacyTextField createUsernameField() { + protected TextField createUsernameField() { checkInitialized(); - LegacyTextField field = new LegacyTextField(getUsernameCaption()); + TextField field = new TextField(getUsernameCaption()); field.focus(); return field; } @@ -287,7 +287,7 @@ public class LoginForm extends AbstractSingleComponentContainer { * @return content component * @since 7.7 */ - protected Component createContent(LegacyTextField userNameField, + protected Component createContent(TextField userNameField, PasswordField passwordField, Button loginButton) { VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true); @@ -327,8 +327,8 @@ public class LoginForm extends AbstractSingleComponentContainer { getLoginButton())); } - private LegacyTextField getUsernameField() { - return (LegacyTextField) getState().userNameFieldConnector; + private TextField getUsernameField() { + return (TextField) getState().userNameFieldConnector; } private PasswordField getPasswordField() { diff --git a/server/src/main/java/com/vaadin/ui/PasswordField.java b/server/src/main/java/com/vaadin/ui/PasswordField.java index de973a3fb4..9d07d2718a 100644 --- a/server/src/main/java/com/vaadin/ui/PasswordField.java +++ b/server/src/main/java/com/vaadin/ui/PasswordField.java @@ -13,21 +13,20 @@ * License for the specific language governing permissions and limitations under * the License. */ + package com.vaadin.ui; import org.jsoup.nodes.Attributes; import org.jsoup.nodes.Element; -import com.vaadin.data.Property; import com.vaadin.ui.declarative.DesignAttributeHandler; import com.vaadin.ui.declarative.DesignContext; -import com.vaadin.v7.ui.LegacyAbstractTextField; /** * A field that is used to enter secret text information like passwords. The * entered text is not displayed on the screen. */ -public class PasswordField extends LegacyAbstractTextField { +public class PasswordField extends AbstractTextField { /** * Constructs an empty PasswordField. @@ -37,29 +36,6 @@ public class PasswordField extends LegacyAbstractTextField { } /** - * Constructs a PasswordField with given property data source. - * - * @param dataSource - * the property data source for the field - */ - public PasswordField(Property dataSource) { - setPropertyDataSource(dataSource); - } - - /** - * Constructs a PasswordField with given caption and property data source. - * - * @param caption - * the caption for the field - * @param dataSource - * the property data source for the field - */ - public PasswordField(String caption, Property dataSource) { - this(dataSource); - setCaption(caption); - } - - /** * Constructs a PasswordField with given value and caption. * * @param caption @@ -94,8 +70,8 @@ public class PasswordField extends LegacyAbstractTextField { super.readDesign(design, designContext); Attributes attr = design.attributes(); if (attr.hasKey("value")) { - setValue(DesignAttributeHandler.readAttribute("value", attr, - String.class), false, true); + doSetValue(DesignAttributeHandler.readAttribute("value", attr, + String.class)); } } @@ -108,16 +84,10 @@ public class PasswordField extends LegacyAbstractTextField { @Override public void writeDesign(Element design, DesignContext designContext) { super.writeDesign(design, designContext); - LegacyAbstractTextField def = (LegacyAbstractTextField) designContext + AbstractTextField def = (AbstractTextField) designContext .getDefaultInstance(this); Attributes attr = design.attributes(); DesignAttributeHandler.writeAttribute("value", attr, getValue(), def.getValue(), String.class); } - - @Override - public void clear() { - setValue(""); - } - } diff --git a/server/src/main/java/com/vaadin/v7/ui/LegacyPasswordField.java b/server/src/main/java/com/vaadin/v7/ui/LegacyPasswordField.java new file mode 100644 index 0000000000..35916959c8 --- /dev/null +++ b/server/src/main/java/com/vaadin/v7/ui/LegacyPasswordField.java @@ -0,0 +1,123 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.v7.ui; + +import org.jsoup.nodes.Attributes; +import org.jsoup.nodes.Element; + +import com.vaadin.data.Property; +import com.vaadin.ui.declarative.DesignAttributeHandler; +import com.vaadin.ui.declarative.DesignContext; + +/** + * A field that is used to enter secret text information like passwords. The + * entered text is not displayed on the screen. + */ +@Deprecated +public class LegacyPasswordField extends LegacyAbstractTextField { + + /** + * Constructs an empty PasswordField. + */ + public LegacyPasswordField() { + setValue(""); + } + + /** + * Constructs a PasswordField with given property data source. + * + * @param dataSource + * the property data source for the field + */ + public LegacyPasswordField(Property dataSource) { + setPropertyDataSource(dataSource); + } + + /** + * Constructs a PasswordField with given caption and property data source. + * + * @param caption + * the caption for the field + * @param dataSource + * the property data source for the field + */ + public LegacyPasswordField(String caption, Property dataSource) { + this(dataSource); + setCaption(caption); + } + + /** + * Constructs a PasswordField with given value and caption. + * + * @param caption + * the caption for the field + * @param value + * the value for the field + */ + public LegacyPasswordField(String caption, String value) { + setValue(value); + setCaption(caption); + } + + /** + * Constructs a PasswordField with given caption. + * + * @param caption + * the caption for the field + */ + public LegacyPasswordField(String caption) { + this(); + setCaption(caption); + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.ui.AbstractField#readDesign(org.jsoup.nodes.Element , + * com.vaadin.ui.declarative.DesignContext) + */ + @Override + public void readDesign(Element design, DesignContext designContext) { + super.readDesign(design, designContext); + Attributes attr = design.attributes(); + if (attr.hasKey("value")) { + setValue(DesignAttributeHandler.readAttribute("value", attr, + String.class), false, true); + } + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.ui.AbstractTextField#writeDesign(org.jsoup.nodes.Element + * , com.vaadin.ui.declarative.DesignContext) + */ + @Override + public void writeDesign(Element design, DesignContext designContext) { + super.writeDesign(design, designContext); + LegacyAbstractTextField def = (LegacyAbstractTextField) designContext + .getDefaultInstance(this); + Attributes attr = design.attributes(); + DesignAttributeHandler.writeAttribute("value", attr, getValue(), + def.getValue(), String.class); + } + + @Override + public void clear() { + setValue(""); + } + +} |