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

  1. package com.sun.java.swing.text;
  2.  
  3. import com.sun.java.swing.event.DocumentEvent;
  4. import com.sun.java.swing.event.DocumentListener;
  5. import com.sun.java.swing.plaf.TextUI;
  6. import java.awt.Rectangle;
  7. import java.awt.event.ActionEvent;
  8. import java.awt.event.ActionListener;
  9. import java.beans.PropertyChangeEvent;
  10. import java.beans.PropertyChangeListener;
  11.  
  12. class DefaultCaret$UpdateHandler implements PropertyChangeListener, DocumentListener, ActionListener {
  13.    // $FF: synthetic field
  14.    private final DefaultCaret this$0;
  15.  
  16.    public void actionPerformed(ActionEvent var1) {
  17.       this.this$0.visible = !this.this$0.visible;
  18.  
  19.       try {
  20.          TextUI var3 = this.this$0.component.getUI();
  21.          Rectangle var2 = var3.modelToView(this.this$0.dot);
  22.          this.this$0.damage(var2);
  23.       } catch (BadLocationException var4) {
  24.       }
  25.    }
  26.  
  27.    public void insertUpdate(DocumentEvent var1) {
  28.       int var2 = 0;
  29.       int var3 = var1.getOffset();
  30.       int var4 = var1.getLength();
  31.       if (this.this$0.dot >= var3) {
  32.          var2 = var4;
  33.       }
  34.  
  35.       if (this.this$0.mark >= var3) {
  36.          DefaultCaret var10000 = this.this$0;
  37.          var10000.mark += var4;
  38.       }
  39.  
  40.       if (var2 != 0) {
  41.          this.this$0.changeCaretPosition(this.this$0.dot + var2);
  42.       }
  43.  
  44.    }
  45.  
  46.    public void removeUpdate(DocumentEvent var1) {
  47.       int var2 = 0;
  48.       int var3 = var1.getOffset();
  49.       int var4 = var3 + var1.getLength();
  50.       if (this.this$0.dot >= var4) {
  51.          var2 = var4 - var3;
  52.       } else if (this.this$0.dot >= var3) {
  53.          var2 = this.this$0.dot - var3;
  54.       }
  55.  
  56.       if (this.this$0.mark >= var4) {
  57.          DefaultCaret var10000 = this.this$0;
  58.          var10000.mark -= var4 - var3;
  59.       } else if (this.this$0.mark >= var3) {
  60.          this.this$0.mark = var3;
  61.       }
  62.  
  63.       if (this.this$0.mark == this.this$0.dot - var2) {
  64.          this.this$0.setDot(this.this$0.dot - var2);
  65.       } else {
  66.          this.this$0.changeCaretPosition(this.this$0.dot - var2);
  67.       }
  68.    }
  69.  
  70.    public void changedUpdate(DocumentEvent var1) {
  71.    }
  72.  
  73.    public void propertyChange(PropertyChangeEvent var1) {
  74.       Object var2 = var1.getOldValue();
  75.       Object var3 = var1.getNewValue();
  76.       if (var2 instanceof Document || var3 instanceof Document) {
  77.          this.this$0.setDot(0);
  78.          if (var2 != null) {
  79.             ((Document)var2).removeDocumentListener(this);
  80.          }
  81.  
  82.          if (var3 != null) {
  83.             ((Document)var3).addDocumentListener(this);
  84.          }
  85.       }
  86.  
  87.    }
  88.  
  89.    DefaultCaret$UpdateHandler(DefaultCaret var1) {
  90.       this.this$0 = var1;
  91.       this.this$0 = var1;
  92.    }
  93. }
  94.