18 package org.turro.financials.relation;
20 import org.turro.string.Strings;
21 import org.turro.elephant.util.DateFormats;
22 import org.turro.elephant.util.DecimalFormats;
23 import org.turro.elephant.util.Messages;
24 import org.turro.financials.db.FinancialsPU;
25 import org.turro.financials.entity.Document;
26 import org.turro.financials.entity.DocumentRelation;
27 import org.turro.financials.menu.FinancialsMenu;
28 import org.turro.zkoss.label.LabelTypes;
29 import org.zkoss.zk.ui.Component;
30 import org.zkoss.zk.ui.event.Event;
31 import org.zkoss.zk.ui.event.EventListener;
32 import org.zkoss.zk.ui.event.Events;
33 import org.zkoss.zul.*;
44 this.document = document;
53 private void updateBox() {
54 getChildren().clear();
55 Caption caption =
new Caption();
57 Toolbarbutton docButton =
new Toolbarbutton(
61 docButton.addEventListener(Events.ON_CLICK,
new EventListener() {
63 public void onEvent(Event event)
throws Exception {
67 caption.appendChild(docButton);
68 Hbox hbox =
new Hbox();
69 hbox.setWidth(
"100%");
71 Cell cconnectors =
new Cell();
72 cconnectors.setHflex(
"1");
73 hbox.appendChild(cconnectors);
74 Vlayout connectors =
new Vlayout();
75 connectors.setStyle(
"border-right: solid 1px #ddd");
76 cconnectors.appendChild(connectors);
78 connectors.appendChild(getDelButton(dr.getId()));
80 Cell ccontent =
new Cell();
81 ccontent.setHflex(
"4");
82 hbox.appendChild(ccontent);
83 Vlayout content =
new Vlayout();
84 content.setStyle(
"padding-left:5px");
85 ccontent.appendChild(content);
89 content.appendChild(
new Label(DecimalFormats.format(document.
getTotalAmount())));
90 cconnectors =
new Cell();
91 cconnectors.setHflex(
"1");
92 hbox.appendChild(cconnectors);
93 connectors =
new Vlayout();
94 connectors.setStyle(
"border-left: solid 1px #ddd");
95 cconnectors.appendChild(connectors);
98 connectors.appendChild(getDelButton(dr.getId()));
103 private void notifyChange() {
104 ((RelationshipViewer) getParent().getParent()).notifyChange();
107 private Component getDelButton(
final long id) {
108 Toolbarbutton tb =
new Toolbarbutton(
id +
"",
"/_zul/images/12/mini_del.png");
109 tb.setSclass(
"tinyLabel");
110 tb.setOrient(
"vertical");
111 tb.addEventListener(Events.ON_CLICK,
new EventListener() {
113 public void onEvent(Event event)
throws Exception {
114 Messages.confirmDeletion().show(() -> {
116 new FinancialsPU().executeUpdate(
117 "delete from DocumentRelation where id = ?",
118 new Object[] {
id });
126 private boolean killRelation(
long id) {
127 Document doc = ((RelationshipColumn) getParent()).
getDocument();
128 for(DocumentRelation dr : doc.getAncestors()) {
129 if(dr.getId() == id) {
134 for(DocumentRelation dr : doc.getDescendants()) {
135 if(dr.getId() == id) {
136 doc.getDescendants().remove(dr);
RegisterView getForcedView()
Set< DocumentRelation > getAncestors()
Set< DocumentRelation > getDescendants()
String getDocumentNumber()
DocumentBox(Document document)