private void setActionsForDay(Map<CalendarDateRange, Set<Action>> actionMap, Date start, Date end, Action.Handler actionHandler) { CalendarDateRange range = new CalendarDateRange(start, end, getTimeZone()); Action[] actions = actionHandler.getActions(range, this); if (actions != null) { Set<Action> actionSet = new LinkedHashSet<Action>( Arrays.asList(actions)); actionMap.put(range, actionSet); } }
@Override public void actionOnEvent(String actionKey, String startDate, String endDate, int eventIndex) { Action action = actionMapper.get(actionKey); SimpleDateFormat formatter = new SimpleDateFormat( DateConstants.ACTION_DATE_FORMAT_PATTERN); formatter.setTimeZone(getTimeZone()); for (Action.Handler ah : actionHandlers) { ah.handleAction(action, Calendar.this, events.get(eventIndex)); } } }
@Override public void writeDesign(Element design, DesignContext designContext) { super.writeDesign(design, designContext); if (currentTimeFormat != null) { design.attr("time-format", currentTimeFormat == TimeFormat.Format12H ? "12h" : "24h"); } if (startDate != null) { design.attr("start-date", df_date.format(getStartDate())); } if (endDate != null) { design.attr("end-date", df_date.format(getEndDate())); } if (!getTimeZone().equals(TimeZone.getDefault())) { design.attr("time-zone", getTimeZone().getID()); } }
private void setActionsForEachHalfHour( Map<CalendarDateRange, Set<Action>> actionMap, Date start, Date end, Action.Handler actionHandler) { GregorianCalendar cal = new GregorianCalendar(getTimeZone(), getLocale()); cal.setTime(start); while (cal.getTime().before(end)) { Date s = cal.getTime(); cal.add(java.util.Calendar.MINUTE, 30); Date e = cal.getTime(); CalendarDateRange range = new CalendarDateRange(s, e, getTimeZone()); Action[] actions = actionHandler.getActions(range, this); if (actions != null) { Set<Action> actionSet = new LinkedHashSet<Action>( Arrays.asList(actions)); actionMap.put(range, actionSet); } } }
@Override public void actionOnEmptyCell(String actionKey, String startDate, String endDate) { Action action = actionMapper.get(actionKey); SimpleDateFormat formatter = new SimpleDateFormat( DateConstants.ACTION_DATE_FORMAT_PATTERN); formatter.setTimeZone(getTimeZone()); try { Date start = formatter.parse(startDate); for (Action.Handler ah : actionHandlers) { ah.handleAction(action, Calendar.this, start); } } catch (ParseException e) { getLogger().log(Level.WARNING, "Could not parse action date string"); } }
private List<CalendarState.Action> createActionsList( Map<CalendarDateRange, Set<Action>> actionMap) { if (actionMap.isEmpty()) { return null; } List<CalendarState.Action> calendarActions = new ArrayList<CalendarState.Action>(); SimpleDateFormat formatter = new SimpleDateFormat( DateConstants.ACTION_DATE_FORMAT_PATTERN); formatter.setTimeZone(getTimeZone()); for (Entry<CalendarDateRange, Set<Action>> entry : actionMap .entrySet()) { CalendarDateRange range = entry.getKey(); Set<Action> actions = entry.getValue(); for (Action action : actions) { String key = actionMapper.key(action); CalendarState.Action calendarAction = new CalendarState.Action(); calendarAction.actionKey = key; calendarAction.caption = action.getCaption(); setResource(key, action.getIcon()); calendarAction.iconKey = key; calendarAction.startDate = formatter.format(range.getStart()); calendarAction.endDate = formatter.format(range.getEnd()); calendarActions.add(calendarAction); } } return calendarActions; }
GregorianCalendar cal = new GregorianCalendar(getTimeZone(), getLocale()); cal.clear();