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 / undo / CompoundEdit.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  2.2 KB  |  113 lines

  1. package javax.swing.undo;
  2.  
  3. import java.util.Enumeration;
  4. import java.util.Vector;
  5.  
  6. public class CompoundEdit extends AbstractUndoableEdit {
  7.    boolean inProgress = true;
  8.    protected Vector edits = new Vector();
  9.  
  10.    public void undo() throws CannotUndoException {
  11.       super.undo();
  12.       int var1 = this.edits.size();
  13.  
  14.       while(var1-- > 0) {
  15.          UndoableEdit var2 = (UndoableEdit)this.edits.elementAt(var1);
  16.          var2.undo();
  17.       }
  18.  
  19.    }
  20.  
  21.    public void redo() throws CannotRedoException {
  22.       super.redo();
  23.       Enumeration var1 = this.edits.elements();
  24.  
  25.       while(var1.hasMoreElements()) {
  26.          ((UndoableEdit)var1.nextElement()).redo();
  27.       }
  28.  
  29.    }
  30.  
  31.    protected UndoableEdit lastEdit() {
  32.       int var1 = this.edits.size();
  33.       return var1 > 0 ? (UndoableEdit)this.edits.elementAt(var1 - 1) : null;
  34.    }
  35.  
  36.    public void die() {
  37.       int var1 = this.edits.size();
  38.  
  39.       for(int var2 = var1 - 1; var2 >= 0; --var2) {
  40.          UndoableEdit var3 = (UndoableEdit)this.edits.elementAt(var2);
  41.          var3.die();
  42.       }
  43.  
  44.       super.die();
  45.    }
  46.  
  47.    public boolean addEdit(UndoableEdit var1) {
  48.       if (!this.inProgress) {
  49.          return false;
  50.       } else {
  51.          UndoableEdit var2 = this.lastEdit();
  52.          if (var2 == null) {
  53.             this.edits.addElement(var1);
  54.          } else if (!var2.addEdit(var1)) {
  55.             if (var1.replaceEdit(var2)) {
  56.                this.edits.removeElementAt(this.edits.size() - 1);
  57.             }
  58.  
  59.             this.edits.addElement(var1);
  60.          }
  61.  
  62.          return true;
  63.       }
  64.    }
  65.  
  66.    public void end() {
  67.       this.inProgress = false;
  68.    }
  69.  
  70.    public boolean canUndo() {
  71.       return !this.isInProgress() && super.canUndo();
  72.    }
  73.  
  74.    public boolean canRedo() {
  75.       return !this.isInProgress() && super.canRedo();
  76.    }
  77.  
  78.    public boolean isInProgress() {
  79.       return this.inProgress;
  80.    }
  81.  
  82.    public boolean isSignificant() {
  83.       Enumeration var1 = this.edits.elements();
  84.  
  85.       while(var1.hasMoreElements()) {
  86.          if (((UndoableEdit)var1.nextElement()).isSignificant()) {
  87.             return true;
  88.          }
  89.       }
  90.  
  91.       return false;
  92.    }
  93.  
  94.    public String getPresentationName() {
  95.       UndoableEdit var1 = this.lastEdit();
  96.       return var1 != null ? var1.getPresentationName() : super.getPresentationName();
  97.    }
  98.  
  99.    public String getUndoPresentationName() {
  100.       UndoableEdit var1 = this.lastEdit();
  101.       return var1 != null ? var1.getUndoPresentationName() : super.getUndoPresentationName();
  102.    }
  103.  
  104.    public String getRedoPresentationName() {
  105.       UndoableEdit var1 = this.lastEdit();
  106.       return var1 != null ? var1.getRedoPresentationName() : super.getRedoPresentationName();
  107.    }
  108.  
  109.    public String toString() {
  110.       return super.toString() + " inProgress: " + this.inProgress + " edits: " + this.edits;
  111.    }
  112. }
  113.