// Copyright (c) 1995, 1996 Regents of the University of California. // All rights reserved. // // This software was developed by the Arcadia project // at the University of California, Irvine. // // Redistribution and use in source and binary forms are permitted // provided that the above copyright notice and this paragraph are // duplicated in all such forms and that any documentation, // advertising materials, and other materials related to such // distribution and use acknowledge that the software was developed // by the University of California, Irvine. The name of the // University may not be used to endorse or promote products derived // from this software without specific prior written permission. // THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR // IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED // WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. // File: Action.java // Classes: Action // Original Author: Jason Robbins // Modifications : Kedar Patankar // Date : 11 Feb 1997 package uci.graphedit; import java.util.Properties; /** * Abstract class for all editor actions. The editor serves as a * command shell for executing actions in much the same way that a * DOS or UNIX commmand command shell executes programs. Each action * can have a Hashtable of "command-line" arguments and also look at * global variables (its environment). Once an instance of an Action * is made, it can be sent the doIt() and undoIt() messages to perform * that action.

* needs-more-work: canDoIt, canUndoIt predicates control graying.

* needs-more-work: Editor will keep a history of recent actions for * undo.

* @see Editor * @see Document * @see UmlPalette */ public abstract class Action { /** Attributes */ protected Properties _args; protected Editor _editor; protected Document _document; /** Constructors*/ public Action(Properties args) { _args = args; } public Action(Editor editor) { this(new Properties()); _editor=editor; _document=null; } public Action(Document document) { this(new Properties()); _document=document; _editor=null; } public Action(Editor editor,Document document) { this(new Properties()); _document=document; _editor=editor; } /** Return a name for this action suitable for display to the user */ public abstract String name(); /** Perform whatever action this Action is meant to do. Subclasses * should override this to do whatever is intended. When the action * executes, it should store enough information to undo itself later * if needed. */ public abstract void doIt(); /** Undo the action using information stored during its * execution.

* needs-more-work: This is not currently implemented. */ public abstract void undoIt(); // needs-more-work: do I need a separate redo()? Should doIt() take // flag to indicate if this is the first time the action is being // done, or it it is actually being redone? What information does // undoIt() need to store to support redo? } /* end class Action */