home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 March / pcp161a.iso / handson / files / copyjava.exe / com / sun / java / swing / plaf / basic / BasicTreeUI$TreeTraverseAction.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-02-26  |  2.6 KB  |  62 lines

  1. package com.sun.java.swing.plaf.basic;
  2.  
  3. import com.sun.java.swing.AbstractAction;
  4. import java.awt.event.ActionEvent;
  5. import java.io.Serializable;
  6.  
  7. class BasicTreeUI$TreeTraverseAction extends AbstractAction implements Serializable {
  8.    // $FF: synthetic field
  9.    private final BasicTreeUI this$0;
  10.    private int direction;
  11.  
  12.    public BasicTreeUI$TreeTraverseAction(BasicTreeUI var1, int var2, String var3) {
  13.       super(var3);
  14.       this.this$0 = var1;
  15.       this.this$0 = var1;
  16.       this.direction = var2;
  17.    }
  18.  
  19.    public void actionPerformed(ActionEvent var1) {
  20.       int var2;
  21.       if (this.this$0.tree != null && (var2 = this.this$0.getRowCount()) > 0) {
  22.          int var3 = this.this$0.tree.getMinSelectionRow();
  23.          int var4;
  24.          if (var3 == -1) {
  25.             var4 = 0;
  26.          } else if (this.direction == 1) {
  27.             if (!this.this$0.isLeaf(var3) && !this.this$0.isExpanded(var3)) {
  28.                this.this$0.expandRow(var3);
  29.                var4 = -1;
  30.             } else {
  31.                var4 = Math.min(var3 + 1, var2 - 1);
  32.             }
  33.          } else if (!this.this$0.isLeaf(var3) && this.this$0.isExpanded(var3)) {
  34.             this.this$0.collapseRow(var3);
  35.             var4 = -1;
  36.          } else {
  37.             try {
  38.                if (!this.this$0.largeModel) {
  39.                   var4 = ((VisibleTreeNode)this.this$0.getNode(var3).getParent()).getRow();
  40.                } else {
  41.                   int[] var5 = new int[1];
  42.                   LargeTreeModelNode var6 = this.this$0.getLargeParentAndChildIndexOfRow(var3, var5);
  43.                   var4 = var6.getRow();
  44.                }
  45.             } catch (Exception var7) {
  46.                var4 = -1;
  47.             }
  48.          }
  49.  
  50.          if (var4 != -1) {
  51.             this.this$0.tree.setSelectionInterval(var4, var4);
  52.             this.this$0.ensureRowsAreVisible(var4, var4);
  53.          }
  54.       }
  55.  
  56.    }
  57.  
  58.    public boolean isEnabled() {
  59.       return this.this$0.tree != null && this.this$0.tree.isEnabled();
  60.    }
  61. }
  62.