19 package org.turro.financials.handshake;
21 import org.turro.command.Command;
22 import org.turro.command.Context;
23 import org.turro.elephant.util.Images;
24 import org.turro.elephant.util.Messages;
25 import org.turro.i18n.I_;
26 import org.turro.zkoss.grid.PagingGrid;
27 import org.zkoss.zk.ui.event.Event;
28 import org.zkoss.zk.ui.event.EventListener;
29 import org.zkoss.zk.ui.event.Events;
30 import org.zkoss.zk.ui.ext.AfterCompose;
31 import org.zkoss.zul.Column;
32 import org.zkoss.zul.Columns;
33 import org.zkoss.zul.Hlayout;
34 import org.zkoss.zul.Label;
35 import org.zkoss.zul.Row;
36 import org.zkoss.zul.Rows;
37 import org.zkoss.zul.Toolbarbutton;
62 private void addRows() {
63 if(handshakes ==
null && handshakes.isEmpty())
return;
68 final Row row =
new Row();
70 rows.appendChild(row);
71 row.appendChild(
new Label(item.getFrom()));
72 row.appendChild(
new Label(item.getDescription()));
73 final Hlayout hbox =
new Hlayout();
74 row.appendChild(hbox);
76 if(item.getConnectImage() !=
null) {
77 Toolbarbutton connect =
new Toolbarbutton();
78 hbox.appendChild(connect);
79 connect.setImage(item.getConnectImage());
80 connect.setTooltiptext(
I_.
get(
"Connect to..."));
81 connect.addEventListener(Events.ON_CLICK,
new EventListener<Event>() {
83 public void onEvent(Event event) throws Exception {
84 item.connect(new Command() {
86 public Object execute(Context context) {
87 hbox.getChildren().clear();
94 if(item.getCreateImage() !=
null) {
95 Toolbarbutton connect =
new Toolbarbutton();
96 hbox.appendChild(connect);
97 connect.setImage(item.getCreateImage());
98 connect.setTooltiptext(I_.get(
"Create new"));
99 connect.addEventListener(Events.ON_CLICK,
new EventListener<Event>() {
101 public void onEvent(Event event) throws Exception {
102 if(item.create()) hbox.getChildren().clear();
107 if(item.getFile() !=
null) {
108 Toolbarbutton
delete =
new Toolbarbutton();
109 hbox.appendChild(
delete);
110 delete.setImage(Images.getImage(
"delete"));
111 delete.setTooltiptext(I_.get(
"Delete"));
112 delete.addEventListener(Events.ON_CLICK,
new EventListener<Event>() {
114 public void onEvent(Event event) throws Exception {
115 Messages.confirmDeletion().add(item.getDescription()).show(() -> {
116 if(item.deleteFile()) row.detach();
123 setRowCount(handshakes.size());
126 private void addColumns() {
127 Columns cols = getColumns(
true);
130 Column col =
new Column(I_.get(
"From"));
132 cols.appendChild(col);
134 col =
new Column(I_.get(
"Description"));
136 cols.appendChild(col);
140 cols.appendChild(col);
static String get(String msg)
Rows getRows(boolean create)