BrightSide Workbench Full Report + Source Code
CalendarView.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2012 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.calendar;
20 
21 import java.util.Calendar;
22 import java.util.HashMap;
23 import java.util.Map;
24 import org.turro.auth.Authentication;
25 import org.turro.calendar.model.UserCalendarModel;
26 import org.turro.elephant.context.Application;
27 import org.turro.menu.ElephantMenu;
28 import org.turro.plugin.command.CalendarPlugin;
29 import org.zkoss.calendar.Calendars;
30 import org.zkoss.zk.ui.ext.AfterCompose;
31 
36 public class CalendarView extends Calendars implements AfterCompose {
37 
38  private CalendarMode mode;
39 
40  public CalendarView() {
41  setFirstDayOfWeek(Calendar.getInstance(Application.getUsedLocale()).getFirstDayOfWeek());
42  }
43 
44  public void refreshModel() {
45  UserCalendarModel calendarModel = new UserCalendarModel();
47  Authentication.getIContact(), getBeginDate(), getEndDate()));
48  setModel(calendarModel);
49  }
50 
51  public CalendarMode getMode() {
52  return mode;
53  }
54 
55  public void setMode(CalendarMode mode) {
56  this.mode = mode;
57  setDays(mode.getDays());
58  setMold(mode.getMold());
59  }
60 
61  public void setMode(String key) {
63  }
64 
65  @Override
66  public void afterCompose() {
67  refreshModel();
68  }
69 
70  @Override
71  public void previousPage() {
72  super.previousPage();
73  refreshModel();
74  }
75 
76  @Override
77  public void nextPage() {
78  super.nextPage();
79  refreshModel();
80  }
81 
82  public static void showCalendar(CalendarEventCallback eventCreateCallback) {
83  Map<String, Object> args = new HashMap<>();
84  args.put("eventCallback", eventCreateCallback);
85  ElephantMenu.showModalZulFile("Calendar", "/calendar/calendarModal.zul", args, null);
86  }
87 
88 }
void setMode(CalendarMode mode)
static void showCalendar(CalendarEventCallback eventCreateCallback)
static void showModalZulFile(String label, String source, Command command)
static Collection< Object > getCalendarFor(IContact contact, Date from, Date to)
static CalendarMode getByKey(String key)