@Override public Action[] getActions(Object target, Object sender) { // The target should be a CalendarDateRage for the // entire day from midnight to midnight. if (!(target instanceof CalendarDateRange)) return null; CalendarDateRange dateRange = (CalendarDateRange) target; // The sender is the Calendar object if (!(sender instanceof Calendar)) return null; Calendar calendar = (Calendar) sender; // List all the events on the requested day List<CalendarEvent> events = calendar.getEvents(dateRange.getStart(), dateRange.getEnd()); if (events.size() == 0) return new Action[]{addEventAction}; else return new Action[]{addEventAction, copyEventAction, deleteEventAction}; }
protected FactAndPlan[] calculateSummariesByWeeks() { Date start = firstDayOfMonth; java.util.Calendar javaCalendar = java.util.Calendar.getInstance(userSession.getLocale()); javaCalendar.setMinimalDaysInFirstWeek(1); javaCalendar.setTime(firstDayOfMonth); int countOfWeeksInTheMonth = javaCalendar.getActualMaximum(java.util.Calendar.WEEK_OF_MONTH); Date lastDayOfMonth = DateUtils.addHours(DateTimeUtils.getLastDayOfMonth(firstDayOfMonth), 23); FactAndPlan[] summariesByWeeks = new FactAndPlan[countOfWeeksInTheMonth + 1]; for (int i = 0; i < countOfWeeksInTheMonth; i++) { Date firstDayOfWeek = DateTimeUtils.getFirstDayOfWeek(start); Date lastDayOfWeek = DateUtils.addHours(DateTimeUtils.getLastDayOfWeek(start), 23); if (firstDayOfWeek.getTime() < firstDayOfMonth.getTime()) { firstDayOfWeek = firstDayOfMonth; } if (lastDayOfWeek.getTime() > lastDayOfMonth.getTime()) { lastDayOfWeek = lastDayOfMonth; } FactAndPlan summaryForTheWeek = new FactAndPlan(); User currentOrSubstitutedUser = userSession.getCurrentOrSubstitutedUser(); summaryForTheWeek.fact.setTime( validationTools.actualWorkHoursForPeriod(firstDayOfWeek, lastDayOfWeek, currentOrSubstitutedUser) ); summaryForTheWeek.plan.setTime( validationTools.workHoursForPeriod(firstDayOfWeek, lastDayOfWeek, currentOrSubstitutedUser) ); summariesByWeeks[i + 1] = summaryForTheWeek; start = DateUtils.addWeeks(start, 1); } return summariesByWeeks; }
@SuppressWarnings("unchecked") ScoutsContainerEventProvider(final Calendar calendar) { super(new DaoFactory().getEventDao().createVaadinContainer()); this.calendar = calendar; this.container = (JPAContainer<Event>) super.getContainerDataSource(); setStartDateProperty(Event_.eventStartDateTime.getName()); setEndDateProperty(Event_.eventEndDateTime.getName()); setDescriptionProperty(Event_.details.getName()); setCaptionProperty(Event_.subject.getName()); }
protected String getMonthName(Date firstDayOfMonth) { return DateUtils.toCalendar(firstDayOfMonth).getDisplayName(java.util.Calendar.MONTH, java.util.Calendar.LONG, userSession.getLocale()); }
protected int getYear(Date firstDayOfMonth) { return DateUtils.toCalendar(firstDayOfMonth).get(java.util.Calendar.YEAR); }
IntervalChangeListener(final Calendar calendar, final CalendarView view) { this.calendar = calendar; this.view = view; }