19 package org.turro.erp.task.usage;
21 import org.turro.command.Command;
22 import org.turro.command.CommandUtil;
23 import org.turro.command.Context;
24 import org.turro.elephant.context.Application;
25 import org.turro.elephant.util.DecimalFormats;
26 import org.turro.elephant.util.Images;
27 import org.turro.elephant.util.ZkossUtils;
28 import org.turro.elephant.zkoss.Modal;
29 import org.turro.erp.db.ErpPU;
30 import org.turro.erp.entity.OrderItem;
31 import org.turro.erp.entity.RequiredUsage;
32 import org.turro.jpa.entity.EntityCollectionUtil;
33 import org.turro.zkoss.label.PercentLabel;
34 import org.turro.zkoss.layout.GridLayout;
35 import org.zkoss.zk.ui.Executions;
36 import org.zkoss.zk.ui.event.Event;
37 import org.zkoss.zk.ui.event.EventListener;
38 import org.zkoss.zk.ui.event.Events;
39 import org.zkoss.zul.*;
51 this.requiredUsage = requiredUsage;
52 setSclass(
"usageBox");
58 private void addComponents() {
59 if(getCaption() !=
null) {
60 getCaption().setLabel(requiredUsage.
getName());
62 gl.
getRows().getChildren().clear();
64 appendChild(
new Caption(requiredUsage.
getName(),
65 Images.getImage(requiredUsage.
getType())));
66 gl =
new GridLayout(
"min,right-1,right-1,right-1");
78 private void renderUsage() {
84 gl.
addCaption(Application.getString(
"lUnits"));
90 gl.
addCaption(Application.getString(
"lDedication"));
101 Hlayout hbox =
new Hlayout();
102 hbox.setStyle(
"text-align:right");
103 Button edit =
new Button(Application.getString(
"lEdit"));
104 hbox.appendChild(edit);
105 edit.addEventListener(Events.ON_CLICK,
new EventListener() {
107 public void onEvent(Event event)
throws Exception {
108 doEdit(requiredUsage,
new Command() {
110 public Object execute(Context context) {
118 Button
delete =
new Button(Application.getString(
"lDelete"));
119 hbox.appendChild(
delete);
120 delete.addEventListener(Events.ON_CLICK,
new EventListener() {
122 public void onEvent(Event event)
throws Exception {
123 ZkossUtils.confirmDeletion(
null,
new Command() {
125 public Object execute(Context context) {
127 Events.postEvent(
new Event(Events.ON_CHANGE, ZkossUtils.getParent(
UsageBox.this, UsageTree.class)));
133 if(requiredUsage.
getId() > 0) {
134 Button order =
new Button(Application.getString(
"lNewOrder"));
135 hbox.appendChild(order);
136 order.addEventListener(Events.ON_CLICK,
new EventListener() {
138 public void onEvent(Event event)
throws Exception {
141 new ErpPU().saveObject(oi);
143 Events.postEvent(
new Event(Events.ON_CHANGE, ZkossUtils.getParent(
UsageBox.this, UsageTree.class)));
152 Window w = (Window) Executions.createComponents(
"/WEB-INF/_zul/erp/task/editUsage.zul",
null,
null);
153 w.setMode(Window.MODAL);
154 Events.sendEvent(Events.ON_USER, w, requiredUsage);
static String getString(String key)
static String getImage(String image)
static int doModal(String file)
double getExpectedUnits()
double getExpectedDedication()
double getEstimatedUnits()
boolean isHumanResourceType()
Set< OrderItem > getOrderItems()
double getEstimatedCost()
double getRealDedication()
Set< RequiredUsage > getRequiredUsages()
static void doEdit(RequiredUsage requiredUsage, Command command)
UsageBox(RequiredUsage requiredUsage)
void setColCaptions(String captions)
GridLayout addComponent(HtmlBasedComponent comp)
Rows getRows(boolean create)
GridLayout addSpannedComponent(HtmlBasedComponent comp, int cols)
GridLayout addCaption(String label)