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

  1. package javax.swing.plaf.basic;
  2.  
  3. import java.awt.event.ActionEvent;
  4. import javax.swing.AbstractAction;
  5. import javax.swing.ListSelectionModel;
  6.  
  7. class BasicTableUI$NavigationalAction extends AbstractAction {
  8.    // $FF: synthetic field
  9.    private final BasicTableUI this$0;
  10.    // $FF: renamed from: dx int
  11.    private int field_0;
  12.    // $FF: renamed from: dy int
  13.    private int field_1;
  14.    private boolean toggle;
  15.    private boolean extend;
  16.    private boolean moveAnchor;
  17.    private boolean inSelection;
  18.    private int anchorRow;
  19.    private int anchorColumn;
  20.    private int leadRow;
  21.    private int leadColumn;
  22.  
  23.    private BasicTableUI$NavigationalAction(BasicTableUI var1, int var2, int var3, boolean var4, boolean var5, boolean var6, boolean var7) {
  24.       this.this$0 = var1;
  25.       this.field_0 = var2;
  26.       this.field_1 = var3;
  27.       this.toggle = var4;
  28.       this.extend = var5;
  29.       this.moveAnchor = var6;
  30.       this.inSelection = var7;
  31.    }
  32.  
  33.    // $FF: synthetic method
  34.    BasicTableUI$NavigationalAction(BasicTableUI var1, BasicTableUI.3 var2, int var3, int var4, boolean var5, boolean var6, boolean var7, boolean var8) {
  35.       this(var1, var3, var4, var5, var6, var7, var8);
  36.    }
  37.  
  38.    public void actionPerformed(ActionEvent var1) {
  39.       ListSelectionModel var2 = this.this$0.table.getSelectionModel();
  40.       this.anchorRow = var2.getAnchorSelectionIndex();
  41.       this.leadRow = var2.getLeadSelectionIndex();
  42.       ListSelectionModel var3 = this.this$0.table.getColumnModel().getSelectionModel();
  43.       this.anchorColumn = var3.getAnchorSelectionIndex();
  44.       this.leadColumn = var3.getLeadSelectionIndex();
  45.       int var4 = this.anchorRow;
  46.       int var5 = this.anchorColumn;
  47.       boolean var6 = this.selectionSpan(var2) * this.selectionSpan(var3) == 1;
  48.       if (this.inSelection && !var6) {
  49.          this.anchorRow += this.field_1;
  50.          this.anchorColumn += this.field_0;
  51.          this.limitToSelectedRange(false);
  52.          var2.setAnchorSelectionIndex(this.anchorRow);
  53.          var3.setAnchorSelectionIndex(this.anchorColumn);
  54.       } else if (this.moveAnchor) {
  55.          this.anchorRow += this.field_1;
  56.          this.anchorColumn += this.field_0;
  57.          if (this.inTableRange(this.anchorRow, this.anchorColumn)) {
  58.             BasicTableUI.access$0(this.this$0, this.anchorRow, this.anchorColumn, false, this.extend);
  59.          }
  60.       } else {
  61.          this.leadRow += this.field_1;
  62.          this.leadColumn += this.field_0;
  63.          if (this.inTableRange(this.leadRow, this.leadColumn)) {
  64.             BasicTableUI.access$0(this.this$0, this.leadRow, this.leadColumn, false, this.extend);
  65.          }
  66.       }
  67.  
  68.       if (this.this$0.table.isEditing() && (var4 != var2.getAnchorSelectionIndex() || var5 != var3.getAnchorSelectionIndex())) {
  69.          this.this$0.table.getCellEditor().stopCellEditing();
  70.       }
  71.  
  72.    }
  73.  
  74.    private boolean inRange(int var1, int var2, int var3) {
  75.       return var1 >= var2 && var1 < var3;
  76.    }
  77.  
  78.    private boolean inTableRange(int var1, int var2) {
  79.       return this.inRange(var1, 0, this.this$0.table.getRowCount()) && this.inRange(var2, 0, this.this$0.table.getColumnCount());
  80.    }
  81.  
  82.    private int indexSign(int var1, ListSelectionModel var2) {
  83.       if (var1 < var2.getMinSelectionIndex()) {
  84.          return -1;
  85.       } else {
  86.          return var1 > var2.getMaxSelectionIndex() ? 1 : 0;
  87.       }
  88.    }
  89.  
  90.    private void limitToSelectedRange(boolean var1) {
  91.       ListSelectionModel var2 = this.this$0.table.getSelectionModel();
  92.       ListSelectionModel var3 = this.this$0.table.getColumnModel().getSelectionModel();
  93.       int var4 = this.indexSign(this.anchorRow, var2);
  94.       int var5 = this.indexSign(this.anchorColumn, var3);
  95.       this.anchorRow -= this.selectionSpan(var2) * var4;
  96.       this.anchorColumn -= this.selectionSpan(var3) * var5;
  97.       if (!var1) {
  98.          this.anchorRow += var5;
  99.          this.anchorColumn += var4;
  100.          this.limitToSelectedRange(true);
  101.       }
  102.  
  103.    }
  104.  
  105.    private int selectionSpan(ListSelectionModel var1) {
  106.       return var1.getMaxSelectionIndex() - var1.getMinSelectionIndex() + 1;
  107.    }
  108. }
  109.