BrightSide Workbench Full Report + Source Code
XMLTaskSelector.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.List;
22 import org.turro.elephant.context.Application;
23 import org.turro.zkoss.label.LabelExtended;
24 import org.turro.elephant.zkoss.ElLabel;
25 import org.zkoss.zk.ui.event.Event;
26 import org.zkoss.zk.ui.event.EventListener;
27 import org.zkoss.zk.ui.event.Events;
28 import org.zkoss.zul.Button;
29 import org.zkoss.zul.Grid;
30 import org.zkoss.zul.Label;
31 import org.zkoss.zul.Row;
32 import org.zkoss.zul.Rows;
33 import org.zkoss.zul.Space;
34 
39 public class XMLTaskSelector extends Grid {
40 
41  public void setHumanResource(XMLHumanResource humanResource) {
42  boolean canGetIn = true;
43 
44  Rows rows = getRows();
45  if(rows != null) {
46  rows.getChildren().clear();
47  } else {
48  rows = new Rows();
49  appendChild(rows);
50  }
51 
53  tcu.setHumanResource(humanResource);
54  List<XMLTimeControl> pending = tcu.getPendingControl();
55 
56  for(XMLTimeControl tc : pending) {
57  canGetIn = false;
58 
59  final Row row = new Row();
60  row.setValue(tc);
61  rows.appendChild(row);
62 
63  row.appendChild(new LabelExtended().setDateTime(tc.getStartTime()));
64 
65  Button select = new Button(Application.getString("lGetOut"));
66  select.setHflex("true");
67  select.addEventListener(Events.ON_CLICK, new EventListener<Event>() {
68  @Override
69  public void onEvent(Event event) throws Exception {
70  Events.postEvent(new Event(Events.ON_CHANGE, XMLTaskSelector.this, row.getValue()));
71  }
72  });
73  row.appendChild(select);
74  }
75 
76  if(canGetIn) {
77  final Row rowStart = new Row();
78  rows.appendChild(rowStart);
79 
80  rowStart.appendChild(new Label(Application.getString("lNow")));
81 
82  Button butStart = new Button(Application.getString("lGetIn"));
83  butStart.setHflex("true");
84  butStart.addEventListener(Events.ON_CLICK, new EventListener<Event>() {
85  @Override
86  public void onEvent(Event event) throws Exception {
87  Events.postEvent(new Event(Events.ON_USER, XMLTaskSelector.this, null));
88  }
89  });
90  rowStart.appendChild(butStart);
91  }
92 
93  final Row rowCancel = new Row();
94  rows.appendChild(rowCancel);
95 
96  rowCancel.appendChild(new Space());
97 
98  Button butCancel = new Button(Application.getString("lCancel"));
99  butCancel.setHflex("true");
100  butCancel.addEventListener(Events.ON_CLICK, new EventListener<Event>() {
101  @Override
102  public void onEvent(Event event) throws Exception {
103  Events.postEvent(new Event(Events.ON_CANCEL, XMLTaskSelector.this));
104  }
105  });
106  rowCancel.appendChild(butCancel);
107 
108  }
109 
110 }
111 
static String getString(String key)
void setHumanResource(XMLHumanResource humanResource)
List< XMLTimeControl > getPendingControl()
void setHumanResource(XMLHumanResource humanResource)