19 package org.turro.erp.task.usage;
22 import org.turro.command.Command;
23 import org.turro.command.Context;
24 import org.turro.erp.entity.OrderItem;
25 import org.turro.erp.entity.ReceiptItem;
26 import org.turro.erp.entity.RequiredUsage;
27 import org.turro.erp.entity.Task;
28 import org.turro.zkoss.layout.GridLayout;
29 import org.zkoss.zk.ui.event.Event;
30 import org.zkoss.zk.ui.event.EventListener;
31 import org.zkoss.zk.ui.event.Events;
32 import org.zkoss.zul.Vlayout;
42 private boolean onlyUsages =
false;
45 addEventListener(Events.ON_CHANGE,
new EventListener() {
47 public void onEvent(Event event)
throws Exception {
54 this.onlyUsages = onlyUsages;
63 public Object execute(Context context) {
66 Events.postEvent(
new Event(Events.ON_CHANGE,
UsageTree.this));
79 public Object execute(Context context) {
82 Events.postEvent(
new Event(Events.ON_CHANGE,
UsageTree.this));
94 this.requiredUsage = requiredUsage;
95 if(requiredUsage !=
null) {
111 private void addComponents() {
112 if(getColumns() ==
null) {
113 if(onlyUsages || isProductOrder()) {
120 getRows().getChildren().clear();
124 ru.getUpdatedOrderItems();
130 appendOrders(glo, ru.getOrderItems());
133 }
else if(requiredUsage !=
null) {
145 private void appendOrders(
GridLayout gl, Set<OrderItem> orderItems) {
146 for(OrderItem oi : orderItems) {
148 gl.addComponent(
new OrderBox(oi));
149 appendReceipts(gl, oi.getReceiptItems());
150 if(oi.getRelated() !=
null) {
152 gl.addComponent(
new OrderBox(oi.getRelated()));
153 appendReceipts(gl, oi.getRelated().getReceiptItems());
158 private void appendReceipts(
GridLayout gl, Set<ReceiptItem> receiptItems) {
159 Vlayout vbox =
new Vlayout();
160 for(ReceiptItem ri : receiptItems) {
161 vbox.appendChild(
new ReceiptBox(ri));
163 gl.addComponent(vbox);
166 private boolean isProductOrder() {
Set< OrderItem > getOrderItems()
void prepareHumanResource()
Set< OrderItem > getUpdatedOrderItems()
Set< RequiredUsage > getRequiredUsages()
static void doEdit(RequiredUsage requiredUsage, Command command)
void setRequiredUsage(RequiredUsage requiredUsage)
void setOnlyUsages(boolean onlyUsages)
RequiredUsage getRequiredUsage()
void setColumns(int columns)
GridLayout addComponent(HtmlBasedComponent comp)
Rows getRows(boolean create)