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.

BasicEvent.java 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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.v7.ui.components.calendar.event;
  17. import java.util.ArrayList;
  18. import java.util.Date;
  19. import java.util.List;
  20. import com.vaadin.v7.ui.components.calendar.event.CalendarEvent.EventChangeNotifier;
  21. /**
  22. * Simple implementation of {@link com.vaadin.addon.calendar.event.CalendarEvent
  23. * CalendarEvent}. Has setters for all required fields and fires events when
  24. * this event is changed.
  25. *
  26. * @since 7.1.0
  27. * @author Vaadin Ltd.
  28. */
  29. @SuppressWarnings("serial")
  30. @Deprecated
  31. public class BasicEvent implements EditableCalendarEvent, EventChangeNotifier {
  32. private String caption;
  33. private String description;
  34. private Date end;
  35. private Date start;
  36. private String styleName;
  37. private transient List<EventChangeListener> listeners = new ArrayList<EventChangeListener>();
  38. private boolean isAllDay;
  39. /**
  40. * Default constructor
  41. */
  42. public BasicEvent() {
  43. }
  44. /**
  45. * Constructor for creating an event with the same start and end date
  46. *
  47. * @param caption
  48. * The caption for the event
  49. * @param description
  50. * The description for the event
  51. * @param date
  52. * The date the event occurred
  53. */
  54. public BasicEvent(String caption, String description, Date date) {
  55. this.caption = caption;
  56. this.description = description;
  57. start = date;
  58. end = date;
  59. }
  60. /**
  61. * Constructor for creating an event with a start date and an end date.
  62. * Start date should be before the end date
  63. *
  64. * @param caption
  65. * The caption for the event
  66. * @param description
  67. * The description for the event
  68. * @param startDate
  69. * The start date of the event
  70. * @param endDate
  71. * The end date of the event
  72. */
  73. public BasicEvent(String caption, String description, Date startDate,
  74. Date endDate) {
  75. this.caption = caption;
  76. this.description = description;
  77. start = startDate;
  78. end = endDate;
  79. }
  80. /*
  81. * (non-Javadoc)
  82. *
  83. * @see com.vaadin.addon.calendar.event.CalendarEvent#getCaption()
  84. */
  85. @Override
  86. public String getCaption() {
  87. return caption;
  88. }
  89. /*
  90. * (non-Javadoc)
  91. *
  92. * @see com.vaadin.addon.calendar.event.CalendarEvent#getDescription()
  93. */
  94. @Override
  95. public String getDescription() {
  96. return description;
  97. }
  98. /*
  99. * (non-Javadoc)
  100. *
  101. * @see com.vaadin.addon.calendar.event.CalendarEvent#getEnd()
  102. */
  103. @Override
  104. public Date getEnd() {
  105. return end;
  106. }
  107. /*
  108. * (non-Javadoc)
  109. *
  110. * @see com.vaadin.addon.calendar.event.CalendarEvent#getStart()
  111. */
  112. @Override
  113. public Date getStart() {
  114. return start;
  115. }
  116. /*
  117. * (non-Javadoc)
  118. *
  119. * @see com.vaadin.addon.calendar.event.CalendarEvent#getStyleName()
  120. */
  121. @Override
  122. public String getStyleName() {
  123. return styleName;
  124. }
  125. /*
  126. * (non-Javadoc)
  127. *
  128. * @see com.vaadin.addon.calendar.event.CalendarEvent#isAllDay()
  129. */
  130. @Override
  131. public boolean isAllDay() {
  132. return isAllDay;
  133. }
  134. /*
  135. * (non-Javadoc)
  136. *
  137. * @see
  138. * com.vaadin.addon.calendar.event.CalendarEventEditor#setCaption(java.lang
  139. * .String)
  140. */
  141. @Override
  142. public void setCaption(String caption) {
  143. this.caption = caption;
  144. fireEventChange();
  145. }
  146. /*
  147. * (non-Javadoc)
  148. *
  149. * @see
  150. * com.vaadin.addon.calendar.event.CalendarEventEditor#setDescription(java
  151. * .lang.String)
  152. */
  153. @Override
  154. public void setDescription(String description) {
  155. this.description = description;
  156. fireEventChange();
  157. }
  158. /*
  159. * (non-Javadoc)
  160. *
  161. * @see
  162. * com.vaadin.addon.calendar.event.CalendarEventEditor#setEnd(java.util.
  163. * Date)
  164. */
  165. @Override
  166. public void setEnd(Date end) {
  167. this.end = end;
  168. fireEventChange();
  169. }
  170. /*
  171. * (non-Javadoc)
  172. *
  173. * @see
  174. * com.vaadin.addon.calendar.event.CalendarEventEditor#setStart(java.util
  175. * .Date)
  176. */
  177. @Override
  178. public void setStart(Date start) {
  179. this.start = start;
  180. fireEventChange();
  181. }
  182. /*
  183. * (non-Javadoc)
  184. *
  185. * @see
  186. * com.vaadin.addon.calendar.event.CalendarEventEditor#setStyleName(java
  187. * .lang.String)
  188. */
  189. @Override
  190. public void setStyleName(String styleName) {
  191. this.styleName = styleName;
  192. fireEventChange();
  193. }
  194. /*
  195. * (non-Javadoc)
  196. *
  197. * @see
  198. * com.vaadin.addon.calendar.event.CalendarEventEditor#setAllDay(boolean)
  199. */
  200. @Override
  201. public void setAllDay(boolean isAllDay) {
  202. this.isAllDay = isAllDay;
  203. fireEventChange();
  204. }
  205. /*
  206. * (non-Javadoc)
  207. *
  208. * @see
  209. * com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventChangeNotifier
  210. * #addListener
  211. * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventChangeListener
  212. * )
  213. */
  214. @Override
  215. public void addEventChangeListener(EventChangeListener listener) {
  216. listeners.add(listener);
  217. }
  218. /*
  219. * (non-Javadoc)
  220. *
  221. * @see
  222. * com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventChangeNotifier
  223. * #removeListener
  224. * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventChangeListener
  225. * )
  226. */
  227. @Override
  228. public void removeEventChangeListener(EventChangeListener listener) {
  229. listeners.remove(listener);
  230. }
  231. /**
  232. * Fires an event change event to the listeners. Should be triggered when
  233. * some property of the event changes.
  234. */
  235. protected void fireEventChange() {
  236. EventChangeEvent event = new EventChangeEvent(this);
  237. for (EventChangeListener listener : listeners) {
  238. listener.eventChange(event);
  239. }
  240. }
  241. }