BrightSide Workbench Full Report + Source Code
CalendarInfo.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2015 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.info;
20 
21 import java.util.Calendar;
22 import java.util.logging.Level;
23 import java.util.logging.Logger;
24 import org.turro.collections.parser.ParserException;
25 import org.turro.action.Events;
26 import org.turro.calendar.CalendarMode;
27 import org.turro.calendar.model.UserCalendarModel;
28 import org.turro.collections.KeyValueMap;
29 import org.turro.elephant.context.Application;
30 import org.turro.elephant.context.ElephantContext;
31 import org.zkoss.calendar.Calendars;
32 import org.zkoss.zk.ui.ext.AfterCompose;
33 
38 public class CalendarInfo extends Calendars implements AfterCompose {
39 
40  private CalendarMode mode;
41  private String args;
42 
43  public CalendarInfo() {
44  setFirstDayOfWeek(Calendar.getInstance(Application.getUsedLocale()).getFirstDayOfWeek());
45  }
46 
47  public void refreshModel() {
48  try {
49  KeyValueMap kvm = new KeyValueMap(args);
50  UserCalendarModel calendarModel = new UserCalendarModel();
51  calendarModel.setICalendarEventList(Events.getPublicEvents(getBeginDate(), getEndDate(), kvm));
52  setModel(calendarModel);
53  } catch (ParserException ex) {
54  Logger.getLogger(CalendarInfo.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
55  }
56  }
57 
58  public String getArgs() {
59  return args;
60  }
61 
62  public void setArgs(String args) {
63  this.args = args;
64  }
65 
66  public CalendarMode getMode() {
67  return mode;
68  }
69 
70  public void setMode(CalendarMode mode) {
71  this.mode = mode;
72  setDays(mode.getDays());
73  setMold(mode.getMold());
74  }
75 
76  public void setMode(String key) {
78  }
79 
80  @Override
81  public void afterCompose() {
82  refreshModel();
83  }
84 
85  @Override
86  public void previousPage() {
87  super.previousPage();
88  refreshModel();
89  }
90 
91  @Override
92  public void nextPage() {
93  super.nextPage();
94  refreshModel();
95  }
96 
97 }
static Collection< ICalendarEvent > getPublicEvents(Date start, Date end, HashMap< String, String > args)
Definition: Events.java:40
void setMode(CalendarMode mode)
static CalendarMode getByKey(String key)