18 package org.turro.zkoss.dialog;
20 import java.util.Arrays;
21 import org.turro.i18n.I_;
22 import org.zkoss.zk.ui.ext.AfterCompose;
23 import org.zkoss.zul.Radio;
24 import org.zkoss.zul.Radiogroup;
30 public class InputEnum<V
extends Enum<V>> extends Radiogroup implements AfterCompose {
33 private boolean populated;
34 private V internalValue;
36 public InputEnum(V[] values) {
40 public V getObjectValue() {
44 int i = getSelectedIndex();
45 return i > -1 ? values[i] :
null;
49 public void setObjectValue(V objectValue) {
51 this.internalValue = objectValue;
53 setSelectedIndex(Arrays.binarySearch(values, objectValue));
57 protected void populateList() {
58 if(values ==
null)
return;
60 Radio r =
new Radio(getString(v), getImage(v));
65 protected String getString(V v) {
69 protected String getImage(V v) {
74 public void afterCompose() {
77 if(internalValue !=
null) {
78 setObjectValue(internalValue);
static String byKey(String key)