home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 144 / DPCS0200.iso / Internet / Supanet / system / swing.jar / javax / swing / plaf / basic / BasicTreeUI$TreeTraverseAction.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-11-05  |  2.3 KB  |  72 lines

  1. package javax.swing.plaf.basic;
  2.  
  3. import java.awt.event.ActionEvent;
  4. import javax.swing.AbstractAction;
  5. import javax.swing.tree.TreePath;
  6.  
  7. public class BasicTreeUI$TreeTraverseAction extends AbstractAction {
  8.    // $FF: synthetic field
  9.    private final BasicTreeUI this$0;
  10.    protected int direction;
  11.    private boolean changeSelection;
  12.  
  13.    public BasicTreeUI$TreeTraverseAction(BasicTreeUI var1, int var2, String var3) {
  14.       this(var1, var2, var3, true);
  15.    }
  16.  
  17.    private BasicTreeUI$TreeTraverseAction(BasicTreeUI var1, int var2, String var3, boolean var4) {
  18.       super(var3);
  19.       this.this$0 = var1;
  20.       this.direction = var2;
  21.       this.changeSelection = var4;
  22.    }
  23.  
  24.    // $FF: synthetic method
  25.    BasicTreeUI$TreeTraverseAction(BasicTreeUI var1, BasicTreeUI.1 var2, int var3, String var4, boolean var5) {
  26.       this(var1, var3, var4, var5);
  27.    }
  28.  
  29.    public void actionPerformed(ActionEvent var1) {
  30.       int var2;
  31.       if (this.this$0.tree != null && (var2 = this.this$0.getRowCount(this.this$0.tree)) > 0) {
  32.          int var3 = BasicTreeUI.access$5(this.this$0);
  33.          int var4;
  34.          if (var3 == -1) {
  35.             var4 = 0;
  36.          } else if (this.direction == 1) {
  37.             if (!this.this$0.isLeaf(var3) && !this.this$0.tree.isExpanded(var3)) {
  38.                this.this$0.toggleExpandState(this.this$0.getPathForRow(this.this$0.tree, var3));
  39.                var4 = -1;
  40.             } else {
  41.                var4 = Math.min(var3 + 1, var2 - 1);
  42.             }
  43.          } else if (!this.this$0.isLeaf(var3) && this.this$0.tree.isExpanded(var3)) {
  44.             this.this$0.toggleExpandState(this.this$0.getPathForRow(this.this$0.tree, var3));
  45.             var4 = -1;
  46.          } else {
  47.             TreePath var5 = this.this$0.getPathForRow(this.this$0.tree, var3);
  48.             if (var5 != null && var5.getPathCount() > 1) {
  49.                var4 = this.this$0.getRowForPath(this.this$0.tree, var5.getParentPath());
  50.             } else {
  51.                var4 = -1;
  52.             }
  53.          }
  54.  
  55.          if (var4 != -1) {
  56.             if (this.changeSelection) {
  57.                this.this$0.tree.setSelectionInterval(var4, var4);
  58.             } else {
  59.                BasicTreeUI.access$6(this.this$0, this.this$0.getPathForRow(this.this$0.tree, var4), true);
  60.             }
  61.  
  62.             this.this$0.ensureRowsAreVisible(var4, var4);
  63.          }
  64.       }
  65.  
  66.    }
  67.  
  68.    public boolean isEnabled() {
  69.       return this.this$0.tree != null && this.this$0.tree.isEnabled();
  70.    }
  71. }
  72.