home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 March / pcp161a.iso / handson / files / copyjava.exe / com / sun / java / swing / undo / AbstractUndoableEdit.class (.txt) next >
Encoding:
Java Class File  |  1998-02-26  |  1.9 KB  |  79 lines

  1. package com.sun.java.swing.undo;
  2.  
  3. public class AbstractUndoableEdit implements UndoableEdit {
  4.    protected static final String UndoName = "Undo";
  5.    protected static final String RedoName = "Redo";
  6.    boolean hasBeenDone = true;
  7.    boolean alive = true;
  8.  
  9.    public void die() {
  10.       this.alive = false;
  11.    }
  12.  
  13.    public void undo() throws CannotUndoException {
  14.       if (!this.canUndo()) {
  15.          throw new CannotUndoException();
  16.       } else {
  17.          this.hasBeenDone = false;
  18.       }
  19.    }
  20.  
  21.    public boolean canUndo() {
  22.       return this.alive && this.hasBeenDone;
  23.    }
  24.  
  25.    public void redo() throws CannotRedoException {
  26.       if (!this.canRedo()) {
  27.          throw new CannotRedoException();
  28.       } else {
  29.          this.hasBeenDone = true;
  30.       }
  31.    }
  32.  
  33.    public boolean canRedo() {
  34.       return this.alive && !this.hasBeenDone;
  35.    }
  36.  
  37.    public boolean addEdit(UndoableEdit var1) {
  38.       return false;
  39.    }
  40.  
  41.    public boolean replaceEdit(UndoableEdit var1) {
  42.       return false;
  43.    }
  44.  
  45.    public boolean isSignificant() {
  46.       return true;
  47.    }
  48.  
  49.    public String getPresentationName() {
  50.       return "";
  51.    }
  52.  
  53.    public String getUndoPresentationName() {
  54.       String var1 = this.getPresentationName();
  55.       if (var1 != "") {
  56.          var1 = "Undo " + var1;
  57.       } else {
  58.          var1 = "Undo";
  59.       }
  60.  
  61.       return var1;
  62.    }
  63.  
  64.    public String getRedoPresentationName() {
  65.       String var1 = this.getPresentationName();
  66.       if (var1 != "") {
  67.          var1 = "Redo " + var1;
  68.       } else {
  69.          var1 = "Redo";
  70.       }
  71.  
  72.       return var1;
  73.    }
  74.  
  75.    public String toString() {
  76.       return super.toString() + " hasBeenDone: " + this.hasBeenDone + " alive: " + this.alive;
  77.    }
  78. }
  79.