19 package org.turro.calendar;
21 import java.util.Date;
22 import org.amic.util.date.CheckDate;
23 import org.turro.string.Strings;
24 import org.turro.auth.Authentication;
25 import org.turro.calendar.event.UserCalendarEvent;
26 import org.turro.command.Command;
27 import org.turro.command.Context;
28 import org.turro.elephant.context.ElephantContext;
29 import org.turro.elephant.util.Components;
30 import org.turro.elephant.util.DateFormats;
31 import org.turro.entities.Entities;
32 import org.turro.entities.IElephantEntity;
33 import org.turro.i18n.I_;
34 import org.turro.plugin.calendar.ICalendarEvent;
35 import org.turro.plugin.command.CalendarEventPlugin;
36 import org.turro.util.Chars;
37 import org.zkoss.calendar.event.CalendarsEvent;
38 import org.zkoss.zk.ui.Component;
39 import org.zkoss.zk.ui.Executions;
40 import org.zkoss.zk.ui.event.Event;
41 import org.zkoss.zk.ui.event.Events;
42 import org.zkoss.zk.ui.event.ForwardEvent;
43 import org.zkoss.zk.ui.util.Clients;
44 import org.zkoss.zk.ui.util.GenericForwardComposer;
45 import org.zkoss.zul.Datebox;
46 import org.zkoss.zul.Label;
47 import org.zkoss.zul.Window;
56 private Label currentDate;
57 private Datebox currentBox;
90 calendar.setCurrentDate(java.util.Calendar.getInstance().getTime());
102 Clients.showNotification(
103 I_.
get(
"Copy to clipboard (Ctrl-C)") +
106 "/_reqxdc_/calendar?ses=" +
123 if(!Strings.isBlank(ce.
getPath())) {
135 public void onEventEdit
$calendar(CalendarsEvent event) {
137 if(!Strings.isBlank(calendarEvent.
getPath())) {
148 public void onEventCreate
$calendar(CalendarsEvent event) {
149 if(calendarEventCallback !=
null) {
150 calendarEventCallback.
onCreate(event.getBeginDate(), event.getEndDate());
151 Events.postEvent(
new Event(Events.ON_CLOSE,
Components.
from(calendar).parent(Window.class)));
158 event.getBeginDate(), event.getEndDate(),
162 public Object execute(Context context) {
172 public void onEventUpdate
$calendar(CalendarsEvent event) {
174 if(!Strings.isBlank(calendarEvent.
getPath())) {
175 if(calendarEventCallback !=
null && calendarEvent.
getPath().equals(calendarEventCallback.
getPath())) {
176 calendarEventCallback.
onUpdate(event.getBeginDate(),
event.getEndDate());
177 Events.postEvent(
new Event(Events.ON_CLOSE,
Components.
from(calendar).parent(Window.class)));
185 event.getBeginDate(), event.getEndDate(),
189 public Object execute(Context context) {
201 calendar.setCurrentDate((Date) event.getOrigin().getData());
212 calendar.setCurrentDate(currentBox.getValue());
217 private void setCurrentDate() {
218 Date curr = calendar.getCurrentDate();
221 currentBox.setValue(curr);
223 currentDate.setValue(
224 DateFormats.format(calendar.getBeginDate(),
true) +
225 Chars.forward().spaced().toString() +
226 DateFormats.format(calendar.getEndDate(),
true));
227 currentBox.setValue(calendar.getBeginDate());
229 currentDate.setValue(DateFormats.monthName(curr) +
230 Chars.forward().spaced().toString() +
231 new CheckDate(curr).getYear());
232 currentBox.setValue(calendar.getBeginDate());
239 super.doAfterCompose(comp);
240 calendarEventCallback = (
CalendarEventCallback) Executions.getCurrent().getArg().get(
"eventCallback");
245 private void setTooltips() {
246 Clients.evalJavaScript(
"setTimeout(addTooltips, 1000);");
static IContact getIContact()
void onEventEdit $calendar(CalendarsEvent event)
void onDayClick $calendar(ForwardEvent event)
void onEventUpdate $calendar(CalendarsEvent event)
void doAfterCompose(Component comp)
void onClick $butRefresh()
void onDoubleClick $schedule()
void onChange $currentBox()
void onEventCreate $calendar(CalendarsEvent event)
void onSelect $schedule()
abstract void onUpdate(Date from, Date to)
abstract void onCreate(Date from, Date to)
abstract String getPath()
void process(Command command)
void setMode(CalendarMode mode)
static String getServerUrl(String scheme)
static Components from(Object component)
static IElephantEntity getController(String path)
static String get(String msg)
static Collection< Object > getCalendarEventFor(IContact contact, Date oldFrom, Date oldTo, Date from, Date to, String path, int mode)