Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

PasswordField.java 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. * Copyright 2000-2018 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.v7.ui;
  17. import org.jsoup.nodes.Attributes;
  18. import org.jsoup.nodes.Element;
  19. import com.vaadin.ui.declarative.DesignAttributeHandler;
  20. import com.vaadin.ui.declarative.DesignContext;
  21. import com.vaadin.v7.data.Property;
  22. /**
  23. * A field that is used to enter secret text information like passwords. The
  24. * entered text is not displayed on the screen.
  25. *
  26. * @deprecated As of 8.0 replaced by {@link com.vaadin.ui.PasswordField} based
  27. * on the new data binding API
  28. */
  29. @Deprecated
  30. public class PasswordField extends AbstractTextField {
  31. /**
  32. * Constructs an empty PasswordField.
  33. */
  34. public PasswordField() {
  35. setValue("");
  36. }
  37. /**
  38. * Constructs a PasswordField with given property data source.
  39. *
  40. * @param dataSource
  41. * the property data source for the field
  42. */
  43. public PasswordField(Property dataSource) {
  44. setPropertyDataSource(dataSource);
  45. }
  46. /**
  47. * Constructs a PasswordField with given caption and property data source.
  48. *
  49. * @param caption
  50. * the caption for the field
  51. * @param dataSource
  52. * the property data source for the field
  53. */
  54. public PasswordField(String caption, Property dataSource) {
  55. this(dataSource);
  56. setCaption(caption);
  57. }
  58. /**
  59. * Constructs a PasswordField with given value and caption.
  60. *
  61. * @param caption
  62. * the caption for the field
  63. * @param value
  64. * the value for the field
  65. */
  66. public PasswordField(String caption, String value) {
  67. setValue(value);
  68. setCaption(caption);
  69. }
  70. /**
  71. * Constructs a PasswordField with given caption.
  72. *
  73. * @param caption
  74. * the caption for the field
  75. */
  76. public PasswordField(String caption) {
  77. this();
  78. setCaption(caption);
  79. }
  80. /*
  81. * (non-Javadoc)
  82. *
  83. * @see com.vaadin.ui.AbstractField#readDesign(org.jsoup.nodes.Element ,
  84. * com.vaadin.ui.declarative.DesignContext)
  85. */
  86. @Override
  87. public void readDesign(Element design, DesignContext designContext) {
  88. super.readDesign(design, designContext);
  89. Attributes attr = design.attributes();
  90. if (attr.hasKey("value")) {
  91. setValue(DesignAttributeHandler.readAttribute("value", attr,
  92. String.class), false, true);
  93. }
  94. }
  95. /*
  96. * (non-Javadoc)
  97. *
  98. * @see com.vaadin.ui.AbstractTextField#writeDesign(org.jsoup.nodes.Element
  99. * , com.vaadin.ui.declarative.DesignContext)
  100. */
  101. @Override
  102. public void writeDesign(Element design, DesignContext designContext) {
  103. super.writeDesign(design, designContext);
  104. AbstractTextField def = (AbstractTextField) designContext
  105. .getDefaultInstance(this);
  106. Attributes attr = design.attributes();
  107. DesignAttributeHandler.writeAttribute("value", attr, getValue(),
  108. def.getValue(), String.class, designContext);
  109. }
  110. @Override
  111. public void clear() {
  112. setValue("");
  113. }
  114. }