BrightSide Workbench Full Report + Source Code
WorkloadComposer.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.task.usage;
20 
21 import org.turro.erp.db.ErpPU;
22 import org.turro.erp.entity.HumanResource;
23 import org.turro.erp.entity.Resource;
24 import org.turro.erp.humanres.HumanResourceCombobox;
25 import org.turro.erp.resource.ResourceCombobox;
26 import org.zkoss.lang.Strings;
27 import org.zkoss.zk.ui.Component;
28 import org.zkoss.zk.ui.util.GenericForwardComposer;
29 import org.zkoss.zul.Button;
30 import org.zkoss.zul.Tab;
31 
36 public class WorkloadComposer extends GenericForwardComposer {
37 
38  private Tab hrTab, rTab, pTab;
39 
40  private HumanResourceCombobox hrwComb;
41  private WorkloadGrid hrwloads;
42 
43  private ResourceCombobox rwComb;
44  private WorkloadGrid rwloads;
45 
46  private HumanResourceCombobox hrpComb;
47  private WorkloadGrid hrploads;
48 
49  private Button butproc;
50 
51  public void show(String value) {
52  if(!Strings.isBlank(value)) {
53  String[] v = value.split(":");
54  if(v.length == 3) {
55  if("1".equals(v[0])) { // assigned
56  if("1".equals(v[1])) { // hr
57  hrwComb.setObjectValue(new ErpPU().find(HumanResource.class, new Long(v[2])));
58  onChange$hrwComb();
59  hrTab.setSelected(true);
60  } else if("2".equals(v[1])) { // r
61  rwComb.setObjectValue(new ErpPU().find(Resource.class, new Long(v[2])));
62  onChange$rwComb();
63  rTab.setSelected(true);
64  }
65  } else if("2".equals(v[0])) { // pending
66  if("1".equals(v[1])) { // hr
67  hrpComb.setObjectValue(new ErpPU().find(HumanResource.class, new Long(v[2])));
68  onChange$hrpComb();
69  pTab.setSelected(true);
70  } else { // r = none
71  hrpComb.setObjectValue(null);
72  onChange$hrpComb();
73  pTab.setSelected(true);
74  }
75  }
76  }
77  }
78  }
79 
80  public void onChange$hrwComb() {
81  hrwloads.setHumanResource(hrwComb.getObjectValue());
82  }
83 
84  public void onChange$rwComb() {
85  rwloads.setResource(rwComb.getObjectValue());
86  }
87 
88  public void onChange$hrpComb() {
89  hrploads.setHumanResource(hrpComb.getObjectValue());
90  }
91 
92  @Override
93  public void doAfterCompose(Component comp) throws Exception {
94  super.doAfterCompose(comp);
95  //hrwComb.setSelectCurrent(true);
96  //hrpComb.setSelectCurrent(true);
97  }
98 
99 }
void setHumanResource(HumanResource humanResource)
void setResource(Resource resource)