home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2002 March / PCWMAR02.iso / software / windowsxp / ftgateoffice / ftgateoffice.exe / Main / webhelp.jar / treeview / TreeView.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-11-07  |  18.1 KB  |  1,543 lines

  1. package treeview;
  2.  
  3. import bssccom.BsscScrollbar;
  4. import hhapplet.BsscFontFixPatch;
  5. import hhapplet.ResourceLib;
  6. import java.applet.Applet;
  7. import java.awt.Button;
  8. import java.awt.Color;
  9. import java.awt.Component;
  10. import java.awt.Container;
  11. import java.awt.Cursor;
  12. import java.awt.Event;
  13. import java.awt.Font;
  14. import java.awt.FontMetrics;
  15. import java.awt.Graphics;
  16. import java.awt.Image;
  17. import java.awt.LayoutManager;
  18. import java.awt.Panel;
  19. import java.awt.Rectangle;
  20. import java.awt.Scrollbar;
  21.  
  22. public class TreeView extends Panel implements ImageSetSource {
  23.    protected int m_nLabelOffset;
  24.    protected ImageSet m_isImages;
  25.    protected ImageSet m_isConnectors;
  26.    protected TreeViewNode m_tvnRoot;
  27.    protected boolean m_bLayoutComplete;
  28.    protected boolean m_bUseButtons;
  29.    protected boolean m_bUseLines;
  30.    protected boolean m_bRootsConnected;
  31.    protected Applet m_applet;
  32.    protected TreeViewNode m_tvnCurrentSelection;
  33.    protected Image m_imgDoubleBuffer;
  34.    protected Rectangle m_rectDisplayArea;
  35.    protected Scrollbar m_sbHorizontal;
  36.    protected Scrollbar m_sbVertical;
  37.    protected BsscScrollbar m_sbBsscHorizontal;
  38.    protected BsscScrollbar m_sbBsscVertical;
  39.    protected boolean m_bIsClumsyNS4;
  40.    protected Button m_btnScrollerCorner;
  41.    protected int m_nInsetX;
  42.    protected int m_nInsetY;
  43.    protected int m_nConnectorWidth;
  44.    protected int m_nIndent;
  45.    protected int m_nIconWidth;
  46.    protected int m_nIconHeight;
  47.    protected int m_nCellHeight;
  48.    protected int m_nFontBaseOffset;
  49.    private boolean m_bNetscapeScrollers;
  50.    private boolean m_bLayedOutByMouseOver;
  51.    private boolean m_bCompletelyFilled;
  52.    private int m_nHorizPosPixels;
  53.    private int m_nVerticalPosPixels;
  54.    private int m_nImageWidth;
  55.    private int m_nImageHeight;
  56.    public static final int LEAF = 0;
  57.    public static final int BRANCH_COLLAPSED = 1;
  58.    public static final int BRANCH_EXPANDED = 2;
  59.    public static final int LEAF_SELECTED = 3;
  60.    public static final int BRANCH_COLLAPSED_SELECTED = 4;
  61.    public static final int BRANCH_EXPANDED_SELECTED = 5;
  62.    public static final int MIN_NUMBER_IMAGES = 3;
  63.    public static final int MIN_NUMBER_IMAGES_SELECTED = 6;
  64.    protected static final int HEIGHT_HORIZONTAL_SB = 16;
  65.    protected static final int WIDTH_VERTICAL_SB = 16;
  66.    protected static final int ICON_VERTICAL_PADDING = 1;
  67.    protected long c_lnDoubleClickWindow;
  68.    private boolean m_bIsNS3Win32;
  69.    private boolean m_bIsNSWin16;
  70.    private boolean m_bIsUnix;
  71.    private long m_lnLastClickTime;
  72.    private boolean m_bIsMac;
  73.    private boolean m_bNeedTreeSize;
  74.    protected boolean m_bMaxWidthIsValid;
  75.    protected boolean m_bMaxHeightIsValid;
  76.    private int m_nMaxWidth;
  77.    private int m_nMaxHeight;
  78.    private boolean m_bUseDoubleBuffer;
  79.    private Object m_Cursor;
  80.  
  81.    public boolean mouseEnter(Event var1, int var2, int var3) {
  82.       if (this.m_bIsClumsyNS4) {
  83.          if (var1.target == this.m_sbBsscHorizontal || var1.target == this.m_sbBsscVertical) {
  84.             return super.mouseEnter(var1, var2, var3);
  85.          }
  86.       } else if (var1.target == this.m_sbHorizontal || var1.target == this.m_sbVertical) {
  87.          return super.mouseEnter(var1, var2, var3);
  88.       }
  89.  
  90.       if (!this.m_bLayoutComplete) {
  91.          this.mylayout();
  92.       }
  93.  
  94.       if (this.m_applet != null) {
  95.          TreeViewNode var4 = this.nodeAtLocation(var2, var3);
  96.          if (var4 != null && this.m_bCompletelyFilled) {
  97.             this.m_applet.showStatus(var4.getLabel());
  98.          }
  99.       }
  100.  
  101.       return false;
  102.    }
  103.  
  104.    public boolean gotFocus(Event var1, Object var2) {
  105.       if (this.m_tvnCurrentSelection == null) {
  106.          this.setSelectionToTop();
  107.          ((Component)this).repaint();
  108.       }
  109.  
  110.       return true;
  111.    }
  112.  
  113.    public void MoveSelectionDown() {
  114.       this.MoveSelectionDown(true);
  115.    }
  116.  
  117.    public void MoveSelectionDown(boolean var1) {
  118.       if (this.m_tvnCurrentSelection.nextNode(true) != null) {
  119.          this.m_tvnCurrentSelection.select(false);
  120.          this.m_tvnCurrentSelection = this.m_tvnCurrentSelection.nextNode(true);
  121.          this.m_tvnCurrentSelection.select(true);
  122.          this.EnsureDisplayed(this.m_tvnCurrentSelection);
  123.          if (var1) {
  124.             this.InternalSelectionHasChanged();
  125.          }
  126.  
  127.          ((Component)this).repaint();
  128.       }
  129.    }
  130.  
  131.    public void ScrollSubTreeIntoView(TreeViewNode var1) {
  132.       if (var1 != null) {
  133.          int var2 = this.GetNodePosition(var1);
  134.          if (this.m_bIsClumsyNS4) {
  135.             if (var2 < this.m_sbBsscVertical.getValue()) {
  136.                this.m_sbBsscVertical.setValue(var2);
  137.             } else {
  138.                int var5 = this.GetOpenChildSiblingCount((TreeViewNode)((SiblingChildTree)var1).getChild());
  139.                int var6 = this.m_rectDisplayArea.height / this.m_nCellHeight - 1;
  140.                if (var5 > 0) {
  141.                   if (var5 >= var6 - 1) {
  142.                      this.m_sbBsscVertical.setValue(var2);
  143.                   } else if (this.m_sbBsscVertical.getValue() < var2 - (var6 - var5)) {
  144.                      this.m_sbBsscVertical.setValue(var2 - (var6 - var5 - 1));
  145.                   }
  146.                }
  147.             }
  148.  
  149.             this.m_nVerticalPosPixels = this.m_sbBsscVertical.getValue() * this.m_nCellHeight;
  150.          } else {
  151.             if (var2 < this.m_sbVertical.getValue()) {
  152.                this.m_sbVertical.setValue(var2);
  153.             } else {
  154.                int var3 = this.GetOpenChildSiblingCount((TreeViewNode)((SiblingChildTree)var1).getChild());
  155.                int var4 = this.m_rectDisplayArea.height / this.m_nCellHeight - 1;
  156.                if (var3 > 0) {
  157.                   if (var3 >= var4 - 1) {
  158.                      this.m_sbVertical.setValue(var2);
  159.                   } else if (this.m_sbVertical.getValue() < var2 - (var4 - var3)) {
  160.                      this.m_sbVertical.setValue(var2 - (var4 - var3 - 1));
  161.                   }
  162.                }
  163.             }
  164.  
  165.             this.m_nVerticalPosPixels = this.m_sbVertical.getValue() * this.m_nCellHeight;
  166.          }
  167.       }
  168.    }
  169.  
  170.    public int getLabelOffset() {
  171.       return this.m_nLabelOffset;
  172.    }
  173.  
  174.    public void setLabelOffset(int var1) {
  175.       this.m_nLabelOffset = var1;
  176.    }
  177.  
  178.    public void CollapseTree() {
  179.       this.m_bMaxHeightIsValid = false;
  180.       this.m_bMaxWidthIsValid = false;
  181.       this.m_tvnCurrentSelection.collapseTree();
  182.       this.mylayout();
  183.       ((Component)this).repaint();
  184.    }
  185.  
  186.    protected int getMaxWidth(TreeViewNode var1, int var2, boolean var3) {
  187.       if (!this.m_bMaxWidthIsValid) {
  188.          this.m_nMaxWidth = this.getMaxSubTreeWidth(var1, var2, var3);
  189.       }
  190.  
  191.       return this.m_nMaxWidth;
  192.    }
  193.  
  194.    public void expandAll() {
  195.       this.m_bMaxHeightIsValid = false;
  196.       this.m_bMaxWidthIsValid = false;
  197.  
  198.       try {
  199.          this.m_tvnRoot.expandTree();
  200.       } catch (NullPointerException var2) {
  201.          ((Throwable)var2).printStackTrace();
  202.       }
  203.    }
  204.  
  205.    public TreeViewNode getCurrentSelection() {
  206.       return this.m_tvnCurrentSelection;
  207.    }
  208.  
  209.    public int GetNodePosition(TreeViewNode var1) {
  210.       TreeViewNode var2 = this.m_tvnRoot;
  211.  
  212.       for(int var3 = 0; var2 != null; var2 = var2.nextNode(true)) {
  213.          if (var1 == var2) {
  214.             return var3;
  215.          }
  216.  
  217.          if (var2.getLabel() != null) {
  218.             ++var3;
  219.          }
  220.       }
  221.  
  222.       return -1;
  223.    }
  224.  
  225.    public void Sync(TreeViewNode var1) {
  226.       if (var1 != null) {
  227.          try {
  228.             while(!this.m_bLayoutComplete) {
  229.                Thread.sleep(100L);
  230.             }
  231.          } catch (InterruptedException var3) {
  232.             ((Throwable)var3).printStackTrace();
  233.          }
  234.  
  235.          TreeViewNode var2 = (TreeViewNode)((SiblingChildTree)var1).getParent();
  236.  
  237.          while(var2 != null && var2.m_bCollapsed) {
  238.             if (var2.m_bCollapsed) {
  239.                var2.m_bCollapsed = false;
  240.                var2 = (TreeViewNode)((SiblingChildTree)var2).getParent();
  241.             }
  242.          }
  243.  
  244.          if (this.m_tvnCurrentSelection != null) {
  245.             this.m_tvnCurrentSelection.select(false);
  246.          }
  247.  
  248.          this.m_tvnCurrentSelection = var1;
  249.          this.m_tvnCurrentSelection.select(true);
  250.          this.mylayout();
  251.          this.EnsureDisplayed(this.m_tvnCurrentSelection);
  252.          this.InternalSelectionHasChanged();
  253.          ((Component)this).repaint();
  254.       }
  255.  
  256.    }
  257.  
  258.    public synchronized void mylayout() {
  259.       this.m_bLayoutComplete = false;
  260.       this.m_rectDisplayArea.reshape(0, 0, ((Component)this).bounds().width, ((Component)this).bounds().height);
  261.       if (this.m_rectDisplayArea.width >= 1 && this.m_rectDisplayArea.height >= 1) {
  262.          try {
  263.             if (this.m_bNeedTreeSize) {
  264.                this.sizeTree(this.m_tvnRoot);
  265.             }
  266.  
  267.             int var1 = this.getMaxWidth(this.m_tvnRoot, 0, true);
  268.             int var2 = this.getMaxHeight(this.m_tvnRoot, 0, true) / this.m_nCellHeight;
  269.             if (var2 >= 1) {
  270.                if (var1 + 1 > this.m_rectDisplayArea.width) {
  271.                   Rectangle var10000 = this.m_rectDisplayArea;
  272.                   var10000.height -= 16;
  273.                }
  274.  
  275.                int var3 = this.m_rectDisplayArea.height / this.m_nCellHeight;
  276.                if (var2 > var3) {
  277.                   Rectangle var6 = this.m_rectDisplayArea;
  278.                   var6.width -= 16;
  279.                }
  280.  
  281.                if (this.m_bIsClumsyNS4) {
  282.                   this.rods_reshape(this.m_sbBsscHorizontal, 0, this.m_rectDisplayArea.height, this.m_rectDisplayArea.width, 16);
  283.                   this.m_sbBsscHorizontal.setValues(this.m_nHorizPosPixels, this.m_rectDisplayArea.width, 0, var1 - (this.m_bNetscapeScrollers ? this.m_rectDisplayArea.width : 0));
  284.                } else {
  285.                   this.rods_reshape(this.m_sbHorizontal, 0, this.m_rectDisplayArea.height, this.m_rectDisplayArea.width, 16);
  286.                   this.m_sbHorizontal.setValues(this.m_nHorizPosPixels, this.m_rectDisplayArea.width, 0, var1 - (this.m_bNetscapeScrollers ? this.m_rectDisplayArea.width : 0));
  287.                }
  288.  
  289.                if (this.m_bIsClumsyNS4) {
  290.                   this.rods_reshape(this.m_sbBsscVertical, this.m_rectDisplayArea.width, 0, 16, this.m_rectDisplayArea.height);
  291.                } else {
  292.                   this.rods_reshape(this.m_sbVertical, this.m_rectDisplayArea.width, 0, 16, this.m_rectDisplayArea.height);
  293.                }
  294.  
  295.                int var4 = this.m_nVerticalPosPixels / this.m_nCellHeight;
  296.                if (var4 + var3 > var2) {
  297.                   var4 = var2 - var3;
  298.                }
  299.  
  300.                if (var4 < 0) {
  301.                   var4 = 0;
  302.                }
  303.  
  304.                if (this.m_bIsClumsyNS4) {
  305.                   this.m_sbBsscVertical.setValues(var4, var3 - 1, 0, var2 - (this.m_bNetscapeScrollers ? var3 : 1));
  306.                   this.m_nVerticalPosPixels = this.m_sbBsscVertical.getValue() * this.m_nCellHeight;
  307.                } else {
  308.                   this.m_sbVertical.setValues(var4, var3 - 1, 0, var2 - (this.m_bNetscapeScrollers ? var3 : 1));
  309.                   this.m_nVerticalPosPixels = this.m_sbVertical.getValue() * this.m_nCellHeight;
  310.                }
  311.  
  312.                this.rods_reshape(this.m_btnScrollerCorner, this.m_rectDisplayArea.width, this.m_rectDisplayArea.height, 16, 16);
  313.                if (this.m_rectDisplayArea.height < 0) {
  314.                   this.m_rectDisplayArea.height = 0;
  315.                }
  316.  
  317.                if (this.m_rectDisplayArea.width < 0) {
  318.                   this.m_rectDisplayArea.width = 0;
  319.                }
  320.  
  321.                if (this.m_imgDoubleBuffer != null && (this.m_nImageWidth != this.m_rectDisplayArea.width || this.m_nImageHeight != this.m_rectDisplayArea.height)) {
  322.                   this.m_imgDoubleBuffer.flush();
  323.                   this.m_imgDoubleBuffer = null;
  324.                }
  325.  
  326.                if (this.m_imgDoubleBuffer == null) {
  327.                   this.m_imgDoubleBuffer = ((Component)this).createImage(this.m_rectDisplayArea.width, this.m_rectDisplayArea.height);
  328.                   this.m_nImageWidth = this.m_rectDisplayArea.width;
  329.                   this.m_nImageHeight = this.m_rectDisplayArea.height;
  330.                }
  331.  
  332.                this.m_bLayoutComplete = true;
  333.             }
  334.          } catch (Exception var5) {
  335.             ((Throwable)var5).printStackTrace();
  336.             this.m_imgDoubleBuffer = null;
  337.          }
  338.       }
  339.    }
  340.  
  341.    protected void sizeTree(TreeViewNode var1) {
  342.       for(TreeViewNode var2 = var1; var2 != null; var2 = (TreeViewNode)((SiblingChildTree)var2).getSibling()) {
  343.          this.sizeNode(var2);
  344.          this.sizeTree((TreeViewNode)((SiblingChildTree)var2).getChild());
  345.       }
  346.  
  347.       this.m_bNeedTreeSize = false;
  348.    }
  349.  
  350.    public void setSelectionToTop() {
  351.       if (this.m_tvnCurrentSelection != null) {
  352.          this.m_tvnCurrentSelection.select(false);
  353.       }
  354.  
  355.       for(this.m_tvnCurrentSelection = this.m_tvnRoot; this.m_tvnCurrentSelection != null && this.m_tvnCurrentSelection.getLabel() == null; this.m_tvnCurrentSelection = this.m_tvnCurrentSelection.nextNode(true)) {
  356.       }
  357.  
  358.       if (this.m_tvnCurrentSelection != null) {
  359.          this.m_tvnCurrentSelection.select(true);
  360.       }
  361.  
  362.    }
  363.  
  364.    public int getCellHeight() {
  365.       return this.m_nCellHeight;
  366.    }
  367.  
  368.    public void setCellHeight(int var1) {
  369.       if (var1 < this.m_nIconHeight + 1) {
  370.          this.m_nCellHeight = this.m_nIconHeight + 1;
  371.       } else {
  372.          this.m_nCellHeight = var1;
  373.       }
  374.    }
  375.  
  376.    public void layout() {
  377.       if (this.m_bLayoutComplete) {
  378.          this.mylayout();
  379.       }
  380.  
  381.    }
  382.  
  383.    public boolean IsDisplayed(TreeViewNode var1) {
  384.       TreeViewNode var2 = this.GetFirstDisplayedNode();
  385.  
  386.       for(int var3 = this.m_rectDisplayArea.height / this.m_nCellHeight; var2 != null && var3 > 0; var2 = var2.nextNode(true)) {
  387.          if (var2.getLabel() != null) {
  388.             --var3;
  389.          }
  390.  
  391.          if (var1 == var2) {
  392.             return true;
  393.          }
  394.       }
  395.  
  396.       return false;
  397.    }
  398.  
  399.    protected void toggleOpenCloseNode(TreeViewNode var1) {
  400.       this.m_bMaxHeightIsValid = false;
  401.       this.m_bMaxWidthIsValid = false;
  402.       var1.setCollapsedState(!var1.getCollapsedState());
  403.       if (var1.getCollapsedState()) {
  404.          this.m_tvnCurrentSelection.select(false);
  405.  
  406.          for(TreeViewNode var2 = (TreeViewNode)this.m_tvnCurrentSelection.getParent(); var2 != null; var2 = (TreeViewNode)((SiblingChildTree)var2).getParent()) {
  407.             if (var2.getCollapsedState()) {
  408.                this.m_tvnCurrentSelection = var2;
  409.             }
  410.          }
  411.  
  412.          this.m_tvnCurrentSelection.select(true);
  413.          this.InternalSelectionHasChanged();
  414.          int var5 = this.getMaxHeight(this.m_tvnRoot, 0, true) / this.m_nCellHeight - 1;
  415.          int var3 = this.m_rectDisplayArea.height / this.m_nCellHeight;
  416.          int var4 = this.m_nVerticalPosPixels / this.m_nCellHeight;
  417.          if (var4 + var3 > var5) {
  418.             var4 = Math.max(var5 - var3, 0);
  419.          }
  420.  
  421.          this.m_nVerticalPosPixels = var4 * this.m_nCellHeight;
  422.       } else {
  423.          this.mylayout();
  424.          this.ScrollSubTreeIntoView(this.m_tvnCurrentSelection);
  425.       }
  426.    }
  427.  
  428.    public TreeViewNode nextVisibleNode() {
  429.       try {
  430.          return this.m_tvnRoot.nextNode(true);
  431.       } catch (NullPointerException var2) {
  432.          ((Throwable)var2).printStackTrace();
  433.          return null;
  434.       }
  435.    }
  436.  
  437.    public TreeViewNode previousVisibleNode() {
  438.       try {
  439.          return this.m_tvnRoot.prevNode(true);
  440.       } catch (NullPointerException var1) {
  441.          return null;
  442.       }
  443.    }
  444.  
  445.    public void setTopIndex(int var1) {
  446.       int var2 = this.m_rectDisplayArea.height / this.m_nCellHeight;
  447.       int var3 = this.getMaxHeight(this.m_tvnRoot, 0, true) / this.m_nCellHeight - 1;
  448.       this.m_nVerticalPosPixels = var1 * this.m_nCellHeight;
  449.       if (this.m_bIsClumsyNS4) {
  450.          this.m_sbBsscVertical.setValues(var1, var2 - 1, 0, var3 - (this.m_bNetscapeScrollers ? var2 : 1));
  451.       } else {
  452.          this.m_sbVertical.setValues(var1, var2 - 1, 0, var3 - (this.m_bNetscapeScrollers ? var2 : 1));
  453.       }
  454.  
  455.       ((Component)this).paintAll(((Component)this).getGraphics());
  456.    }
  457.  
  458.    public void MoveSelectionHome() {
  459.       this.setSelectionToTop();
  460.       if (this.m_bIsClumsyNS4) {
  461.          this.m_sbBsscVertical.setValue(0);
  462.          this.m_nVerticalPosPixels = this.m_sbBsscVertical.getValue() * this.m_nCellHeight;
  463.       } else {
  464.          this.m_sbVertical.setValue(0);
  465.          this.m_nVerticalPosPixels = this.m_sbVertical.getValue() * this.m_nCellHeight;
  466.       }
  467.  
  468.       ((Component)this).repaint();
  469.    }
  470.  
  471.    public void CollapseBranch() {
  472.       this.m_bMaxHeightIsValid = false;
  473.       this.m_bMaxWidthIsValid = false;
  474.       this.m_tvnCurrentSelection.setCollapsedState(true);
  475.       this.mylayout();
  476.       ((Component)this).repaint();
  477.    }
  478.  
  479.    public boolean mouseExit(Event var1, int var2, int var3) {
  480.       if (this.m_bIsClumsyNS4) {
  481.          if (var1.target == this.m_sbBsscHorizontal || var1.target == this.m_sbBsscVertical) {
  482.             return super.mouseExit(var1, var2, var3);
  483.          }
  484.       } else if (var1.target == this.m_sbHorizontal || var1.target == this.m_sbVertical) {
  485.          return super.mouseExit(var1, var2, var3);
  486.       }
  487.  
  488.       if (this.m_applet != null && this.m_bCompletelyFilled) {
  489.          this.m_applet.showStatus("");
  490.       }
  491.  
  492.       return false;
  493.    }
  494.  
  495.    public void setFilled(boolean var1) {
  496.       this.m_bCompletelyFilled = var1;
  497.       this.m_bLayoutComplete = false;
  498.       this.m_bNeedTreeSize = true;
  499.       this.m_bMaxHeightIsValid = false;
  500.       this.m_bMaxWidthIsValid = false;
  501.       ((Component)this).repaint();
  502.    }
  503.  
  504.    public void setApplet(Applet var1) {
  505.       this.m_applet = var1;
  506.    }
  507.  
  508.    protected void rods_reshape(Component var1, int var2, int var3, int var4, int var5) {
  509.       var1.move(var2, var3);
  510.       var1.resize(var4, var5);
  511.    }
  512.  
  513.    public boolean getUseLines() {
  514.       return this.m_bUseLines;
  515.    }
  516.  
  517.    public TreeViewNode getRoot() {
  518.       return this.m_tvnRoot;
  519.    }
  520.  
  521.    public void setRoot(TreeViewNode var1) {
  522.       this.m_tvnRoot = var1;
  523.       this.setSelectionToTop();
  524.    }
  525.  
  526.    public void setUseLines(boolean var1) {
  527.       this.m_bUseLines = var1;
  528.    }
  529.  
  530.    protected void InternalSelectionHasChanged() {
  531.    }
  532.  
  533.    protected int drawConnector(Graphics var1, TreeViewNode var2, int var3, int var4) {
  534.       if (this.m_bUseButtons && this.m_bUseLines) {
  535.          Image var18 = null;
  536.          Object var6 = null;
  537.  
  538.          try {
  539.             if (((SiblingChildTree)var2).getChild() != null) {
  540.                if (var2.getCollapsedState()) {
  541.                   var18 = this.m_isConnectors.getImage(5);
  542.                } else {
  543.                   var18 = this.m_isConnectors.getImage(6);
  544.                }
  545.             }
  546.          } catch (IndexOutOfBoundsException var12) {
  547.             ((Throwable)var12).printStackTrace();
  548.             var18 = null;
  549.          } catch (NullPointerException var13) {
  550.             ((Throwable)var13).printStackTrace();
  551.             var18 = null;
  552.          }
  553.  
  554.          try {
  555.             if (((SiblingChildTree)var2).getParent() == null) {
  556.                if (this.m_bRootsConnected) {
  557.                   if (((SiblingChildTree)var2).getSiblingLeft() == null) {
  558.                      if (((SiblingChildTree)var2).getSibling() == null) {
  559.                         var19 = this.m_isConnectors.getImage(1);
  560.                      } else {
  561.                         var19 = this.m_isConnectors.getImage(2);
  562.                      }
  563.                   } else if (((SiblingChildTree)var2).getSibling() == null) {
  564.                      var19 = this.m_isConnectors.getImage(4);
  565.                   } else {
  566.                      var19 = this.m_isConnectors.getImage(3);
  567.                   }
  568.                } else {
  569.                   var19 = this.m_isConnectors.getImage(1);
  570.                }
  571.             } else if (((SiblingChildTree)var2).getSiblingLeft() == null && ((SiblingChildTree)var2).getParent() != null && ((TreeViewNode)((SiblingChildTree)var2).getParent()).getLabel() == null) {
  572.                var19 = this.m_isConnectors.getImage(2);
  573.             } else if (((SiblingChildTree)var2).getSibling() == null) {
  574.                var19 = this.m_isConnectors.getImage(4);
  575.             } else {
  576.                var19 = this.m_isConnectors.getImage(3);
  577.             }
  578.          } catch (IndexOutOfBoundsException var14) {
  579.             ((Throwable)var14).printStackTrace();
  580.             var19 = null;
  581.          } catch (NullPointerException var15) {
  582.             ((Throwable)var15).printStackTrace();
  583.             var19 = null;
  584.          }
  585.  
  586.          if (var19 != null) {
  587.             var1.drawImage(var19, var3, var4, this);
  588.          }
  589.  
  590.          if (var18 != null) {
  591.             var1.drawImage(var18, var3, var4, this);
  592.          }
  593.  
  594.          var3 += this.m_nConnectorWidth;
  595.       } else if (this.m_bUseButtons) {
  596.          Image var5 = null;
  597.  
  598.          try {
  599.             if (((SiblingChildTree)var2).getChild() != null) {
  600.                if (var2.getCollapsedState()) {
  601.                   var5 = this.m_isConnectors.getImage(5);
  602.                } else {
  603.                   var5 = this.m_isConnectors.getImage(6);
  604.                }
  605.             }
  606.          } catch (IndexOutOfBoundsException var10) {
  607.             ((Throwable)var10).printStackTrace();
  608.             var5 = null;
  609.          } catch (NullPointerException var11) {
  610.             ((Throwable)var11).printStackTrace();
  611.             var5 = null;
  612.          }
  613.  
  614.          if (var5 != null) {
  615.             var1.drawImage(var5, var3, var4, this);
  616.          }
  617.  
  618.          var3 += this.m_nConnectorWidth;
  619.       } else if (this.m_bUseLines) {
  620.          Object var16 = null;
  621.  
  622.          try {
  623.             if (((SiblingChildTree)var2).getParent() == null) {
  624.                if (this.m_bRootsConnected) {
  625.                   if (((SiblingChildTree)var2).getSiblingLeft() == null) {
  626.                      if (((SiblingChildTree)var2).getSibling() == null) {
  627.                         var17 = this.m_isConnectors.getImage(1);
  628.                      } else {
  629.                         var17 = this.m_isConnectors.getImage(2);
  630.                      }
  631.                   } else if (((SiblingChildTree)var2).getSibling() == null) {
  632.                      var17 = this.m_isConnectors.getImage(4);
  633.                   } else {
  634.                      var17 = this.m_isConnectors.getImage(3);
  635.                   }
  636.                } else {
  637.                   var17 = this.m_isConnectors.getImage(1);
  638.                }
  639.             } else if (((SiblingChildTree)var2).getSibling() == null) {
  640.                var17 = this.m_isConnectors.getImage(4);
  641.             } else {
  642.                var17 = this.m_isConnectors.getImage(3);
  643.             }
  644.          } catch (IndexOutOfBoundsException var8) {
  645.             ((Throwable)var8).printStackTrace();
  646.             var17 = null;
  647.          } catch (NullPointerException var9) {
  648.             ((Throwable)var9).printStackTrace();
  649.             var17 = null;
  650.          }
  651.  
  652.          if (var17 != null) {
  653.             var1.drawImage(var17, var3, var4, this);
  654.          }
  655.  
  656.          var3 += this.m_nConnectorWidth;
  657.       }
  658.  
  659.       return var3;
  660.    }
  661.  
  662.    protected void paintBorder(Graphics var1) {
  663.       Rectangle var2 = this.m_rectDisplayArea;
  664.       Color var3 = ((Component)this).getBackground();
  665.       Color var4 = var3.darker();
  666.       Color var5 = var4.darker();
  667.       Color var6 = var5.darker();
  668.       var1.setColor(var5);
  669.       var1.drawLine(0, 0, var2.width - 1, 0);
  670.       var1.drawLine(0, 0, 0, var2.height - 1);
  671.       var1.setColor(var6);
  672.       var1.drawLine(1, 1, var2.width - 2, 1);
  673.       var1.drawLine(1, 1, 1, var2.height - 2);
  674.       var1.setColor(var4);
  675.       var1.drawLine(var2.width - 2, 1, var2.width - 2, var2.height - 2);
  676.       var1.drawLine(1, var2.height - 2, var2.width - 2, var2.height - 2);
  677.       var1.setColor(var3);
  678.       var1.drawLine(var2.width - 1, 1, var2.width - 1, var2.height - 1);
  679.       var1.drawLine(0, var2.height - 1, var2.width - 1, var2.height - 1);
  680.    }
  681.  
  682.    public void collapseAll() {
  683.       this.m_bMaxHeightIsValid = false;
  684.       this.m_bMaxWidthIsValid = false;
  685.  
  686.       try {
  687.          this.m_tvnRoot.collapseTree();
  688.       } catch (NullPointerException var2) {
  689.          ((Throwable)var2).printStackTrace();
  690.       }
  691.    }
  692.  
  693.    public int getIconHeight() {
  694.       return this.m_nIconHeight;
  695.    }
  696.  
  697.    public void setIconHeight(int var1) {
  698.       if (var1 < 0) {
  699.          var1 = 0;
  700.       }
  701.  
  702.       this.m_nIconHeight = var1;
  703.       if (var1 > this.m_nCellHeight - 1) {
  704.          this.m_nCellHeight = var1 + 1;
  705.       }
  706.  
  707.    }
  708.  
  709.    public void ScrollRight() {
  710.       if (this.m_bIsClumsyNS4) {
  711.          this.m_sbBsscHorizontal.setValue(this.m_sbBsscHorizontal.getValue() + 1);
  712.          this.m_nHorizPosPixels = this.m_sbBsscHorizontal.getValue();
  713.       } else {
  714.          this.m_sbHorizontal.setValue(this.m_sbHorizontal.getValue() + 1);
  715.          this.m_nHorizPosPixels = this.m_sbHorizontal.getValue();
  716.       }
  717.  
  718.       ((Component)this).repaint();
  719.    }
  720.  
  721.    protected int getMaxSubTreeHeight(TreeViewNode var1, int var2, boolean var3) {
  722.       int var4 = var2;
  723.  
  724.       for(TreeViewNode var5 = var1; var5 != null; var5 = (TreeViewNode)((SiblingChildTree)var5).getSibling()) {
  725.          var4 += var5.getHeight();
  726.          if (!var3 || !var5.getCollapsedState()) {
  727.             var4 = this.getMaxSubTreeHeight((TreeViewNode)((SiblingChildTree)var5).getChild(), var4, var3);
  728.          }
  729.       }
  730.  
  731.       return var4;
  732.    }
  733.  
  734.    public int getIndent() {
  735.       return this.m_nIndent;
  736.    }
  737.  
  738.    public void setIndent(int var1) {
  739.       this.m_nIndent = var1;
  740.    }
  741.  
  742.    public boolean getRootsConnected() {
  743.       return this.m_bRootsConnected;
  744.    }
  745.  
  746.    public void setRootsConnected(boolean var1) {
  747.       this.m_bRootsConnected = var1;
  748.    }
  749.  
  750.    public boolean handleEvent(Event var1) {
  751.       switch (var1.id) {
  752.          case 401:
  753.             switch (var1.key) {
  754.                case 10:
  755.                   this.m_tvnCurrentSelection.doAction();
  756.                   return super.handleEvent(var1);
  757.                case 43:
  758.                   this.ExpandBranch();
  759.                   return super.handleEvent(var1);
  760.                case 45:
  761.                   this.CollapseBranch();
  762.                   return super.handleEvent(var1);
  763.                default:
  764.                   return super.handleEvent(var1);
  765.             }
  766.          case 402:
  767.             if (System.getProperty("java.vendor").startsWith("Netscape") && System.getProperty("java.version").equalsIgnoreCase("1.1.2") && System.getProperty("os.name").startsWith("Mac")) {
  768.                this.m_tvnCurrentSelection.doAction();
  769.             }
  770.             break;
  771.          case 403:
  772.             switch (var1.key) {
  773.                case 10:
  774.                   this.m_tvnCurrentSelection.doAction();
  775.                   return super.handleEvent(var1);
  776.                case 1000:
  777.                   this.MoveSelectionHome();
  778.                   return super.handleEvent(var1);
  779.                case 1001:
  780.                   this.MoveSelectionEnd();
  781.                   return super.handleEvent(var1);
  782.                case 1002:
  783.                   this.MoveSelectionPgUp();
  784.                   return super.handleEvent(var1);
  785.                case 1003:
  786.                   this.MoveSelectionPgDn();
  787.                   return super.handleEvent(var1);
  788.                case 1004:
  789.                   this.MoveSelectionUp();
  790.                   return super.handleEvent(var1);
  791.                case 1005:
  792.                   this.MoveSelectionDown();
  793.                   return super.handleEvent(var1);
  794.                case 1006:
  795.                   if (this.m_tvnCurrentSelection.getChild() != null && !this.m_tvnCurrentSelection.getCollapsedState()) {
  796.                      if ((var1.modifiers & 1) == 1) {
  797.                         this.CollapseTree();
  798.                      } else {
  799.                         this.CollapseBranch();
  800.                      }
  801.  
  802.                      return super.handleEvent(var1);
  803.                   } else {
  804.                      if (this.m_tvnCurrentSelection.getParent() != null) {
  805.                         this.MoveSelectionToParent();
  806.                         return super.handleEvent(var1);
  807.                      }
  808.  
  809.                      return super.handleEvent(var1);
  810.                   }
  811.                case 1007:
  812.                   if (!this.m_tvnCurrentSelection.getCollapsedState()) {
  813.                      if (this.m_tvnCurrentSelection.getChild() != null) {
  814.                         this.MoveSelectionDown();
  815.                         return super.handleEvent(var1);
  816.                      }
  817.  
  818.                      return super.handleEvent(var1);
  819.                   } else {
  820.                      if ((var1.modifiers & 1) == 1) {
  821.                         this.ExpandTree();
  822.                      } else {
  823.                         this.ExpandBranch();
  824.                      }
  825.  
  826.                      return super.handleEvent(var1);
  827.                   }
  828.                default:
  829.                   return super.handleEvent(var1);
  830.             }
  831.          case 501:
  832.             if (this.m_bIsClumsyNS4) {
  833.                if (var1.target == this.m_sbBsscHorizontal || var1.target == this.m_sbBsscVertical) {
  834.                   break;
  835.                }
  836.             } else if (var1.target == this.m_sbHorizontal || var1.target == this.m_sbVertical) {
  837.                break;
  838.             }
  839.  
  840.             if (this.m_rectDisplayArea.inside(var1.x, var1.y)) {
  841.                int var2 = var1.x + this.m_nHorizPosPixels;
  842.                byte var3 = 11;
  843.                TreeViewNode var4 = this.nodeAtLocation(var1.x, var1.y);
  844.                if (var4 != null) {
  845.                   boolean var5 = !this.m_bIsMac && var1.clickCount % 2 == 0;
  846.                   if (this.m_bIsUnix || this.m_bIsMac || this.m_bIsNSWin16) {
  847.                      long var6 = System.currentTimeMillis();
  848.                      if (this.m_lnLastClickTime > var6 - this.c_lnDoubleClickWindow) {
  849.                         var5 = true;
  850.                         this.m_lnLastClickTime = 0L;
  851.                      } else {
  852.                         this.m_lnLastClickTime = var6;
  853.                      }
  854.                   }
  855.  
  856.                   if (this.m_bIsMac && !var5) {
  857.                      var1.clickCount = 1;
  858.                   }
  859.  
  860.                   if (((SiblingChildTree)var4).getChild() != null && var2 > var4.getBounds().x && (var2 < var4.getBounds().x + var3 || var5)) {
  861.                      ((Component)this).requestFocus();
  862.                      if (this.m_tvnCurrentSelection != null) {
  863.                         this.m_tvnCurrentSelection.select(false);
  864.                      }
  865.  
  866.                      this.m_tvnCurrentSelection = var4;
  867.                      this.m_tvnCurrentSelection.select(true);
  868.                      this.InternalSelectionHasChanged();
  869.                      var4.doAction();
  870.                      this.toggleOpenCloseNode(var4);
  871.                      this.mylayout();
  872.                      ((Component)this).requestFocus();
  873.                      ((Component)this).repaint();
  874.                   } else if (var2 > var4.getBounds().x + var3 && var1.clickCount < 2) {
  875.                      if (this.m_tvnCurrentSelection != null) {
  876.                         this.m_tvnCurrentSelection.select(false);
  877.                      }
  878.  
  879.                      this.m_tvnCurrentSelection = var4;
  880.                      this.m_tvnCurrentSelection.select(true);
  881.                      this.InternalSelectionHasChanged();
  882.                      var4.doAction();
  883.                      ((Component)this).repaint();
  884.                   }
  885.  
  886.                   if (var5) {
  887.                      var4.doDblClick();
  888.                   }
  889.                }
  890.             }
  891.             break;
  892.          case 601:
  893.          case 602:
  894.          case 603:
  895.          case 604:
  896.          case 605:
  897.             if (this.m_bIsClumsyNS4) {
  898.                if (var1.target == this.m_sbBsscHorizontal) {
  899.                   this.m_nHorizPosPixels = this.m_sbBsscHorizontal.getValue();
  900.                } else if (var1.target == this.m_sbBsscVertical) {
  901.                   this.m_nVerticalPosPixels = this.m_sbBsscVertical.getValue() * this.m_nCellHeight;
  902.                }
  903.             } else if (var1.target == this.m_sbHorizontal) {
  904.                this.m_nHorizPosPixels = this.m_sbHorizontal.getValue();
  905.             } else if (var1.target == this.m_sbVertical) {
  906.                this.m_nVerticalPosPixels = this.m_sbVertical.getValue() * this.m_nCellHeight;
  907.             }
  908.  
  909.             ((Component)this).repaint();
  910.       }
  911.  
  912.       return super.handleEvent(var1);
  913.    }
  914.  
  915.    public void MoveSelectionToParent() {
  916.       if (this.m_tvnCurrentSelection.getParent() != null) {
  917.          if (this.m_tvnCurrentSelection.getParent() != this.m_tvnRoot) {
  918.             this.m_tvnCurrentSelection.select(false);
  919.             this.m_tvnCurrentSelection = (TreeViewNode)this.m_tvnCurrentSelection.getParent();
  920.             this.m_tvnCurrentSelection.select(true);
  921.             this.EnsureDisplayed(this.m_tvnCurrentSelection);
  922.             this.InternalSelectionHasChanged();
  923.             ((Component)this).repaint();
  924.          }
  925.       }
  926.    }
  927.  
  928.    public void ExpandTree() {
  929.       this.m_bMaxHeightIsValid = false;
  930.       this.m_bMaxWidthIsValid = false;
  931.       this.m_tvnCurrentSelection.expandTree();
  932.       this.mylayout();
  933.       ((Component)this).repaint();
  934.    }
  935.  
  936.    protected int paintTree(Graphics var1, TreeViewNode var2, int var3, int var4, Rectangle var5) {
  937.       TreeViewNode var6 = var2;
  938.  
  939.       while(var6 != null) {
  940.          int var7 = var3;
  941.          int var8 = var4;
  942.          if (var6.getLabel() != null) {
  943.             if (var5.inside(var3, var4) || var5.inside(var3, var4 + this.m_nCellHeight)) {
  944.                this.paintNode(var1, var6, var3, var4);
  945.             }
  946.  
  947.             var7 = var3 + this.m_nIndent;
  948.             var8 = var4 + this.m_nCellHeight;
  949.          }
  950.  
  951.          if (!var6.getCollapsedState()) {
  952.             var4 = this.paintTree(var1, (TreeViewNode)((SiblingChildTree)var6).getChild(), var7, var8, var5);
  953.          } else {
  954.             var4 = var8;
  955.          }
  956.  
  957.          var6 = (TreeViewNode)((SiblingChildTree)var6).getSibling();
  958.          if (var8 > var5.y + var5.height) {
  959.             var6 = null;
  960.          }
  961.       }
  962.  
  963.       return var4;
  964.    }
  965.  
  966.    protected TreeViewNode nodeAtLocation(int var1, int var2) {
  967.       if (!this.m_rectDisplayArea.inside(var1, var2)) {
  968.          return null;
  969.       } else {
  970.          int var3 = var2 + this.m_nVerticalPosPixels;
  971.  
  972.          for(TreeViewNode var4 = this.m_tvnRoot; var4 != null; var4 = var4.nextNode(true)) {
  973.             Rectangle var5 = var4.getBounds();
  974.             if (var3 > var5.y && var3 <= var5.y + var5.height && var4.getLabel() != null) {
  975.                return var4;
  976.             }
  977.          }
  978.  
  979.          return null;
  980.       }
  981.    }
  982.  
  983.    public void ScrollLeft() {
  984.       if (this.m_bIsClumsyNS4) {
  985.          this.m_sbBsscHorizontal.setValue(this.m_sbBsscHorizontal.getValue() - 1);
  986.          this.m_nHorizPosPixels = this.m_sbBsscHorizontal.getValue();
  987.       } else {
  988.          this.m_sbHorizontal.setValue(this.m_sbHorizontal.getValue() - 1);
  989.          this.m_nHorizPosPixels = this.m_sbHorizontal.getValue();
  990.       }
  991.  
  992.       ((Component)this).repaint();
  993.    }
  994.  
  995.    public boolean mouseMove(Event var1, int var2, int var3) {
  996.       if (this.m_bIsClumsyNS4) {
  997.          if (var1.target == this.m_sbBsscHorizontal || var1.target == this.m_sbBsscVertical) {
  998.             return super.mouseMove(var1, var2, var3);
  999.          }
  1000.       } else if (var1.target == this.m_sbHorizontal || var1.target == this.m_sbVertical) {
  1001.          return super.mouseMove(var1, var2, var3);
  1002.       }
  1003.  
  1004.       if (!this.m_bLayoutComplete) {
  1005.          this.mylayout();
  1006.       }
  1007.  
  1008.       if (this.m_applet != null) {
  1009.          TreeViewNode var4 = this.nodeAtLocation(var2, var3);
  1010.          if (var4 != null) {
  1011.             if (this.m_bCompletelyFilled) {
  1012.                this.m_applet.showStatus(var4.getLabel());
  1013.             }
  1014.          } else if (this.m_bCompletelyFilled) {
  1015.             this.m_applet.showStatus("");
  1016.          }
  1017.       }
  1018.  
  1019.       return false;
  1020.    }
  1021.  
  1022.    protected void sizeNode(TreeViewNode var1) {
  1023.       if (var1 != null) {
  1024.          FontMetrics var2 = ((Component)this).getFontMetrics(((Component)this).getFont());
  1025.          int var3 = 0;
  1026.          if (this.m_bUseButtons || this.m_bUseLines) {
  1027.             var3 = this.m_nIconWidth;
  1028.          }
  1029.  
  1030.          if (var1.getCurrentImage() != null) {
  1031.             var3 += this.m_nIconWidth + this.m_nLabelOffset;
  1032.          }
  1033.  
  1034.          if (var1.getLabel() != null) {
  1035.             var3 += var2.stringWidth(var1.getLabel() + ' ');
  1036.          } else if (var1.getCurrentImage() != null) {
  1037.             var3 -= this.m_nLabelOffset;
  1038.          }
  1039.  
  1040.          var1.setBounds(0, 0, var3, this.m_nCellHeight);
  1041.       }
  1042.    }
  1043.  
  1044.    public TreeViewNode nextNode(boolean var1) {
  1045.       try {
  1046.          return (TreeViewNode)this.m_tvnRoot.prevNode();
  1047.       } catch (NullPointerException var2) {
  1048.          return null;
  1049.       }
  1050.    }
  1051.  
  1052.    public TreeViewNode previousNode(boolean var1) {
  1053.       try {
  1054.          return (TreeViewNode)this.m_tvnRoot.prevNode();
  1055.       } catch (NullPointerException var2) {
  1056.          return null;
  1057.       }
  1058.    }
  1059.  
  1060.    public void ExpandBranch() {
  1061.       this.m_bMaxHeightIsValid = false;
  1062.       this.m_bMaxWidthIsValid = false;
  1063.       this.m_tvnCurrentSelection.setCollapsedState(false);
  1064.       this.mylayout();
  1065.       this.ScrollSubTreeIntoView(this.m_tvnCurrentSelection);
  1066.       ((Component)this).repaint();
  1067.    }
  1068.  
  1069.    public void update(Graphics var1) {
  1070.       if (!this.m_bLayoutComplete) {
  1071.          this.mylayout();
  1072.       }
  1073.  
  1074.       this.paint(var1);
  1075.    }
  1076.  
  1077.    public void ResetCursor() {
  1078.       if (!System.getProperty("java.version").startsWith("1.0") && (System.getProperty("java.vendor").indexOf("Netscape") == -1 || !System.getProperty("java.version").startsWith("1.1.2"))) {
  1079.          if (this.m_Cursor != null) {
  1080.             try {
  1081.                ((Component)this).setCursor((Cursor)this.m_Cursor);
  1082.             } catch (Exception var1) {
  1083.             }
  1084.  
  1085.             this.m_Cursor = null;
  1086.          }
  1087.  
  1088.       }
  1089.    }
  1090.  
  1091.    public int getXInset() {
  1092.       return this.m_nInsetX;
  1093.    }
  1094.  
  1095.    public void setXInset(int var1) {
  1096.       if (var1 < 0) {
  1097.          var1 = 0;
  1098.       }
  1099.  
  1100.    }
  1101.  
  1102.    public void MoveSelectionUp() {
  1103.       this.MoveSelectionUp(true);
  1104.    }
  1105.  
  1106.    public ImageSet getConnectors() {
  1107.       return this.m_isConnectors;
  1108.    }
  1109.  
  1110.    public void setConnectors(ImageSet var1) {
  1111.       this.m_isConnectors = var1;
  1112.    }
  1113.  
  1114.    public int getIconWidth() {
  1115.       return this.m_nIconWidth;
  1116.    }
  1117.  
  1118.    public void setIconWidth(int var1) {
  1119.       if (var1 < 0) {
  1120.          var1 = 0;
  1121.       }
  1122.  
  1123.       this.m_nIconWidth = var1;
  1124.    }
  1125.  
  1126.    public void MoveSelectionUp(boolean var1) {
  1127.       if (this.m_tvnCurrentSelection.prevNode(true) != null) {
  1128.          if (this.m_tvnCurrentSelection.prevNode(true) != this.m_tvnRoot) {
  1129.             this.m_tvnCurrentSelection.select(false);
  1130.             this.m_tvnCurrentSelection = this.m_tvnCurrentSelection.prevNode(true);
  1131.             this.m_tvnCurrentSelection.select(true);
  1132.             this.EnsureDisplayed(this.m_tvnCurrentSelection);
  1133.             if (var1) {
  1134.                this.InternalSelectionHasChanged();
  1135.             }
  1136.  
  1137.             ((Component)this).repaint();
  1138.          }
  1139.       }
  1140.    }
  1141.  
  1142.    protected int getMaxSubTreeWidth(TreeViewNode var1, int var2, boolean var3) {
  1143.       int var4 = 0;
  1144.  
  1145.       for(TreeViewNode var5 = var1; var5 != null; var5 = (TreeViewNode)((SiblingChildTree)var5).getSibling()) {
  1146.          if (var5.getWidth() + var2 > var4) {
  1147.             var4 = var5.getWidth() + var2;
  1148.          }
  1149.  
  1150.          if (!var3 || !var5.getCollapsedState()) {
  1151.             int var6 = this.getMaxSubTreeWidth((TreeViewNode)((SiblingChildTree)var5).getChild(), var2 + this.m_nIndent, var3);
  1152.             if (var6 > var4) {
  1153.                var4 = var6;
  1154.             }
  1155.          }
  1156.       }
  1157.  
  1158.       return var4;
  1159.    }
  1160.  
  1161.    public boolean isFocusTraversable() {
  1162.       return true;
  1163.    }
  1164.  
  1165.    protected int getMaxHeight(TreeViewNode var1, int var2, boolean var3) {
  1166.       if (!this.m_bMaxHeightIsValid) {
  1167.          this.m_nMaxHeight = this.getMaxSubTreeHeight(var1, var2, var3);
  1168.       }
  1169.  
  1170.       return this.m_nMaxHeight;
  1171.    }
  1172.  
  1173.    public int getYInset() {
  1174.       return this.m_nInsetY;
  1175.    }
  1176.  
  1177.    public void setYInset(int var1) {
  1178.       if (var1 < 0) {
  1179.          var1 = 0;
  1180.       }
  1181.  
  1182.    }
  1183.  
  1184.    public void MoveSelectionPgDn() {
  1185.       int var1 = this.m_rectDisplayArea.height / this.m_nCellHeight - 1;
  1186.  
  1187.       for(int var2 = 0; var2 < var1; ++var2) {
  1188.          this.MoveSelectionDown(false);
  1189.       }
  1190.  
  1191.       this.InternalSelectionHasChanged();
  1192.       ((Component)this).repaint();
  1193.    }
  1194.  
  1195.    public TreeView() {
  1196.       this((ImageSet)null, (TreeViewNode)null);
  1197.    }
  1198.  
  1199.    public TreeView(ImageSet var1) {
  1200.       this(var1, (TreeViewNode)null);
  1201.    }
  1202.  
  1203.    public TreeView(TreeViewNode var1) {
  1204.       this((ImageSet)null, var1);
  1205.    }
  1206.  
  1207.    public TreeView(ImageSet var1, TreeViewNode var2) {
  1208.       this.m_nLabelOffset = 6;
  1209.       this.m_bLayoutComplete = false;
  1210.       this.m_bUseButtons = true;
  1211.       this.m_bUseLines = false;
  1212.       this.m_bRootsConnected = true;
  1213.       this.m_applet = null;
  1214.       this.m_sbHorizontal = new Scrollbar(0);
  1215.       this.m_sbVertical = new Scrollbar(1);
  1216.       this.m_sbBsscHorizontal = new BsscScrollbar(0);
  1217.       this.m_sbBsscVertical = new BsscScrollbar(1);
  1218.       this.m_bIsClumsyNS4 = false;
  1219.       this.m_btnScrollerCorner = new Button();
  1220.       this.m_nInsetX = 5;
  1221.       this.m_nInsetY = 1;
  1222.       this.m_nConnectorWidth = 16;
  1223.       this.m_nIndent = 7 + this.m_nConnectorWidth;
  1224.       this.m_nIconWidth = 16;
  1225.       this.m_nIconHeight = 16;
  1226.       this.m_nCellHeight = this.m_nIconHeight + 1;
  1227.       this.m_nFontBaseOffset = this.m_nIconHeight;
  1228.       this.m_bNetscapeScrollers = false;
  1229.       this.m_bLayedOutByMouseOver = false;
  1230.       this.m_bCompletelyFilled = false;
  1231.       this.m_nHorizPosPixels = 0;
  1232.       this.m_nVerticalPosPixels = 0;
  1233.       this.m_nImageWidth = 0;
  1234.       this.m_nImageHeight = 0;
  1235.       this.c_lnDoubleClickWindow = 500L;
  1236.       this.m_bIsNS3Win32 = false;
  1237.       this.m_bIsNSWin16 = false;
  1238.       this.m_bIsUnix = false;
  1239.       this.m_lnLastClickTime = 0L;
  1240.       this.m_bIsMac = false;
  1241.       this.m_bNeedTreeSize = true;
  1242.       this.m_bMaxWidthIsValid = false;
  1243.       this.m_bMaxHeightIsValid = false;
  1244.       this.m_nMaxWidth = 0;
  1245.       this.m_nMaxHeight = 0;
  1246.       this.m_bUseDoubleBuffer = true;
  1247.       this.m_Cursor = null;
  1248.  
  1249.       try {
  1250.          if (System.getProperty("java.vendor").startsWith("Netscape")) {
  1251.             if (System.getProperty("java.version").startsWith("1.0") && System.getProperty("os.name").startsWith("Windows") && System.getProperty("os.version").startsWith("4")) {
  1252.                this.m_bIsNS3Win32 = true;
  1253.             } else if (System.getProperty("os.name").startsWith("16-bit Windows")) {
  1254.                this.c_lnDoubleClickWindow = 1500L;
  1255.                this.m_bIsNSWin16 = true;
  1256.             }
  1257.          }
  1258.  
  1259.          if (System.getProperty("java.vendor").startsWith("Netscape") && System.getProperty("java.version").startsWith("1.1.5") && System.getProperty("os.name").startsWith("Windows")) {
  1260.             this.m_bIsClumsyNS4 = true;
  1261.          }
  1262.       } finally {
  1263.          ;
  1264.       }
  1265.  
  1266.       this.m_tvnRoot = var2;
  1267.       this.m_isImages = var1;
  1268.       this.m_isConnectors = new TreeViewConnectorImageSet();
  1269.       this.m_imgDoubleBuffer = null;
  1270.       this.m_rectDisplayArea = new Rectangle();
  1271.       ((Container)this).setLayout((LayoutManager)null);
  1272.  
  1273.       try {
  1274.          String var3 = System.getProperty("os.name");
  1275.          if (!var3.startsWith("Windows")) {
  1276.             this.m_bIsMac = var3.startsWith("Mac");
  1277.             this.m_bIsUnix = !this.m_bIsMac;
  1278.          }
  1279.       } finally {
  1280.          ;
  1281.       }
  1282.  
  1283.       int var15 = BsscFontFixPatch.GetFontSize();
  1284.       ((Component)this).setFont(new Font(BsscFontFixPatch.GetFontName(), 0, var15));
  1285.       FontMetrics var4 = ((Component)this).getFontMetrics(((Component)this).getFont());
  1286.       int var5 = var4.getLeading() + var4.getAscent() + var4.getDescent();
  1287.       this.setCellHeight(var5);
  1288.       if (var5 < this.m_nCellHeight) {
  1289.          this.m_nFontBaseOffset = (this.m_nCellHeight + var5) / 2 - var4.getDescent();
  1290.       } else {
  1291.          this.m_nFontBaseOffset = this.m_nCellHeight - var4.getDescent();
  1292.       }
  1293.  
  1294.       this.setSelectionToTop();
  1295.       Scrollbar var6 = new Scrollbar();
  1296.       var6.setValues(0, 3, 0, 10);
  1297.       var6.setValue(10);
  1298.       if (!this.m_bIsClumsyNS4) {
  1299.          this.m_bNetscapeScrollers = var6.getValue() == 10;
  1300.       }
  1301.  
  1302.       if (this.m_bIsClumsyNS4) {
  1303.          this.m_sbBsscHorizontal.setLineIncrement(16);
  1304.          if (this.m_sbBsscHorizontal.getPageIncrement() < 128) {
  1305.             this.m_sbBsscHorizontal.setPageIncrement(128);
  1306.          }
  1307.  
  1308.          this.m_sbBsscHorizontal.setBackground(new Color(192, 192, 192));
  1309.          ((Container)this).add(this.m_sbBsscHorizontal);
  1310.          this.m_sbBsscVertical.setBackground(new Color(192, 192, 192));
  1311.          ((Container)this).add(this.m_sbBsscVertical);
  1312.       } else {
  1313.          this.m_sbHorizontal.setLineIncrement(16);
  1314.          if (this.m_sbHorizontal.getPageIncrement() < 128) {
  1315.             this.m_sbHorizontal.setPageIncrement(128);
  1316.          }
  1317.  
  1318.          this.m_sbHorizontal.setBackground(new Color(192, 192, 192));
  1319.          ((Container)this).add(this.m_sbHorizontal);
  1320.          this.m_sbVertical.setBackground(new Color(192, 192, 192));
  1321.          ((Container)this).add(this.m_sbVertical);
  1322.       }
  1323.  
  1324.       this.m_btnScrollerCorner.enable(false);
  1325.       ((Container)this).add(this.m_btnScrollerCorner);
  1326.    }
  1327.  
  1328.    public void EnsureDisplayed(TreeViewNode var1) {
  1329.       int var2 = this.m_rectDisplayArea.height / this.m_nCellHeight;
  1330.       if (!this.IsDisplayed(var1)) {
  1331.          int var3 = this.GetNodePosition(var1);
  1332.          if (this.m_bIsClumsyNS4) {
  1333.             if (var3 < this.m_sbBsscVertical.getValue()) {
  1334.                this.m_sbBsscVertical.setValue(var3);
  1335.             } else {
  1336.                this.m_sbBsscVertical.setValue(var3 - var2 + 1);
  1337.             }
  1338.  
  1339.             this.m_nVerticalPosPixels = this.m_sbBsscVertical.getValue() * this.m_nCellHeight;
  1340.          } else {
  1341.             if (var3 < this.m_sbVertical.getValue()) {
  1342.                this.m_sbVertical.setValue(var3);
  1343.             } else {
  1344.                this.m_sbVertical.setValue(var3 - var2 + 1);
  1345.             }
  1346.  
  1347.             this.m_nVerticalPosPixels = this.m_sbVertical.getValue() * this.m_nCellHeight;
  1348.          }
  1349.       }
  1350.    }
  1351.  
  1352.    public int GetOpenChildSiblingCount(TreeViewNode var1) {
  1353.       int var2 = 0;
  1354.       if (var1 == null) {
  1355.          return 0;
  1356.       } else {
  1357.          if (var1.getLabel() != null) {
  1358.             ++var2;
  1359.          }
  1360.  
  1361.          if (!var1.getCollapsedState()) {
  1362.             TreeViewNode var3 = (TreeViewNode)((SiblingChildTree)var1).getChild();
  1363.             if (var3 != null) {
  1364.                var2 += this.GetOpenChildSiblingCount(var3);
  1365.             }
  1366.          }
  1367.  
  1368.          TreeViewNode var4 = (TreeViewNode)((SiblingChildTree)var1).getSibling();
  1369.          if (var4 != null) {
  1370.             var2 += this.GetOpenChildSiblingCount(var4);
  1371.          }
  1372.  
  1373.          return var2;
  1374.       }
  1375.    }
  1376.  
  1377.    public void paint(Graphics var1) {
  1378.       try {
  1379.          if (!this.m_bLayoutComplete) {
  1380.             String var2 = ResourceLib.GetRes("LoadingContents");
  1381.             var1.drawChars(var2.toCharArray(), 0, var2.length(), 0, 10);
  1382.             this.mylayout();
  1383.          }
  1384.  
  1385.          if (this.m_bUseDoubleBuffer && this.m_imgDoubleBuffer == null) {
  1386.             return;
  1387.          }
  1388.  
  1389.          if (this.m_bIsNS3Win32) {
  1390.             var1.dispose();
  1391.          }
  1392.  
  1393.          Object var6 = null;
  1394.          Graphics var7;
  1395.          if (this.m_bUseDoubleBuffer) {
  1396.             var7 = this.m_imgDoubleBuffer.getGraphics();
  1397.          } else {
  1398.             var7 = ((Component)this).getGraphics();
  1399.          }
  1400.  
  1401.          var7.setFont(((Component)this).getFont());
  1402.          var7.setColor(((Component)this).getBackground());
  1403.          var7.fillRect(0, 0, ((Component)this).bounds().width, ((Component)this).bounds().height);
  1404.          var7.setColor(((Component)this).getForeground());
  1405.          var7.translate(-this.m_nHorizPosPixels, -this.m_nVerticalPosPixels);
  1406.  
  1407.          try {
  1408.             Rectangle var3 = new Rectangle(this.m_rectDisplayArea.x, this.m_rectDisplayArea.y, this.m_rectDisplayArea.width, this.m_rectDisplayArea.height);
  1409.             var3.y += this.m_nVerticalPosPixels;
  1410.             this.paintTree(var7, this.m_tvnRoot, this.m_nInsetX, this.m_nInsetY, var3);
  1411.          } catch (NullPointerException var4) {
  1412.             ((Throwable)var4).printStackTrace();
  1413.          }
  1414.  
  1415.          if (this.m_bUseDoubleBuffer) {
  1416.             var7.dispose();
  1417.             var7 = this.m_imgDoubleBuffer.getGraphics();
  1418.          } else {
  1419.             var7.translate(this.m_nHorizPosPixels, this.m_nVerticalPosPixels);
  1420.          }
  1421.  
  1422.          this.paintBorder(var7);
  1423.          if (this.m_bUseDoubleBuffer) {
  1424.             if (this.m_bIsNS3Win32) {
  1425.                var7.dispose();
  1426.                var1 = ((Component)this).getGraphics();
  1427.             }
  1428.  
  1429.             var1.drawImage(this.m_imgDoubleBuffer, 0, 0, this);
  1430.             return;
  1431.          }
  1432.       } catch (Exception var5) {
  1433.          ((Throwable)var5).printStackTrace();
  1434.       }
  1435.  
  1436.    }
  1437.  
  1438.    protected void paintNode(Graphics var1, TreeViewNode var2, int var3, int var4) {
  1439.       var2.moveBounds(var3, var4);
  1440.       var3 = this.drawConnector(var1, var2, var3, var4);
  1441.       if (var2.getCurrentImage() != null) {
  1442.          var1.drawImage(var2.getCurrentImage(), var3, var4 + 1, this.m_nIconWidth, this.m_nIconHeight, this);
  1443.          var3 += this.m_nIconWidth + this.m_nLabelOffset;
  1444.       }
  1445.  
  1446.       if (var2.getLabel() != null) {
  1447.          this.drawText(var1, var2, var3, var4);
  1448.       }
  1449.  
  1450.    }
  1451.  
  1452.    public void MoveSelectionEnd() {
  1453.       this.m_tvnCurrentSelection.select(false);
  1454.  
  1455.       while(this.m_tvnCurrentSelection.nextNode(true) != null) {
  1456.          this.m_tvnCurrentSelection = this.m_tvnCurrentSelection.nextNode(true);
  1457.       }
  1458.  
  1459.       this.m_tvnCurrentSelection.select(true);
  1460.       if (this.m_bIsClumsyNS4) {
  1461.          this.m_sbBsscVertical.setValue(this.m_sbBsscVertical.getMaximum());
  1462.          this.m_nVerticalPosPixels = this.m_sbBsscVertical.getValue() * this.m_nCellHeight;
  1463.       } else {
  1464.          this.m_sbVertical.setValue(this.m_sbVertical.getMaximum());
  1465.          this.m_nVerticalPosPixels = this.m_sbVertical.getValue() * this.m_nCellHeight;
  1466.       }
  1467.  
  1468.       this.InternalSelectionHasChanged();
  1469.       ((Component)this).repaint();
  1470.    }
  1471.  
  1472.    public void MoveSelectionPgUp() {
  1473.       int var1 = this.m_rectDisplayArea.height / this.m_nCellHeight - 1;
  1474.  
  1475.       for(int var2 = 0; var2 < var1; ++var2) {
  1476.          this.MoveSelectionUp(false);
  1477.       }
  1478.  
  1479.       this.InternalSelectionHasChanged();
  1480.       ((Component)this).repaint();
  1481.    }
  1482.  
  1483.    TreeViewNode GetFirstDisplayedNode() {
  1484.       TreeViewNode var1 = this.m_tvnRoot;
  1485.       int var2 = 0;
  1486.       if (this.m_bIsClumsyNS4) {
  1487.          var2 = this.m_sbBsscVertical.getValue();
  1488.       } else {
  1489.          var2 = this.m_sbVertical.getValue();
  1490.       }
  1491.  
  1492.       for(; var1 != null && var2 > 0; var1 = var1.nextNode(true)) {
  1493.          if (var1.getLabel() != null) {
  1494.             --var2;
  1495.          }
  1496.       }
  1497.  
  1498.       return var1;
  1499.    }
  1500.  
  1501.    public void SetWaitCursor() {
  1502.       if (!System.getProperty("java.version").startsWith("1.0") && (System.getProperty("java.vendor").indexOf("Netscape") == -1 || !System.getProperty("java.version").startsWith("1.1.2"))) {
  1503.          try {
  1504.             this.m_Cursor = ((Component)this).getCursor();
  1505.             ((Component)this).setCursor(new Cursor(3));
  1506.          } catch (Exception var1) {
  1507.          }
  1508.       }
  1509.    }
  1510.  
  1511.    public boolean getUseButtons() {
  1512.       return this.m_bUseButtons;
  1513.    }
  1514.  
  1515.    public void setUseButtons(boolean var1) {
  1516.       this.m_bUseButtons = var1;
  1517.    }
  1518.  
  1519.    public ImageSet getImages() {
  1520.       return this.m_isImages;
  1521.    }
  1522.  
  1523.    public void setImages(ImageSet var1) {
  1524.       this.m_isImages = var1;
  1525.    }
  1526.  
  1527.    protected void drawText(Graphics var1, TreeViewNode var2, int var3, int var4) {
  1528.       var4 += this.m_nFontBaseOffset;
  1529.       if (var2.isSelected()) {
  1530.          var1.setColor(new Color(0, 0, 128));
  1531.          Rectangle var5 = var2.getBounds();
  1532.          int var6 = var5.width + var5.x - var3;
  1533.          var1.fillRect(var3, var5.y, var6, var5.height);
  1534.          var1.setColor(Color.white);
  1535.       } else {
  1536.          var1.setColor(((Component)this).getForeground());
  1537.       }
  1538.  
  1539.       var1.setFont(((Component)this).getFont());
  1540.       var1.drawString(var2.getLabel(), var3, var4);
  1541.    }
  1542. }
  1543.