home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &n…he Search for Life DVD 2 / DVD-ROM.iso / install / jre1_3 / lib / rt.jar / javax / swing / JTree$DynamicUtilTreeNode.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  1.6 KB  |  93 lines

  1. package javax.swing;
  2.  
  3. import java.util.Enumeration;
  4. import java.util.Hashtable;
  5. import java.util.Vector;
  6. import javax.swing.tree.DefaultMutableTreeNode;
  7. import javax.swing.tree.TreeNode;
  8.  
  9. public class JTree$DynamicUtilTreeNode extends DefaultMutableTreeNode {
  10.    protected boolean hasChildren;
  11.    protected Object childValue;
  12.    protected boolean loadedChildren = false;
  13.  
  14.    public static void createChildren(DefaultMutableTreeNode var0, Object var1) {
  15.       if (var1 instanceof Vector) {
  16.          Vector var2 = (Vector)var1;
  17.          int var3 = 0;
  18.  
  19.          for(int var4 = var2.size(); var3 < var4; ++var3) {
  20.             var0.add(new JTree$DynamicUtilTreeNode(var2.elementAt(var3), var2.elementAt(var3)));
  21.          }
  22.       } else if (var1 instanceof Hashtable) {
  23.          Hashtable var5 = (Hashtable)var1;
  24.          Enumeration var7 = var5.keys();
  25.  
  26.          while(var7.hasMoreElements()) {
  27.             Object var9 = var7.nextElement();
  28.             var0.add(new JTree$DynamicUtilTreeNode(var9, var5.get(var9)));
  29.          }
  30.       } else if (var1 instanceof Object[]) {
  31.          Object[] var6 = var1;
  32.          int var8 = 0;
  33.  
  34.          for(int var10 = var6.length; var8 < var10; ++var8) {
  35.             var0.add(new JTree$DynamicUtilTreeNode(var6[var8], var6[var8]));
  36.          }
  37.       }
  38.  
  39.    }
  40.  
  41.    public JTree$DynamicUtilTreeNode(Object var1, Object var2) {
  42.       super(var1);
  43.       this.childValue = var2;
  44.       if (var2 != null) {
  45.          if (var2 instanceof Vector) {
  46.             ((DefaultMutableTreeNode)this).setAllowsChildren(true);
  47.          } else if (var2 instanceof Hashtable) {
  48.             ((DefaultMutableTreeNode)this).setAllowsChildren(true);
  49.          } else if (var2 instanceof Object[]) {
  50.             ((DefaultMutableTreeNode)this).setAllowsChildren(true);
  51.          } else {
  52.             ((DefaultMutableTreeNode)this).setAllowsChildren(false);
  53.          }
  54.       } else {
  55.          ((DefaultMutableTreeNode)this).setAllowsChildren(false);
  56.       }
  57.  
  58.    }
  59.  
  60.    public boolean isLeaf() {
  61.       return !((DefaultMutableTreeNode)this).getAllowsChildren();
  62.    }
  63.  
  64.    public int getChildCount() {
  65.       if (!this.loadedChildren) {
  66.          this.loadChildren();
  67.       }
  68.  
  69.       return super.getChildCount();
  70.    }
  71.  
  72.    protected void loadChildren() {
  73.       this.loadedChildren = true;
  74.       createChildren(this, this.childValue);
  75.    }
  76.  
  77.    public TreeNode getChildAt(int var1) {
  78.       if (!this.loadedChildren) {
  79.          this.loadChildren();
  80.       }
  81.  
  82.       return super.getChildAt(var1);
  83.    }
  84.  
  85.    public Enumeration children() {
  86.       if (!this.loadedChildren) {
  87.          this.loadChildren();
  88.       }
  89.  
  90.       return super.children();
  91.    }
  92. }
  93.