2 * Copyright 2000-2018 Vaadin Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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
16 package com.vaadin.v7.ui.components.calendar.handler;
18 import java.util.Calendar;
19 import java.util.Date;
21 import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.DateClickEvent;
22 import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.DateClickHandler;
25 * Implements basic functionality needed to switch to day view when a single day
31 @SuppressWarnings("serial")
33 public class BasicDateClickHandler implements DateClickHandler {
39 * com.vaadin.addon.calendar.ui.CalendarComponentEvents.DateClickHandler
41 * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.DateClickEvent)
44 public void dateClick(DateClickEvent event) {
45 Date clickedDate = event.getDate();
47 Calendar javaCalendar = event.getComponent().getInternalCalendar();
48 javaCalendar.setTime(clickedDate);
50 // as times are expanded, this is all that is needed to show one day
51 Date start = javaCalendar.getTime();
52 Date end = javaCalendar.getTime();
54 setDates(event, start, end);
58 * Set the start and end dates for the event.
61 * The event that the start and end dates should be set
67 protected void setDates(DateClickEvent event, Date start, Date end) {
68 event.getComponent().setStartDate(start);
69 event.getComponent().setEndDate(end);