home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / swingall.jar / javax / swing / undo / CompoundEdit.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-07-15  |  2.7 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 boolean addEdit(UndoableEdit var1) {
  11.       if (!this.inProgress) {
  12.          return false;
  13.       } else {
  14.          UndoableEdit var2 = this.lastEdit();
  15.          if (var2 == null) {
  16.             this.edits.addElement(var1);
  17.          } else if (!var2.addEdit(var1)) {
  18.             if (var1.replaceEdit(var2)) {
  19.                this.edits.removeElementAt(this.edits.size() - 1);
  20.             }
  21.  
  22.             this.edits.addElement(var1);
  23.          }
  24.  
  25.          return true;
  26.       }
  27.    }
  28.  
  29.    public boolean canRedo() {
  30.       return !this.isInProgress() && super.canRedo();
  31.    }
  32.  
  33.    public boolean canUndo() {
  34.       return !this.isInProgress() && super.canUndo();
  35.    }
  36.  
  37.    public void die() {
  38.       int var1 = this.edits.size();
  39.  
  40.       for(int var2 = var1 - 1; var2 >= 0; --var2) {
  41.          UndoableEdit var3 = (UndoableEdit)this.edits.elementAt(var2);
  42.          var3.die();
  43.       }
  44.  
  45.       super.die();
  46.    }
  47.  
  48.    public void end() {
  49.       this.inProgress = false;
  50.    }
  51.  
  52.    public String getPresentationName() {
  53.       UndoableEdit var1 = this.lastEdit();
  54.       return var1 != null ? var1.getPresentationName() : super.getPresentationName();
  55.    }
  56.  
  57.    public String getRedoPresentationName() {
  58.       UndoableEdit var1 = this.lastEdit();
  59.       return var1 != null ? var1.getRedoPresentationName() : super.getRedoPresentationName();
  60.    }
  61.  
  62.    public String getUndoPresentationName() {
  63.       UndoableEdit var1 = this.lastEdit();
  64.       return var1 != null ? var1.getUndoPresentationName() : super.getUndoPresentationName();
  65.    }
  66.  
  67.    public boolean isInProgress() {
  68.       return this.inProgress;
  69.    }
  70.  
  71.    public boolean isSignificant() {
  72.       Enumeration var1 = this.edits.elements();
  73.  
  74.       while(var1.hasMoreElements()) {
  75.          if (((UndoableEdit)var1.nextElement()).isSignificant()) {
  76.             return true;
  77.          }
  78.       }
  79.  
  80.       return false;
  81.    }
  82.  
  83.    protected UndoableEdit lastEdit() {
  84.       int var1 = this.edits.size();
  85.       return var1 > 0 ? (UndoableEdit)this.edits.elementAt(var1 - 1) : null;
  86.    }
  87.  
  88.    public void redo() throws CannotRedoException {
  89.       super.redo();
  90.       Enumeration var1 = this.edits.elements();
  91.  
  92.       while(var1.hasMoreElements()) {
  93.          ((UndoableEdit)var1.nextElement()).redo();
  94.       }
  95.  
  96.    }
  97.  
  98.    public String toString() {
  99.       return super.toString() + " inProgress: " + this.inProgress + " edits: " + this.edits;
  100.    }
  101.  
  102.    public void undo() throws CannotUndoException {
  103.       super.undo();
  104.       int var1 = this.edits.size();
  105.  
  106.       while(var1-- > 0) {
  107.          UndoableEdit var2 = (UndoableEdit)this.edits.elementAt(var1);
  108.          var2.undo();
  109.       }
  110.  
  111.    }
  112. }
  113.