home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 139 / dpcs0999.iso / Web / CFserver / data1.cab / Java / allaire / controls / cftreeform.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-04-12  |  4.5 KB  |  271 lines

  1. package allaire.controls;
  2.  
  3. import allaire.util.netHelpers;
  4. import java.applet.Applet;
  5. import java.util.StringTokenizer;
  6. import netscape.application.AWTCompatibility;
  7. import netscape.application.Application;
  8. import netscape.application.Color;
  9. import netscape.application.ExternalWindow;
  10. import netscape.application.Font;
  11. import netscape.application.RootView;
  12. import netscape.application.Size;
  13. import netscape.application.View;
  14. import netscape.util.Vector;
  15.  
  16. public class cftreeform extends Application {
  17.    static final int maxlevels = 20;
  18.    static final int NIMAGES = 8;
  19.    private CFTree m_tree;
  20.    private String m_separator;
  21.    private boolean m_includeroot;
  22.  
  23.    public String cf_getNode() {
  24.       return this.m_tree.currentItem();
  25.    }
  26.  
  27.    public static void main(String[] var0) {
  28.       cftreeform var1 = new cftreeform();
  29.       ExternalWindow var2 = new ExternalWindow();
  30.       ((Application)var1).setMainRootView(var2.rootView());
  31.       Size var3 = var2.windowSizeForContentSize(320, 200);
  32.       var2.sizeTo(var3.width, var3.height);
  33.       var2.show();
  34.       ((Application)var1).run();
  35.       System.exit(0);
  36.    }
  37.  
  38.    public String cf_getPath() {
  39.       return this.m_includeroot ? this.m_tree.currentCompletePath(this.m_separator) : this.m_tree.currentPath(this.m_separator);
  40.    }
  41.  
  42.    public void init() {
  43.       super.init();
  44.       RootView var1 = ((Application)this).mainRootView();
  45.       int var2 = 0;
  46.       Font var4 = Font.defaultFont();
  47.       String var5 = ((Application)this).parameterNamed("treeitems");
  48.       String var6 = ((Application)this).parameterNamed("border");
  49.       String var7 = ((Application)this).parameterNamed("vscroll");
  50.       String var8 = ((Application)this).parameterNamed("hscroll");
  51.       String var9 = ((Application)this).parameterNamed("showlinks");
  52.       String var10 = ((Application)this).parameterNamed("font");
  53.       String var11 = ((Application)this).parameterNamed("fontsize");
  54.       String var12 = ((Application)this).parameterNamed("fontweight");
  55.       String var13 = ((Application)this).parameterNamed("root");
  56.       String var14 = ((Application)this).parameterNamed("appendkey");
  57.       Vector var15 = new Vector();
  58.       boolean var16 = false;
  59.       String[] var17 = new String[]{"folder", "computer", "floppy", "fixed", "remote", "cd", "document", "element"};
  60.       this.m_separator = ((Application)this).parameterNamed("separator");
  61.       if (this.m_separator == null) {
  62.          this.m_separator = "\\";
  63.       }
  64.  
  65.       var1.setColor(Color.white);
  66.       if (var10 == null) {
  67.          var10 = var4.name();
  68.       } else {
  69.          var16 = true;
  70.       }
  71.  
  72.       int var3;
  73.       if (var11 == null) {
  74.          var3 = var4.size();
  75.       } else {
  76.          var3 = Integer.parseInt(var11);
  77.          var16 = true;
  78.       }
  79.  
  80.       if (var12 == null) {
  81.          var2 = var4.style();
  82.       } else {
  83.          if (var12.indexOf("BOLD") >= 0) {
  84.             ++var2;
  85.          }
  86.  
  87.          if (var12.indexOf("ITALIC") >= 0) {
  88.             var2 += 2;
  89.          }
  90.  
  91.          var16 = true;
  92.       }
  93.  
  94.       if (var13 != null && var13.compareTo("Y") == 0) {
  95.          this.m_includeroot = true;
  96.       }
  97.  
  98.       this.m_tree = new CFTree(0, 0, ((View)var1).width(), ((View)var1).height(), var1);
  99.       if (var16) {
  100.          this.m_tree.setFont(Font.fontNamed(var10, var2, var3));
  101.       }
  102.  
  103.       if (var6 == null || var6.compareTo("no") != 0) {
  104.          this.m_tree.setBorder(true);
  105.       }
  106.  
  107.       if (var7 == null || var7.compareTo("no") != 0) {
  108.          this.m_tree.setVScroll(true);
  109.       }
  110.  
  111.       if (var9 != null && var9.compareTo("no") == 0) {
  112.          this.m_tree.showURLs(false);
  113.       }
  114.  
  115.       if (var14 != null && var14.compareTo("N") == 0) {
  116.          this.m_tree.appendKeys(false);
  117.       }
  118.  
  119.       if (var8 == null || var8.compareTo("no") != 0) {
  120.          this.m_tree.setHScroll(true);
  121.       }
  122.  
  123.       if (var5 != null) {
  124.          var5 = netHelpers.URLDecode(var5);
  125.          StringTokenizer var18 = new StringTokenizer(var5, "\u0002");
  126.          String var23 = null;
  127.          int var30 = -1;
  128.  
  129.          int var28;
  130.          for(int[] var31 = new int[20]; var18.hasMoreTokens(); var30 = var28) {
  131.             String var19 = var18.nextToken();
  132.             StringTokenizer var34 = new StringTokenizer(var19, "\u0001");
  133.             String var20;
  134.             if (var34.hasMoreTokens()) {
  135.                var20 = var34.nextToken();
  136.             } else {
  137.                var20 = "-1";
  138.             }
  139.  
  140.             var28 = Integer.parseInt(var20);
  141.             String var22;
  142.             if (var34.hasMoreTokens()) {
  143.                var22 = var34.nextToken();
  144.             } else {
  145.                var22 = "";
  146.             }
  147.  
  148.             String var21;
  149.             if (var34.hasMoreTokens()) {
  150.                var21 = var34.nextToken();
  151.                if (var21.compareTo("\u0003") == 0) {
  152.                   var21 = var22;
  153.                }
  154.             } else {
  155.                var21 = var22;
  156.             }
  157.  
  158.             int var29;
  159.             boolean var32;
  160.             if (var34.hasMoreTokens()) {
  161.                var23 = var34.nextToken();
  162.                var29 = 0;
  163.                if (var23.compareTo("\u0003") == 0) {
  164.                   var32 = false;
  165.                } else {
  166.                   var32 = true;
  167.                   if (var23.indexOf(46) == -1 && var23.indexOf(58) == -1 && var23.indexOf(92) == -1 && var23.indexOf(47) == -1) {
  168.                      int var35 = 0;
  169.  
  170.                      do {
  171.                         if (var23.equalsIgnoreCase(var17[var35])) {
  172.                            var32 = false;
  173.                            var29 = 2 * var35;
  174.                            break;
  175.                         }
  176.  
  177.                         ++var35;
  178.                      } while(var35 < 8);
  179.                   }
  180.                }
  181.             } else {
  182.                var32 = false;
  183.                var29 = 0;
  184.             }
  185.  
  186.             String var24;
  187.             if (var34.hasMoreTokens()) {
  188.                var24 = var34.nextToken();
  189.                if (var24.compareTo("\u0003") == 0) {
  190.                   var24 = null;
  191.                }
  192.             } else {
  193.                var24 = null;
  194.             }
  195.  
  196.             String var25;
  197.             String var26;
  198.             if (var34.hasMoreTokens()) {
  199.                var25 = var34.nextToken();
  200.                if (var34.hasMoreTokens()) {
  201.                   var26 = var34.nextToken();
  202.                } else {
  203.                   var26 = "";
  204.                }
  205.  
  206.                if (var25.compareTo("\u0003") == 0) {
  207.                   var25 = null;
  208.                   var26 = null;
  209.                } else if (var26.compareTo("\u0003") == 0) {
  210.                   var26 = "";
  211.                }
  212.             } else {
  213.                var25 = null;
  214.                var26 = null;
  215.             }
  216.  
  217.             boolean var33;
  218.             if (var34.hasMoreTokens()) {
  219.                String var27 = var34.nextToken();
  220.                if (var27.compareTo("H") == 0) {
  221.                   var33 = true;
  222.                } else {
  223.                   var33 = false;
  224.                }
  225.             } else {
  226.                var33 = false;
  227.             }
  228.  
  229.             if (var28 > 19) {
  230.                var28 = 19;
  231.             } else if (var28 > var30 + 1) {
  232.                var28 = var30 + 1;
  233.             }
  234.  
  235.             if (var28 == -1) {
  236.                var31[0] = this.m_tree.addItem(var21, var22, var28, var29);
  237.                if (var33) {
  238.                   var15.addElement(new Integer(var31[0]));
  239.                }
  240.             } else {
  241.                var31[var28 + 1] = this.m_tree.addItem(var21, var22, var31[var28], var29);
  242.                if (var33) {
  243.                   var15.addElement(new Integer(var31[var28 + 1]));
  244.                }
  245.             }
  246.  
  247.             if (var32) {
  248.                this.m_tree.setItemImageURL(var31[var28 + 1], var23, var24 == null ? var23 : var24);
  249.             }
  250.  
  251.             if (var25 != null) {
  252.                this.m_tree.setItemURL(var31[var28 + 1], var25, var26, false);
  253.             }
  254.          }
  255.       }
  256.  
  257.       if (var15.size() > 0) {
  258.          int var39 = var15.size();
  259.  
  260.          for(int var40 = 0; var40 < var39; ++var40) {
  261.             CFTreeItem var37 = this.m_tree.itemAt((Integer)var15.elementAt(var40));
  262.             this.m_tree.hideChildren(var37);
  263.          }
  264.       }
  265.  
  266.       CFTreeFormApplet var38 = (CFTreeFormApplet)AWTCompatibility.awtApplet();
  267.       var38.m_treeControl = this;
  268.       ((Applet)var38).showStatus("");
  269.    }
  270. }
  271.