BrightSide Workbench Full Report + Source Code
BreakdownEdit.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.reference;
20 
21 import org.turro.elephant.util.DecimalFormats;
22 import org.zkoss.zk.ui.Component;
23 import org.zkoss.zk.ui.util.GenericForwardComposer;
24 import org.zkoss.zul.Checkbox;
25 import org.zkoss.zul.Image;
26 import org.zkoss.zul.Label;
27 import org.zkoss.zul.Radiogroup;
28 
33 public class BreakdownEdit extends GenericForwardComposer {
34 
35  private Radiogroup type;
36  private Checkbox showQuantity, showPrice;
37  private BreakdownGrid breakdowns;
38  private Label total;
39  private Image warnmatch;
40 
41  @Override
42  public void doAfterCompose(Component comp) throws Exception {
43  super.doAfterCompose(comp);
44  showQuantity.setChecked(true);
45  showPrice.setChecked(false);
46  breakdowns.setAllowInsertions(!breakdowns.isReadOnly());
47  breakdowns.setAllowDeletions(!breakdowns.isReadOnly());
48  breakdowns.updateCollection(breakdowns.getOrderReference().getBreakdowns());
49  onChange$breakdowns();
50  }
51 
52  public void onChange$breakdowns() {
53  double t = breakdowns.getAmount();
54  total.setValue(DecimalFormats.format(t));
55  warnmatch.setVisible(Math.abs(t - breakdowns.getOrderReference().getPrice()) > 0.001);
56  }
57 
58  public void onClick$warnmatch() {
59  onChange$breakdowns();
60  }
61 
62  public void onCheck$type() {
63  breakdowns.setMode(type.getSelectedIndex());
64  }
65 
66  public void onCheck$showQuantity() {
67  breakdowns.setShowQuantity(showQuantity.isChecked());
68  }
69 
70  public void onCheck$showPrice() {
71  breakdowns.setShowPrice(showPrice.isChecked());
72  }
73 
74 }
static String format(Number value, String pattern)
void updateCollection(Collection< V > collection)
void setAllowDeletions(boolean allowDeletions)
void setAllowInsertions(boolean allowInsertions)