BrightSide Workbench Full Report + Source Code
EntityCloneGrid.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.clone;
20 
21 import java.util.ArrayList;
22 import org.turro.clone.ClonedEntitySet;
23 import org.turro.elephant.context.Application;
24 import org.turro.elephant.util.Images;
25 import org.turro.erp.entity.OrderReference;
26 import org.turro.erp.entity.Predecessor;
27 import org.turro.erp.entity.RequiredUsage;
28 import org.turro.erp.entity.Task;
29 import org.turro.erp.entity.WorkOrder;
30 import org.turro.hierarchy.Hierarchical;
31 import org.turro.hierarchy.HierarchyGrid;
32 import org.turro.zkoss.label.LabelTypes;
33 import org.turro.elephant.zkoss.ElLabel;
34 import org.zkoss.zul.Hlayout;
35 import org.zkoss.zul.Image;
36 import org.zkoss.zul.Label;
37 import org.zkoss.zul.Row;
38 import org.zkoss.zul.Space;
39 
44 public class EntityCloneGrid extends HierarchyGrid {
45 
46  public void setWorkOrder(WorkOrder workOrder) {
47  WorkOrderClone woc = new WorkOrderClone(workOrder, new ClonedEntitySet());
48  ArrayList<Hierarchical> list = new ArrayList<Hierarchical>();
49  list.add(woc);
50  setCollection(list, 0);
51  }
52 
53  public void setOrderReference(OrderReference orderReference) {
54  OrderReferenceClone orc = new OrderReferenceClone(orderReference, new ClonedEntitySet());
55  ArrayList<Hierarchical> list = new ArrayList<Hierarchical>();
56  list.add(orc);
57  setCollection(list, 0);
58  }
59 
60  public void setTask(Task task) {
61  TaskClone tc = new TaskClone(task, new ClonedEntitySet());
62  ArrayList<Hierarchical> list = new ArrayList<Hierarchical>();
63  list.add(tc);
64  setCollection(list, 0);
65  }
66 
67  @Override
68  protected void refreshValue(Row row, Hierarchical value) {
69  Hlayout nameLayout = getNameLayout(value);
70  if(value instanceof WorkOrderClone) {
71  WorkOrder wo = ((WorkOrderClone) value).getEntity();
72  nameLayout.appendChild(new Image(Images.getImage("workorder")));
73  nameLayout.appendChild(new Label(wo.getDescription()));
74  } else if(value instanceof OrderReferenceClone) {
75  OrderReference or = ((OrderReferenceClone) value).getEntity();
76  nameLayout.appendChild(new Image(Images.getImage("reference")));
77  nameLayout.appendChild(new Label(or.getSomeDescription()));
78  } else if(value instanceof TaskClone) {
79  Task t = ((TaskClone) value).getEntity();
80  nameLayout.appendChild(new Image(Images.getImage("task")));
81  nameLayout.appendChild(new Label(t.getName()));
82  } else if(value instanceof RequiredUsageClone) {
83  RequiredUsage ru = ((RequiredUsageClone) value).getEntity();
84  nameLayout.appendChild(new Image(Images.getImage(ru.getType())));
85  nameLayout.appendChild(new Label(ru.isHumanResourceType() ? ru.getHumanResourceAptitude().getName() : ru.getName()));
86  if(ru.hasResource()) {
87  nameLayout.appendChild(new Space());
88  nameLayout.appendChild(new Image(Images.getImage("resource")));
89  nameLayout.appendChild(new Label(ru.getResource().getName()));
90  }
91  } else if(value instanceof PredecessorClone) {
92  Predecessor p = ((PredecessorClone) value).getEntity();
93  nameLayout.appendChild(new Image(Images.getImage(p.getType().toString())));
94  nameLayout.appendChild(LabelTypes.getSoftLabel(Application.getString(p.getType().toString())));
95  nameLayout.appendChild(new Label(p.getPredecessor().getName()));
96  }
97  row.appendChild(nameLayout);
98  }
99 
100 }
static String getString(String key)
static String getImage(String image)
Definition: Images.java:36
void setWorkOrder(WorkOrder workOrder)
void setOrderReference(OrderReference orderReference)
void refreshValue(Row row, Hierarchical value)
HumanResourceAptitude getHumanResourceAptitude()
Hlayout getNameLayout(final Hierarchical value)
void setCollection(Collection< Hierarchical > items, int showBreakdownLevel)
static Label getSoftLabel(String value)
Definition: LabelTypes.java:28