You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

InlineDateField.java 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * Copyright 2000-2016 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.ui;
  17. import java.time.LocalDate;
  18. import com.vaadin.shared.ui.datefield.InlineDateFieldState;
  19. /**
  20. * A date entry component, which displays the actual date selector inline.
  21. *
  22. * @see AbstractLocalDateField
  23. * @see DateField
  24. * @author Vaadin Ltd.
  25. * @since 8.0
  26. */
  27. public class InlineDateField extends AbstractLocalDateField {
  28. /**
  29. * Constructs an empty <code>InlineDateField</code> with no caption.
  30. */
  31. public InlineDateField() {
  32. super();
  33. }
  34. /**
  35. * Constructs a new <code>InlineDateField</code> with the given caption and
  36. * initial text contents.
  37. *
  38. * @param caption
  39. * the caption <code>String</code> for the editor.
  40. * @param value
  41. * the LocalDate value.
  42. */
  43. public InlineDateField(String caption, LocalDate value) {
  44. super(caption, value);
  45. }
  46. /**
  47. * Constructs an empty <code>InlineDateField</code> with caption.
  48. *
  49. * @param caption
  50. * the caption of the datefield.
  51. */
  52. public InlineDateField(String caption) {
  53. super(caption);
  54. }
  55. /**
  56. * Constructs a new {@code InlineDateField} with a value change listener.
  57. * <p>
  58. * The listener is called when the value of this {@code InlineDateField} is
  59. * changed either by the user or programmatically.
  60. *
  61. * @param valueChangeListener
  62. * the value change listener, not {@code null}
  63. */
  64. public InlineDateField(ValueChangeListener<LocalDate> valueChangeListener) {
  65. super();
  66. addValueChangeListener(valueChangeListener);
  67. }
  68. /**
  69. * Constructs a new {@code InlineDateField} with the given caption and a
  70. * value change listener.
  71. * <p>
  72. * The listener is called when the value of this {@code InlineDateField} is
  73. * changed either by the user or programmatically.
  74. *
  75. * @param caption
  76. * the caption for the field
  77. * @param valueChangeListener
  78. * the value change listener, not {@code null}
  79. */
  80. public InlineDateField(String caption,
  81. ValueChangeListener<LocalDate> valueChangeListener) {
  82. this(valueChangeListener);
  83. setCaption(caption);
  84. }
  85. /**
  86. * Constructs a new {@code InlineDateField} with the given caption, initial
  87. * text contents and a value change listener.
  88. * <p>
  89. * The listener is called when the value of this {@code InlineDateField} is
  90. * changed either by the user or programmatically.
  91. *
  92. * @param caption
  93. * the caption for the field
  94. * @param value
  95. * the value for the field, not {@code null}
  96. * @param valueChangeListener
  97. * the value change listener, not {@code null}
  98. */
  99. public InlineDateField(String caption, LocalDate value,
  100. ValueChangeListener<LocalDate> valueChangeListener) {
  101. this(caption, value);
  102. addValueChangeListener(valueChangeListener);
  103. }
  104. @Override
  105. protected InlineDateFieldState getState() {
  106. return (InlineDateFieldState) super.getState();
  107. }
  108. @Override
  109. protected InlineDateFieldState getState(boolean markAsDirty) {
  110. return (InlineDateFieldState) super.getState(markAsDirty);
  111. }
  112. }