View Javadoc

1   
2   package org.catacomb.druid.blocks;
3   
4   import org.catacomb.druid.build.Context;
5   import org.catacomb.druid.build.GUIPath;
6   import org.catacomb.druid.gui.base.DruPanel;
7   import org.catacomb.druid.gui.edit.DruRadioButtons;
8   
9   
10  
11  public class RadioButtons extends Panel {
12  
13      public String action;
14      public String layout;
15  
16      public String label;
17  
18      public String store;
19  
20      public String options;
21      public String labels;
22  
23      public String from;
24      public int autoSelect;
25  
26  
27  
28      public RadioButtons() {
29          autoSelect = -1;
30      }
31  
32  
33  
34      public DruPanel instantiatePanel() {
35  
36          if (layout == null) {
37              layout = "vertical";
38          }
39  
40          return  new DruRadioButtons(label, action, layout);
41      }
42  
43      public void populatePanel(DruPanel dp, Context ctx, GUIPath gpath) {
44  
45          DruRadioButtons drup = (DruRadioButtons)dp;
46  
47          if (options != null) {
48              String[] sa = options.split(",");
49  
50              String[] sopts = new String[sa.length];
51              String[] slabs = new String[sa.length];
52  
53              for (int i = 0; i < sa.length; i++) {
54                  String s = sa[i].trim();
55                  sopts[i] = s;
56                  slabs[i] = s;
57              }
58  
59              if (labels != null) {
60                  String[] sb = labels.split(",");
61                  for (int i = 0; i < sa.length && i < sopts.length; i++) {
62                      slabs[i] = sb[i].trim();
63                  }
64              }
65  
66              drup.setOptions(sopts, slabs);
67          }
68  
69  
70          if (autoSelect >= 0) {
71              drup.setAutoSelect(autoSelect);
72          }
73  
74          if (from != null && from.length() > 0) {
75              ctx.getMarketplace().addConsumer("ChoiceOptions", drup, from);
76          }
77  
78      }
79  
80  }