home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 144 / DPCS0200.iso / Internet / Supanet / system / swing.jar / javax / swing / text / DefaultCaret$UpdateHandler.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-11-05  |  3.2 KB  |  131 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.plaf.TextUI;
  11. import javax.swing.text.Position.Bias;
  12.  
  13. class DefaultCaret$UpdateHandler implements PropertyChangeListener, DocumentListener, ActionListener {
  14.    // $FF: synthetic field
  15.    private final DefaultCaret this$0;
  16.  
  17.    DefaultCaret$UpdateHandler(DefaultCaret var1) {
  18.       this.this$0 = var1;
  19.    }
  20.  
  21.    public void actionPerformed(ActionEvent var1) {
  22.       this.this$0.visible ^= true;
  23.       this.this$0.repaint();
  24.    }
  25.  
  26.    public void changedUpdate(DocumentEvent var1) {
  27.    }
  28.  
  29.    public void insertUpdate(DocumentEvent var1) {
  30.       if (this.this$0.async || SwingUtilities.isEventDispatchThread()) {
  31.          int var2 = 0;
  32.          int var3 = var1.getOffset();
  33.          int var4 = var1.getLength();
  34.          if (this.this$0.dot >= var3) {
  35.             var2 = var4;
  36.          }
  37.  
  38.          if (this.this$0.mark >= var3) {
  39.             DefaultCaret var10000 = this.this$0;
  40.             var10000.mark += var4;
  41.          }
  42.  
  43.          if (var2 != 0) {
  44.             if (this.this$0.dot == var3) {
  45.                TextUI var5 = this.this$0.component.getUI();
  46.                Document var6 = this.this$0.component.getDocument();
  47.                int var7 = this.this$0.dot + var2;
  48.  
  49.                boolean var8;
  50.                try {
  51.                   var8 = var6.getText(var7 - 1, 1).equals("\n");
  52.                } catch (BadLocationException var9) {
  53.                   var8 = false;
  54.                }
  55.  
  56.                if (var8) {
  57.                   this.this$0.changeCaretPosition(var7, Bias.Forward);
  58.                } else {
  59.                   this.this$0.changeCaretPosition(var7, Bias.Backward);
  60.                }
  61.             } else {
  62.                this.this$0.changeCaretPosition(this.this$0.dot + var2, this.this$0.dotBias);
  63.             }
  64.          }
  65.       }
  66.  
  67.    }
  68.  
  69.    public void propertyChange(PropertyChangeEvent var1) {
  70.       Object var2 = var1.getOldValue();
  71.       Object var3 = var1.getNewValue();
  72.       if (var2 instanceof Document || var3 instanceof Document) {
  73.          this.this$0.setDot(0);
  74.          if (var2 != null) {
  75.             ((Document)var2).removeDocumentListener(this);
  76.          }
  77.  
  78.          if (var3 != null) {
  79.             ((Document)var3).addDocumentListener(this);
  80.          }
  81.       }
  82.  
  83.    }
  84.  
  85.    public void removeUpdate(DocumentEvent var1) {
  86.       if (this.this$0.async || SwingUtilities.isEventDispatchThread()) {
  87.          int var2 = 0;
  88.          int var3 = var1.getOffset();
  89.          int var4 = var3 + var1.getLength();
  90.          boolean var5 = false;
  91.          if (this.this$0.dot >= var4) {
  92.             var2 = var4 - var3;
  93.             if (this.this$0.dot == var4) {
  94.                var5 = true;
  95.             }
  96.          } else if (this.this$0.dot >= var3) {
  97.             var2 = this.this$0.dot - var3;
  98.             var5 = true;
  99.          }
  100.  
  101.          boolean var6 = false;
  102.          if (this.this$0.mark >= var4) {
  103.             DefaultCaret var10000 = this.this$0;
  104.             var10000.mark -= var4 - var3;
  105.             if (this.this$0.mark == var4) {
  106.                var6 = true;
  107.             }
  108.          } else if (this.this$0.mark >= var3) {
  109.             this.this$0.mark = var3;
  110.             var6 = true;
  111.          }
  112.  
  113.          if (this.this$0.mark == this.this$0.dot - var2) {
  114.             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));
  115.          } else {
  116.             if (var5) {
  117.                this.this$0.dotBias = this.this$0.guessBiasForOffset(this.this$0.dot - var2, this.this$0.dotBias, this.this$0.dotLTR);
  118.             }
  119.  
  120.             if (var6) {
  121.                this.this$0.markBias = this.this$0.guessBiasForOffset(this.this$0.mark, this.this$0.markBias, this.this$0.markLTR);
  122.             }
  123.  
  124.             this.this$0.changeCaretPosition(this.this$0.dot - var2, this.this$0.dotBias);
  125.             this.this$0.markLTR = this.this$0.isPositionLTR(this.this$0.mark, this.this$0.markBias);
  126.          }
  127.       }
  128.  
  129.    }
  130. }
  131.