1 package thinlet.drafts; 2 3 import thinlet.*; 4 5 public class TreeDemo { 6 7 public void updatePopup(Thinlet thinlet, Object tree, 8 Object expand, Object collapse, Object enable, Object disable) { 9 Object 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 tree) { 20 thinlet.setBoolean(thinlet.getSelectedItem(tree), "expanded", true); 21 } 22 23 public void collapse(Thinlet thinlet, Object tree) { 24 thinlet.setBoolean(thinlet.getSelectedItem(tree), "expanded", false); 25 } 26 27 public void enable(Thinlet thinlet, Object tree) { 28 thinlet.setBoolean(thinlet.getSelectedItem(tree), "enabled", true); 29 } 30 31 public void disable(Thinlet thinlet, Object tree) { 32 thinlet.setBoolean(thinlet.getSelectedItem(tree), "enabled", false); 33 } 34 35 public void removePopup(Thinlet thinlet, Object button, Object popupmenu) { 36 thinlet.remove(popupmenu); 37 thinlet.setBoolean(button, "enabled", false); 38 } 39 } | Popular Tags |