BrightSide Workbench Full Report + Source Code
TimeList.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.erp.time;
20 
21 import java.util.Date;
22 import java.util.List;
23 import org.amic.util.date.CheckDate;
24 import org.turro.erp.entity.TimeControl;
25 import org.turro.zkoss.label.LabelTypes;
26 import org.zkoss.text.DateFormats;
27 import org.zkoss.zul.Grid;
28 import org.zkoss.zul.Label;
29 import org.zkoss.zul.Row;
30 import org.zkoss.zul.Rows;
31 import org.zkoss.zul.Vlayout;
32 
37 public class TimeList extends Grid {
38 
39  public void setDate(Date date) {
40  Rows rows = getRows();
41  if(rows != null) {
42  rows.getChildren().clear();
43  } else {
44  rows = new Rows();
45  appendChild(rows);
46  }
47 
48  TimeControlUtil tcu = new TimeControlUtil();
49  List<TimeControl> registered = tcu.getFromDate(date);
50  long absoluteDays = CheckDate.absoluteDays(date);
51 
52  for(TimeControl tc : registered) {
53  final Row row = new Row();
54  row.setValue(tc);
55  rows.appendChild(row);
56 
57  Vlayout vbox = new Vlayout();
58  row.appendChild(vbox);
59  vbox.appendChild(new Label(tc.getHumanResource().getName()));
60  if(tc.getTask() != null) {
61  vbox.appendChild(LabelTypes.getSoftLabel(tc.getTask().getFullDescription()));
62  }
63  vbox = new Vlayout();
64  row.appendChild(vbox);
65  vbox.appendChild(new Label(new CheckDate(tc.getStartTime()).formatDate("HH:mm:ss")));
66  if(tc.getStartTime() != null && CheckDate.absoluteDays(tc.getStartTime()) != absoluteDays) {
67  vbox.appendChild(LabelTypes.getSoftLabel(DateFormats.format(tc.getStartTime(), true)));
68  }
69  vbox = new Vlayout();
70  row.appendChild(vbox);
71  vbox.appendChild(new Label(new CheckDate(tc.getEndTime()).formatDate("HH:mm:ss")));
72  if(tc.getEndTime() != null && CheckDate.absoluteDays(tc.getEndTime()) != absoluteDays) {
73  vbox.appendChild(LabelTypes.getSoftLabel(DateFormats.format(tc.getEndTime(), true)));
74  }
75  }
76  }
77 
78 }
List< TimeControl > getFromDate(Date date)
void setDate(Date date)
Definition: TimeList.java:39
static Label getSoftLabel(String value)
Definition: LabelTypes.java:28