home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &n…he Search for Life DVD 2 / DVD-ROM.iso / install / jre1_3 / lib / rt.jar / javax / swing / text / DefaultCaret$UpdateHandler.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  2.9 KB  |  136 lines

  1. package javax.swing.text;
  2.  
  3. import java.awt.event.ActionEvent;
  4. import java.awt.event.ActionListener;
  5. import java.beans.PropertyChangeEvent;
  6. import java.beans.PropertyChangeListener;
  7. import javax.swing.SwingUtilities;
  8. import javax.swing.event.DocumentEvent;
  9. import javax.swing.event.DocumentListener;
  10. import javax.swing.text.Position.Bias;
  11.  
  12. class DefaultCaret$UpdateHandler implements PropertyChangeListener, DocumentListener, ActionListener {
  13.    // $FF: synthetic field
  14.    private final DefaultCaret this$0;
  15.  
  16.    DefaultCaret$UpdateHandler(DefaultCaret var1) {
  17.       this.this$0 = var1;
  18.    }
  19.  
  20.    public void actionPerformed(ActionEvent var1) {
  21.       if (this.this$0.visible || this.this$0.width != 0 && this.this$0.height != 0) {
  22.          this.this$0.visible = !this.this$0.visible;
  23.          this.this$0.repaint();
  24.       } else {
  25.          this.this$0.setVisible(true);
  26.       }
  27.  
  28.    }
  29.  
  30.    public void insertUpdate(DocumentEvent var1) {
  31.       if (this.this$0.async || SwingUtilities.isEventDispatchThread()) {
  32.          int var2 = 0;
  33.          int var3 = var1.getOffset();
  34.          int var4 = var1.getLength();
  35.          if (this.this$0.dot >= var3) {
  36.             var2 = var4;
  37.          }
  38.  
  39.          if (this.this$0.mark >= var3) {
  40.             DefaultCaret var10000 = this.this$0;
  41.             var10000.mark += var4;
  42.          }
  43.  
  44.          if (var2 != 0) {
  45.             if (this.this$0.dot == var3) {
  46.                Document var5 = this.this$0.component.getDocument();
  47.                int var6 = this.this$0.dot + var2;
  48.  
  49.                boolean var7;
  50.                try {
  51.                   Segment var8 = new Segment();
  52.                   var5.getText(var6 - 1, 1, var8);
  53.                   var7 = var8.count > 0 && var8.array[var8.offset] == '\n';
  54.                } catch (BadLocationException var9) {
  55.                   var7 = false;
  56.                }
  57.  
  58.                if (var7) {
  59.                   this.this$0.changeCaretPosition(var6, Bias.Forward);
  60.                } else {
  61.                   this.this$0.changeCaretPosition(var6, Bias.Backward);
  62.                }
  63.             } else {
  64.                this.this$0.changeCaretPosition(this.this$0.dot + var2, this.this$0.dotBias);
  65.             }
  66.          }
  67.       }
  68.  
  69.    }
  70.  
  71.    public void removeUpdate(DocumentEvent var1) {
  72.       if (this.this$0.async || SwingUtilities.isEventDispatchThread()) {
  73.          int var2 = 0;
  74.          int var3 = var1.getOffset();
  75.          int var4 = var3 + var1.getLength();
  76.          boolean var5 = false;
  77.          if (this.this$0.dot >= var4) {
  78.             var2 = var4 - var3;
  79.             if (this.this$0.dot == var4) {
  80.                var5 = true;
  81.             }
  82.          } else if (this.this$0.dot >= var3) {
  83.             var2 = this.this$0.dot - var3;
  84.             var5 = true;
  85.          }
  86.  
  87.          boolean var6 = false;
  88.          if (this.this$0.mark >= var4) {
  89.             DefaultCaret var10000 = this.this$0;
  90.             var10000.mark -= var4 - var3;
  91.             if (this.this$0.mark == var4) {
  92.                var6 = true;
  93.             }
  94.          } else if (this.this$0.mark >= var3) {
  95.             this.this$0.mark = var3;
  96.             var6 = true;
  97.          }
  98.  
  99.          if (this.this$0.mark == this.this$0.dot - var2) {
  100.             this.this$0.setDot(this.this$0.dot - var2, this.this$0.guessBiasForOffset(this.this$0.dot - var2, this.this$0.dotBias, this.this$0.dotLTR));
  101.          } else {
  102.             if (var5) {
  103.                this.this$0.dotBias = this.this$0.guessBiasForOffset(this.this$0.dot - var2, this.this$0.dotBias, this.this$0.dotLTR);
  104.             }
  105.  
  106.             if (var6) {
  107.                this.this$0.markBias = this.this$0.guessBiasForOffset(this.this$0.mark, this.this$0.markBias, this.this$0.markLTR);
  108.             }
  109.  
  110.             this.this$0.changeCaretPosition(this.this$0.dot - var2, this.this$0.dotBias);
  111.             this.this$0.markLTR = this.this$0.isPositionLTR(this.this$0.mark, this.this$0.markBias);
  112.          }
  113.       }
  114.  
  115.    }
  116.  
  117.    public void changedUpdate(DocumentEvent var1) {
  118.    }
  119.  
  120.    public void propertyChange(PropertyChangeEvent var1) {
  121.       Object var2 = var1.getOldValue();
  122.       Object var3 = var1.getNewValue();
  123.       if (var2 instanceof Document || var3 instanceof Document) {
  124.          this.this$0.setDot(0);
  125.          if (var2 != null) {
  126.             ((Document)var2).removeDocumentListener(this);
  127.          }
  128.  
  129.          if (var3 != null) {
  130.             ((Document)var3).addDocumentListener(this);
  131.          }
  132.       }
  133.  
  134.    }
  135. }
  136.