19 package org.turro.status;
21 import java.util.ArrayList;
23 import org.turro.elephant.util.Images;
24 import org.turro.i18n.I_;
25 import org.turro.zkoss.label.LabelTypes;
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.Hlayout;
31 import org.zkoss.zul.Label;
32 import org.zkoss.zul.Space;
33 import org.zkoss.zul.Toolbarbutton;
41 private Status status;
42 private final ArrayList<Component> comps =
new ArrayList<Component>();
53 private void addComponents() {
54 if(status ==
null)
return;
55 setSclass(
"z-valign-middle");
57 for(Component c : comps) {
61 comps.add(LabelTypes.getSoftLabel(I_.get(
"Status")));
62 comps.add(
new Label(I_.byKey(status.getName())));
63 Set possible = status.getPossibleStatus();
64 if(!possible.isEmpty()) {
65 comps.add(
new Space());
66 comps.add(LabelTypes.getSoftLabel(I_.get(
"Change to")));
68 for(
final Object e : possible) {
69 if(status.canChangeTo((Enum) e)) {
70 Toolbarbutton button =
new Toolbarbutton(
71 I_.get(e.toString()), Images.getImage(
"forward"));
72 button.addEventListener(Events.ON_CLICK,
new EventListener() {
74 public void onEvent(Event event)
throws Exception {
75 status.changeTo((Enum) e);
77 Events.postEvent(
new Event(Events.ON_CHANGE));
85 Component first = getFirstChild();
86 for(Component c : comps) {
87 insertBefore(c, first);
void setStatus(Status status)