KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > thinlet > drafts > TreeDemo


1 package thinlet.drafts;
2
3 import thinlet.*;
4
5 public class TreeDemo {
6     
7     public void updatePopup(Thinlet thinlet, Object JavaDoc tree,
8             Object JavaDoc expand, Object JavaDoc collapse, Object JavaDoc enable, Object JavaDoc disable) {
9         Object JavaDoc node = thinlet.getSelectedItem(tree);
10         boolean enabled = thinlet.getBoolean(node, "enabled");
11         boolean expanded = thinlet.getBoolean(node, "expanded");
12         boolean hasnode = thinlet.getItem(node, 0) != null;
13         thinlet.setBoolean(expand, "enabled", hasnode && !expanded);
14         thinlet.setBoolean(collapse, "enabled", hasnode && expanded);
15         thinlet.setBoolean(enable, "enabled", !enabled);
16         thinlet.setBoolean(disable, "enabled", enabled);
17     }
18     
19     public void expand(Thinlet thinlet, Object JavaDoc tree) {
20         thinlet.setBoolean(thinlet.getSelectedItem(tree), "expanded", true);
21     }
22     
23     public void collapse(Thinlet thinlet, Object JavaDoc tree) {
24         thinlet.setBoolean(thinlet.getSelectedItem(tree), "expanded", false);
25     }
26     
27     public void enable(Thinlet thinlet, Object JavaDoc tree) {
28         thinlet.setBoolean(thinlet.getSelectedItem(tree), "enabled", true);
29     }
30     
31     public void disable(Thinlet thinlet, Object JavaDoc tree) {
32         thinlet.setBoolean(thinlet.getSelectedItem(tree), "enabled", false);
33     }
34     
35     public void removePopup(Thinlet thinlet, Object JavaDoc button, Object JavaDoc popupmenu) {
36         thinlet.remove(popupmenu);
37         thinlet.setBoolean(button, "enabled", false);
38     }
39 }
Popular Tags