Save This Page
Home » openjdk-7 » net » sf » bibkeeper » undo » [javadoc | source]
    1   package net.sf.bibkeeper.undo;
    2   
    3   import javax.swing.undo;
    4   import net.sf.bibkeeper;
    5   
    6   /**
    7    * This class represents a change in any field value. The relevant
    8    * information is the BibtexEntry, the field name, the old and the
    9    * new value. Old/new values can be null.
   10    */
   11   public class UndoablePreambleChange extends AbstractUndoableEdit {
   12   
   13       private BibtexDatabase base;
   14       private String oldValue, newValue;
   15       private BibtexBaseFrame baseFrame;
   16   
   17       public UndoablePreambleChange(BibtexDatabase base, BibtexBaseFrame baseFrame,
   18   				  String oldValue, String newValue) {
   19   	this.base = base;
   20   	this.oldValue = oldValue;
   21   	this.newValue = newValue;
   22   	this.baseFrame = baseFrame;
   23       }
   24   
   25       public String getUndoPresentationName() {
   26   	return "Undo: change preamble";
   27       }
   28   
   29       public String getRedoPresentationName() {
   30   	return "Redo: change preamble";
   31       }
   32   
   33       public void undo() {
   34   	super.undo();
   35   	
   36   	// Revert the change.
   37   	base.setPreamble(oldValue);
   38   
   39   	// If the preamble editor is open, update it.
   40   	baseFrame.updatePreamble();
   41       }
   42   
   43       public void redo() {
   44   	super.redo();
   45   
   46   	// Redo the change.
   47   	base.setPreamble(newValue);
   48   
   49   	// If the preamble editor is open, update it.
   50   	baseFrame.updatePreamble();
   51   
   52       }
   53   
   54   
   55   
   56   }

Save This Page
Home » openjdk-7 » net » sf » bibkeeper » undo » [javadoc | source]