18 package org.turro.contacts.zul.fields;
20 import java.util.List;
21 import org.turro.contacts.FieldDef;
22 import org.turro.contacts.db.ContactsPU;
23 import org.turro.elephant.context.Application;
24 import org.turro.elephant.db.WhereClause;
25 import org.turro.i18n.I_;
26 import org.zkoss.zk.ui.Component;
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.zul.*;
39 private Toolbar toolbar;
40 private Toolbarbutton addButton, saveButton;
51 toolbar =
new Toolbar();
52 getParent().appendChild(toolbar);
57 private void addColumns() {
58 Columns cols =
new Columns();
59 cols.setSizable(
true);
60 cols.setMenupopup(
"auto");
63 Column col =
new Column(
I_.
get(
"Tag discriminator"));
64 cols.appendChild(col);
65 col =
new Column(
I_.
get(
"Tab label"));
66 cols.appendChild(col);
67 col =
new Column(
I_.
get(
"Field label"));
68 cols.appendChild(col);
69 col =
new Column(
I_.
get(
"Field type"));
70 cols.appendChild(col);
74 cols.appendChild(col);
78 private void addRows() {
81 wc.
addClause(
"from FieldDef as fieldDef");
82 wc.
addClause(
"order by fieldDef.tabKey, fieldDef.labelKey");
84 rows.appendChild(
new FieldDefRow(fd));
88 private void addToolbarButtons() {
89 saveButton =
new Toolbarbutton(
91 "/_zul/images/save.png"
93 saveButton.addEventListener(Events.ON_CLICK,
new EventListener() {
96 public void onEvent(Event event)
throws Exception {
97 ContactsPU cpu =
new ContactsPU();
98 for(Component fdr : rows.getChildren()) {
99 FieldDef fd = cpu.saveObject(((FieldDefRow)fdr).getFieldDef());
100 ((FieldDefRow)fdr).setFieldDef(fd);
105 toolbar.appendChild(saveButton);
107 addButton =
new Toolbarbutton(
109 "/_zul/images/new.png"
111 addButton.addEventListener(Events.ON_CLICK,
new EventListener() {
114 public void onEvent(Event event)
throws Exception {
115 rows.appendChild(
new FieldDefRow(
new FieldDef()));
119 toolbar.appendChild(addButton);
boolean isInRole(String role)
static Application getApplication()
void addClause(String clause)
static String get(String msg)