19 package org.turro.scheduler.model;
21 import java.text.DateFormatSymbols;
22 import org.turro.elephant.context.Application;
23 import org.turro.i18n.I_;
24 import org.turro.scheduler.task.AbstractTask;
25 import org.turro.scheduler.task.constraints.Month;
26 import org.turro.scheduler.task.constraints.WeekDay;
27 import org.turro.string.Strings;
28 import org.zkoss.zk.ui.event.Event;
29 import org.zkoss.zk.ui.event.EventListener;
30 import org.zkoss.zk.ui.event.Events;
31 import org.zkoss.zul.Caption;
32 import org.zkoss.zul.Checkbox;
33 import org.zkoss.zul.Groupbox;
34 import org.zkoss.zul.Hlayout;
35 import org.zkoss.zul.Vlayout;
44 private final Checkbox[] months =
new Checkbox[12];
45 private final Checkbox[] daysOfMonth =
new Checkbox[31];
46 private final Checkbox[] weekDays =
new Checkbox[7];
47 private final Checkbox[] hours =
new Checkbox[24];
48 private final Checkbox[] minutes =
new Checkbox[12];
64 months[month.ordinal()].setDisabled(task.
isSystem());
66 for(
int x = 0; x < 31; x++) {
68 daysOfMonth[x].setDisabled(task.
isSystem());
72 weekDays[weekDay.ordinal()].setDisabled(task.
isSystem());
74 for(
int x = 0; x < 24; x++) {
76 hours[x].setDisabled(task.
isSystem());
78 for(
int x = 0; x < 12; x++) {
80 minutes[x].setDisabled(task.
isSystem());
85 private void initMonth() {
86 EventListener<? extends Event> listener = (Event event) -> {
87 Checkbox ck = (Checkbox) event.getTarget();
94 Groupbox box =
new Groupbox();
97 box.appendChild(
new Caption(I_.get(
"Months")));
98 Vlayout vbox =
new Vlayout();
99 box.appendChild(vbox);
100 for(Month m : Month.values()) {
101 months[m.ordinal()] =
new Checkbox(Strings.capitalize(dfs.getMonths()[m.ordinal()]));
102 months[m.ordinal()].setValue(m);
103 months[m.ordinal()].addEventListener(Events.ON_CHECK, listener);
104 vbox.appendChild(months[m.ordinal()]);
108 private void initDayOfMonth() {
109 EventListener<? extends Event> listener = (Event event) -> {
110 Checkbox ck = (Checkbox) event.getTarget();
117 Groupbox box =
new Groupbox();
120 box.appendChild(
new Caption(I_.get(
"Days of month")));
121 Hlayout hbox =
new Hlayout();
122 box.appendChild(hbox);
124 for(
int x = 0; x < 31; x++) {
126 vbox =
new Vlayout();
127 hbox.appendChild(vbox);
129 daysOfMonth[x] =
new Checkbox((x + 1) +
"");
130 daysOfMonth[x].setValue(x + 1);
131 daysOfMonth[x].addEventListener(Events.ON_CHECK, listener);
132 vbox.appendChild(daysOfMonth[x]);
136 private void initWeekDays() {
137 EventListener<? extends Event> listener = (Event event) -> {
138 Checkbox ck = (Checkbox) event.getTarget();
145 Groupbox box =
new Groupbox();
148 box.appendChild(
new Caption(I_.get(
"Days of week")));
149 Vlayout vbox =
new Vlayout();
150 box.appendChild(vbox);
151 for(WeekDay wd : WeekDay.values()) {
152 weekDays[wd.ordinal()] =
new Checkbox(Strings.capitalize(dfs.getWeekdays()[WeekDay.map(wd.ordinal())]));
153 weekDays[wd.ordinal()].setValue(wd);
154 weekDays[wd.ordinal()].addEventListener(Events.ON_CHECK, listener);
155 vbox.appendChild(weekDays[wd.ordinal()]);
159 private void initHours() {
160 EventListener<? extends Event> listener = (Event event) -> {
161 Checkbox ck = (Checkbox) event.getTarget();
168 Groupbox box =
new Groupbox();
171 box.appendChild(
new Caption(I_.get(
"Hours")));
172 Hlayout hbox =
new Hlayout();
173 box.appendChild(hbox);
175 for(
int x = 0; x < 24; x++) {
177 vbox =
new Vlayout();
178 hbox.appendChild(vbox);
180 hours[x] =
new Checkbox(x +
"");
181 hours[x].setValue(x);
182 hours[x].addEventListener(Events.ON_CHECK, listener);
183 vbox.appendChild(hours[x]);
187 private void initMinutes() {
188 EventListener<? extends Event> listener = (Event event) -> {
189 Checkbox ck = (Checkbox) event.getTarget();
196 Groupbox box =
new Groupbox();
199 box.appendChild(
new Caption(I_.get(
"Minutes")));
200 Vlayout vbox =
new Vlayout();
201 box.appendChild(vbox);
202 for(
int x = 0; x < 12; x++) {
203 minutes[x] =
new Checkbox((x * 5) +
"");
204 minutes[x].setValue(x * 5);
205 minutes[x].addEventListener(Events.ON_CHECK, listener);
206 vbox.appendChild(minutes[x]);
static Locale getUsedLocale()
void setTask(AbstractTask task)
TaskSettings getSettings()
abstract boolean isSystem()
WeekDayConstraint getWeekDays()
MinuteConstraint getMinutes()
MonthConstraint getMonths()
HourConstraint getHours()
DayOfMonthConstraint getDaysOfMonth()
TaskConstraints getConstraints()