svn commit: r13480 - trunk/src/model/src/org/argouml/model

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: bobtarling
Date: 2007-09-02 15:12:38-0700
New Revision: 13480

Added:
   trunk/src/model/src/org/argouml/model/DummyModelCommand.java   (contents, props changed)
   trunk/src/model/src/org/argouml/model/ModelCommand.java
      - copied, changed from r13479, /trunk/src/model/src/org/argouml/model/ModelMemento.java
   trunk/src/model/src/org/argouml/model/ModelCommandCreationObserver.java
      - copied, changed from r13479, /trunk/src/model/src/org/argouml/model/MementoCreationObserver.java
Modified:
   trunk/src/model/src/org/argouml/model/MementoCreationObserver.java
   trunk/src/model/src/org/argouml/model/Model.java

Log:
Initial move of undo from GEF to ArgoUML - with wrapping of GEF mementos in ArgoUML Commands

Added: trunk/src/model/src/org/argouml/model/DummyModelCommand.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/model/src/org/argouml/model/DummyModelCommand.java?view=auto&rev=13480
==============================================================================
--- (empty file)
+++ trunk/src/model/src/org/argouml/model/DummyModelCommand.java	2007-09-02 15:12:38-0700
@@ -0,0 +1,47 @@
+// $Id$
+// Copyright (c) 2005-2006 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.model;
+
+/**
+ * Dummy commands are created where we haven't yet designed the correct
+ * memento for undoing an operation. It acts as a marker of work to be done
+ * to complete the Undo implementation.
+ * It also allows the save action to enable at the correct time. If there
+ * is no memento generated and fired back to the main application then
+ * the save action will not enable.
+ * @author Bob Tarling
+ */
+public class DummyModelCommand extends ModelCommand {
+
+    @Override
+    public void undo() {
+        // Do nothing.
+    }
+
+    @Override
+    public void execute() {
+        // Do nothing.
+    }
+}

Modified: trunk/src/model/src/org/argouml/model/MementoCreationObserver.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/model/src/org/argouml/model/MementoCreationObserver.java?view=diff&rev=13480&p1=trunk/src/model/src/org/argouml/model/MementoCreationObserver.java&p2=trunk/src/model/src/org/argouml/model/MementoCreationObserver.java&r1=13479&r2=13480
==============================================================================
--- trunk/src/model/src/org/argouml/model/MementoCreationObserver.java	(original)
+++ trunk/src/model/src/org/argouml/model/MementoCreationObserver.java	2007-09-02 15:12:38-0700
@@ -27,8 +27,9 @@
 /**
  * An interface to be implemented by the class responsible for managing
  * or delegating mementos.
- *
+ * 
  * @author Bob Tarling
+ * @deprecated in 0.25.4 by Bob Tarling use ModelCommandCreationObserver
  */
 public interface MementoCreationObserver {
     /**

Modified: trunk/src/model/src/org/argouml/model/Model.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/model/src/org/argouml/model/Model.java?view=diff&rev=13480&p1=trunk/src/model/src/org/argouml/model/Model.java&p2=trunk/src/model/src/org/argouml/model/Model.java&r1=13479&r2=13480
==============================================================================
--- trunk/src/model/src/org/argouml/model/Model.java	(original)
+++ trunk/src/model/src/org/argouml/model/Model.java	2007-09-02 15:12:38-0700
@@ -95,6 +95,11 @@
     private static MementoCreationObserver mementoCreationObserver;
 
     /**
+     * The register for the observer.
+     */
+    private static ModelCommandCreationObserver modelCommandCreationObserver;
+
+    /**
      * Constructor to prohibit creation.
      */
     private Model() {
@@ -519,6 +524,7 @@
      * @see {@link ModelMemento}
      *
      * @param observer the interested party
+     * @deprecated use setModelCommandCreationObserver
      */
     public static void setMementoCreationObserver(
             MementoCreationObserver observer) {
@@ -526,17 +532,39 @@
     }
 
     /**
+     * Allows an external system to register itself to recieve commands
+     * created by the model implementation.
+     * @see {@link ModelMemento}
+     *
+     * @param observer the interested party
+     */
+    public static void setModelCommandCreationObserver(
+            ModelCommandCreationObserver observer) {
+        modelCommandCreationObserver = observer;
+    }
+
+    /**
      * Gets the external class responsible for handling mementos.
      * @return the MementoCreationObserver
+     * @deprectated use getModelCommandCreationObserver
      */
     public static MementoCreationObserver getMementoCreationObserver() {
         return mementoCreationObserver;
     }
 
     /**
-     * Notify any observer that a memento has been created.
+     * Gets the external class responsible for handling mementos.
+     * @return the MementoCreationObserver
+     */
+    public static ModelCommandCreationObserver getModelCommandCreationObserver() {
+        return modelCommandCreationObserver;
+    }
+
+    /**
+     * Notify any observer that a command has been created.
      *
      * @param memento The newly created memento.
+     * @deprecated use notifyModelCommandCreationObserver
      */
     public static void notifyMementoCreationObserver(
             ModelMemento memento) {
@@ -547,6 +575,19 @@
     }
 
     /**
+     * Notify any observer that a memento has been created.
+     *
+     * @param command The newly created command.
+     */
+    public static void notifyModelCommandCreationObserver(
+            ModelCommand command) {
+        ModelCommandCreationObserver mco = getModelCommandCreationObserver();
+        if (mco != null) {
+            mco.modelCommandCreated(command);
+        }
+    }
+
+    /**
      * Getter for CopyHelper.
      *
      * @return the helper

Copied: trunk/src/model/src/org/argouml/model/ModelCommand.java (from r13479, /trunk/src/model/src/org/argouml/model/ModelMemento.java)
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/model/src/org/argouml/model/ModelCommand.java?view=diff&rev=13480&p1=/trunk/src/model/src/org/argouml/model/ModelMemento.java&p2=trunk/src/model/src/org/argouml/model/ModelCommand.java&r1=13479&r2=13480
==============================================================================
--- /trunk/src/model/src/org/argouml/model/ModelMemento.java	(original)
+++ trunk/src/model/src/org/argouml/model/ModelCommand.java	2007-09-02 15:12:38-0700
@@ -25,14 +25,14 @@
 package org.argouml.model;
 
 /**
- * A memento to record the state of an object before an undoable change.<p>
- * The model implementation should create a ModelMemento for any
+ * A command to record the state of an object before an undoable change.<p>
+ * The model implementation should create a ModelCommand for any
  * undoable operation performed. Any mutator method should normally be
  * undoable except loading a model from file.
  * 
  * @author Bob Tarling
  */
-public abstract class ModelMemento {
+public abstract class ModelCommand {
 
     /**
      * The method to undo this memento.
@@ -40,9 +40,9 @@
     public abstract void undo();
 
     /**
-     * The method to redo this memento once undone.
+     * The method to execute this memento.
      */
-    public abstract void redo();
+    public abstract void execute();
     
     /**
      * Dispose of any resources used by this memento before it is

Copied: trunk/src/model/src/org/argouml/model/ModelCommandCreationObserver.java (from r13479, /trunk/src/model/src/org/argouml/model/MementoCreationObserver.java)
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/model/src/org/argouml/model/ModelCommandCreationObserver.java?view=diff&rev=13480&p1=/trunk/src/model/src/org/argouml/model/MementoCreationObserver.java&p2=trunk/src/model/src/org/argouml/model/ModelCommandCreationObserver.java&r1=13479&r2=13480
==============================================================================
--- /trunk/src/model/src/org/argouml/model/MementoCreationObserver.java	(original)
+++ trunk/src/model/src/org/argouml/model/ModelCommandCreationObserver.java	2007-09-02 15:12:38-0700
@@ -26,14 +26,14 @@
 
 /**
  * An interface to be implemented by the class responsible for managing
- * or delegating mementos.
+ * or delegating commands reform the model interface.
  *
  * @author Bob Tarling
  */
-public interface MementoCreationObserver {
+public interface ModelCommandCreationObserver {
     /**
      * Called whenever a memento is created by the model subsystem.
      * @param memento the memento.
      */
-    void mementoCreated(ModelMemento memento);
+    void modelCommandCreated(ModelCommand memento);
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.