From aef81a9acb17a9eadc5df75007b4364fbfa3a9de Mon Sep 17 00:00:00 2001 From: Sascha Brawer Date: Wed, 26 Nov 2003 23:23:40 +0100 Subject: StateEdit.java (getPresentationName): Docfix. 2003-11-26 Sascha Brawer * javax/swing/undo/StateEdit.java (getPresentationName): Docfix. * javax/swing/undo/AbstractUndoableEdit.java (canUndo, canRedo, isSignificant): Likewise. 2003-11-26 Sascha Brawer * javax/swing/undo/CompoundEdit.java: Re-format, document. (inProgress): Set initial value to true. (undo, redo, die, canUndo, canRedo): Also call inherited implementation; simplify code structure. (getPresentationName, getUndoPresentationName, getRedoPresentationName): Make behavior dependent on lastEdit. (addEdit, isSignificant): Completely re-written. 2003-11-26 Sascha Brawer * javax/swing/undo/StateEdit.java: Re-format, document. (undo, redo): Also call inherited implementation. 2003-11-26 Sascha Brawer * javax/swing/undo/StateEditable.java: Re-format, document. 2003-11-26 Sascha Brawer * javax/swing/undo/AbstractUndoableEdit.java: Re-format, document. (AbstractUndoableEdit): Initialize hasBeenDone to true. (canUndo, canRedo): Simplify. (getUndoPresentationName, getRedoPresentationName): Support localized message; call getPresentationName() only once. From-SVN: r73967 --- libjava/javax/swing/undo/StateEditable.java | 73 ++++++++++++++++++++++++----- 1 file changed, 60 insertions(+), 13 deletions(-) (limited to 'libjava/javax/swing/undo/StateEditable.java') diff --git a/libjava/javax/swing/undo/StateEditable.java b/libjava/javax/swing/undo/StateEditable.java index 016a543..d3f9d4c 100644 --- a/libjava/javax/swing/undo/StateEditable.java +++ b/libjava/javax/swing/undo/StateEditable.java @@ -1,4 +1,4 @@ -/* StateEditable.java -- +/* StateEditable.java -- Interface for collaborating with StateEdit. Copyright (C) 2002, 2003 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -37,29 +37,76 @@ exception statement from your version. */ package javax.swing.undo; -// Imports import java.util.Hashtable; + /** - * StateEditable public interface - * @author Andrew Selkirk + * The interface for objects whose state can be undone or redone by a + * {@link StateEdit} action. + * + *

The following example shows how to write a class that implements + * this interface. + * + *

 class Foo
+ *   implements StateEditable
+ * {
+ *   private String name;
+ *
+ *   public void setName(String n) { name = n; }
+ *
+ *   public void restoreState(Hashtable h)
+ *   {
+ *     if (h.containsKey("name"))
+ *       setName((String) h.get("name"));
+ *   }
+ *
+ *   public void storeState(Hashtable s)
+ *   {
+ *     s.put("name", name);
+ *   }
+ * }
+ * + * @see StateEdit + * + * @author Andrew Selkirk (aselkirk@sympatico.ca) + * @author Sascha Brawer (brawer@dandelis.ch) */ public interface StateEditable { /** - * Restore State - * @param state State + * The ID of the Java source file in Sun’s Revision Control + * System (RCS). This certainly should not be part of the API + * specification. But in order to be API-compatible with + * Sun’s reference implementation, GNU Classpath also has to + * provide this field. However, we do not try to match its value. */ - void restoreState(Hashtable state); + static final String RCSID = ""; + /** - * Store State - * @param state State + * Performs an edit action, taking any editable state information + * from the specified hash table. + * + *

Note to implementors of this interface: To increase + * efficiency, the StateEdit class {@linkplan + * StateEdit#removeRedundantState() removes redundant state + * information}. Therefore, implementations of this interface must be + * prepared for the case where certain keys were stored into the + * table by {@link #storeState}, but are not present anymore + * when the restoreState method gets called. + * + * @param state a hash table containing the relevant state + * information. */ - void storeState(Hashtable state); + void restoreState(Hashtable state); + /** - * For some reason, Sun made the RCS IDs visible. + * Stores any editable state information into the specified hash + * table. + * + * @param state a hash table for storing relevant state + * information. */ - String RCSID = "We aren't compatible"; -} // StateEditable + void storeState(Hashtable state); +} -- cgit v1.1