diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2016-03-10 22:40:51 +0200 |
---|---|---|
committer | Teemu Suo-Anttila <teemusa@vaadin.com> | 2016-03-14 07:59:12 +0200 |
commit | a6653d3fe49e6a97468ac09f7f2f4d621bea1078 (patch) | |
tree | 96c82e20ca6551ee4c14c8877f0258b25c63cddf /server/src/com/vaadin/ui/components/calendar/event/BasicEventProvider.java | |
parent | f7e57d77ce621ee39167369c31d989edc5633266 (diff) | |
download | vaadin-framework-a6653d3fe49e6a97468ac09f7f2f4d621bea1078.tar.gz vaadin-framework-a6653d3fe49e6a97468ac09f7f2f4d621bea1078.zip |
Migrate vaadin-server build to maven
Change-Id: I5c740f4e9cb28103bab199f9a552153d82277e7e
Diffstat (limited to 'server/src/com/vaadin/ui/components/calendar/event/BasicEventProvider.java')
-rw-r--r-- | server/src/com/vaadin/ui/components/calendar/event/BasicEventProvider.java | 179 |
1 files changed, 0 insertions, 179 deletions
diff --git a/server/src/com/vaadin/ui/components/calendar/event/BasicEventProvider.java b/server/src/com/vaadin/ui/components/calendar/event/BasicEventProvider.java deleted file mode 100644 index 9fa6baadad..0000000000 --- a/server/src/com/vaadin/ui/components/calendar/event/BasicEventProvider.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright 2000-2014 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.ui.components.calendar.event; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import com.vaadin.ui.components.calendar.event.CalendarEvent.EventChangeEvent; -import com.vaadin.ui.components.calendar.event.CalendarEventProvider.EventSetChangeNotifier; - -/** - * <p> - * Simple implementation of - * {@link com.vaadin.addon.calendar.event.CalendarEventProvider - * CalendarEventProvider}. Use {@link #addEvent(CalendarEvent)} and - * {@link #removeEvent(CalendarEvent)} to add / remove events. - * </p> - * - * <p> - * {@link com.vaadin.addon.calendar.event.CalendarEventProvider.EventSetChangeNotifier - * EventSetChangeNotifier} and - * {@link com.vaadin.addon.calendar.event.CalendarEvent.EventChangeListener - * EventChangeListener} are also implemented, so the Calendar is notified when - * an event is added, changed or removed. - * </p> - * - * @since 7.1.0 - * @author Vaadin Ltd. - */ -@SuppressWarnings("serial") -public class BasicEventProvider implements CalendarEditableEventProvider, - EventSetChangeNotifier, CalendarEvent.EventChangeListener { - - protected List<CalendarEvent> eventList = new ArrayList<CalendarEvent>(); - - private List<EventSetChangeListener> listeners = new ArrayList<EventSetChangeListener>(); - - /* - * (non-Javadoc) - * - * @see - * com.vaadin.addon.calendar.event.CalendarEventProvider#getEvents(java. - * util.Date, java.util.Date) - */ - @Override - public List<CalendarEvent> getEvents(Date startDate, Date endDate) { - ArrayList<CalendarEvent> activeEvents = new ArrayList<CalendarEvent>(); - - for (CalendarEvent ev : eventList) { - long from = startDate.getTime(); - long to = endDate.getTime(); - - if (ev.getStart() != null && ev.getEnd() != null) { - long f = ev.getStart().getTime(); - long t = ev.getEnd().getTime(); - // Select only events that overlaps with startDate and - // endDate. - if ((f <= to && f >= from) || (t >= from && t <= to) - || (f <= from && t >= to)) { - activeEvents.add(ev); - } - } - } - - return activeEvents; - } - - /** - * Does this event provider container this event - * - * @param event - * The event to check for - * @return If this provider has the event then true is returned, else false - */ - public boolean containsEvent(BasicEvent event) { - return eventList.contains(event); - } - - /* - * (non-Javadoc) - * - * @see - * com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventSetChangeNotifier - * #addListener - * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventSetChangeListener - * ) - */ - @Override - public void addEventSetChangeListener(EventSetChangeListener listener) { - listeners.add(listener); - - } - - /* - * (non-Javadoc) - * - * @see - * com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventSetChangeNotifier - * #removeListener - * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventSetChangeListener - * ) - */ - @Override - public void removeEventSetChangeListener(EventSetChangeListener listener) { - listeners.remove(listener); - } - - /** - * Fires a eventsetchange event. The event is fired when either an event is - * added or removed to the event provider - */ - protected void fireEventSetChange() { - EventSetChangeEvent event = new EventSetChangeEvent(this); - - for (EventSetChangeListener listener : listeners) { - listener.eventSetChange(event); - } - } - - /* - * (non-Javadoc) - * - * @see - * com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventChangeListener - * #eventChange - * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventSetChange) - */ - @Override - public void eventChange(EventChangeEvent changeEvent) { - // naive implementation - fireEventSetChange(); - } - - /* - * (non-Javadoc) - * - * @see - * com.vaadin.addon.calendar.event.CalendarEditableEventProvider#addEvent - * (com.vaadin.addon.calendar.event.CalendarEvent) - */ - @Override - public void addEvent(CalendarEvent event) { - eventList.add(event); - if (event instanceof BasicEvent) { - ((BasicEvent) event).addEventChangeListener(this); - } - fireEventSetChange(); - } - - /* - * (non-Javadoc) - * - * @see - * com.vaadin.addon.calendar.event.CalendarEditableEventProvider#removeEvent - * (com.vaadin.addon.calendar.event.CalendarEvent) - */ - @Override - public void removeEvent(CalendarEvent event) { - eventList.remove(event); - if (event instanceof BasicEvent) { - ((BasicEvent) event).removeEventChangeListener(this); - } - fireEventSetChange(); - } -} |