View Javadoc

1   package org.catacomb.druid.blocks;
2   
3   import org.catacomb.druid.build.Context;
4   import org.catacomb.druid.build.GUIPath;
5   import org.catacomb.druid.gui.base.DruPanel;
6   import org.catacomb.druid.gui.edit.DruChoice;
7   import org.catacomb.druid.gui.edit.DruMenu;
8   import org.catacomb.druid.gui.edit.DruTreePanel;
9   import org.catacomb.interlish.structure.AddableTo;
10  import org.catacomb.report.E;
11  
12  
13  
14  public class TreePanel extends Panel implements AddableTo {
15  
16  
17      public String pivotSelection;
18  
19      public String flavor;
20      public String show;
21  
22      public String action;
23      public PopupMenu popup;
24  
25      public boolean showRoot;
26      public boolean draggable;
27  
28  
29  
30      public TreePanel() {
31          super();
32          showRoot = true;
33  
34      }
35  
36  
37      public void add(Object obj) {
38          if (obj instanceof PopupMenu) {
39              popup = (PopupMenu)obj;
40          } else {
41              E.error("cant add " + obj);
42          }
43      }
44  
45  
46      public DruPanel instantiatePanel() {
47          DruTreePanel drup = new DruTreePanel();
48          return drup;
49      }
50  
51  
52      public void populatePanel(DruPanel dp, Context ctx, GUIPath gpath) {
53          DruTreePanel drup = (DruTreePanel)dp;
54          drup.setID(id);
55  
56  
57          drup.setRootVisibility(showRoot);
58  
59  
60          if (action != null) {
61              drup.setAction(action);
62          }
63  
64          if (show != null) {
65              ctx.getMarketplace().addConsumer("Tree", drup, show);
66          }
67  
68          if (pivotSelection != null) {
69              if (pivotSelection.equals("none")) {
70  
71  
72              } else {
73                  String[] sa = { "order 1", "order 2", "order 3" };
74  
75                  DruChoice pivotChoice = new DruChoice(sa, "repivot");
76                  pivotChoice.setTooltip("alternative views of the tree");
77  
78                  drup.setPivotChoice(pivotChoice);
79              }
80          }
81  
82          if (popup != null) {
83              DruMenu drum = (DruMenu)(popup.realize(ctx, gpath));
84              drup.setMenu(drum);
85          }
86  
87          ctx.getMarketplace().addVisible("TreeSelection", drup, flavor); // was "selection" not flavor;
88  
89          if (draggable) {
90              drup.enableDrag();
91          }
92  
93  
94      }
95  
96  }