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.

InlineDateTimeField.java 3.9KB

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