19 package org.turro.valuation;
21 import java.util.TreeSet;
22 import org.turro.i18n.I_;
23 import org.turro.zkoss.grid.PagingGrid;
24 import org.turro.zkoss.input.Percentbox;
25 import org.turro.zkoss.label.LabelTip;
26 import org.zkoss.zk.ui.event.Event;
27 import org.zkoss.zk.ui.event.EventListener;
28 import org.zkoss.zk.ui.event.Events;
29 import org.zkoss.zul.*;
39 unitFormat =
"#0.000";
49 rows.getChildren().clear();
51 TreeSet<Variable> vars =
new TreeSet<Variable>(
new VariableOrderComparator());
52 vars.addAll(
model.getVariables());
54 for(Variable var : vars) {
61 private void processVariable(
final Variable var) {
65 row.setSclass(var.getType() +
"-var-row");
67 if(var.isAlwaysApply()) {
68 final Checkbox apply =
new Checkbox();
69 apply.setChecked(var.isApply());
70 apply.addEventListener(Events.ON_CHECK,
new EventListener() {
72 public void onEvent(Event event)
throws Exception {
73 var.setApply(apply.isChecked());
74 Events.postEvent(
new Event(Events.ON_CHANGE,
VariablesGrid.this));
77 row.appendChild(apply);
79 row.appendChild(
new Space());
82 Hlayout hbox =
new Hlayout();
83 hbox.appendChild(
new Image(
"/_zul/images/" + var.getType() +
".png"));
84 hbox.appendChild(
new LabelTip(var.getName()));
85 row.appendChild(hbox);
87 final Percentbox structure =
new Percentbox();
88 structure.setInplace(
true);
89 structure.setValue(var.getStructureMargin());
90 structure.addEventListener(Events.ON_CHANGE,
new EventListener() {
92 public void onEvent(Event event)
throws Exception {
93 var.setStructureMargin(structure.getValue());
94 Events.postEvent(
new Event(Events.ON_CHANGE, VariablesGrid.this));
97 row.appendChild(structure);
99 final Percentbox profit =
new Percentbox();
100 profit.setInplace(
true);
101 profit.setValue(var.getProfitMargin());
102 profit.addEventListener(Events.ON_CHANGE,
new EventListener() {
104 public void onEvent(Event event)
throws Exception {
105 var.setProfitMargin(profit.getValue());
106 Events.postEvent(
new Event(Events.ON_CHANGE, VariablesGrid.this));
109 row.appendChild(profit);
115 Columns cols =
new Columns();
116 cols.setSizable(
true);
119 Column col =
new Column();
121 col.setWidth(
"50px");
122 cols.appendChild(col);
125 col.setLabel(
I_.
get(
"Variable"));
127 cols.appendChild(col);
130 col.setLabel(
I_.
get(
"Structure margin"));
131 col.setWidth(
"120px");
132 cols.appendChild(col);
135 col.setLabel(
I_.
get(
"Profit margin"));
136 col.setWidth(
"120px");
137 cols.appendChild(col);
static String get(String msg)
void setValuationModel(ValuationModel model)
Rows getRows(boolean create)
void setRowCount(int rows)