svn commit: r13513 - trunk/src_new/org/argouml/uml/ui/ActionSaveProject.java

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: bobtarling
Date: 2007-09-08 03:46:41-0700
New Revision: 13513

Modified:
   trunk/src_new/org/argouml/uml/ui/ActionSaveProject.java

Log:
Use Command rather than Memento

Modified: trunk/src_new/org/argouml/uml/ui/ActionSaveProject.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/ui/ActionSaveProject.java?view=diff&rev=13513&p1=trunk/src_new/org/argouml/uml/ui/ActionSaveProject.java&p2=trunk/src_new/org/argouml/uml/ui/ActionSaveProject.java&r1=13512&r2=13513
==============================================================================
--- trunk/src_new/org/argouml/uml/ui/ActionSaveProject.java	(original)
+++ trunk/src_new/org/argouml/uml/ui/ActionSaveProject.java	2007-09-08 03:46:41-0700
@@ -33,10 +33,11 @@
 import org.apache.log4j.Logger;
 import org.argouml.application.helpers.ResourceLoaderWrapper;
 import org.argouml.i18n.Translator;
+import org.argouml.kernel.AbstractCommand;
+import org.argouml.kernel.Command;
+import org.argouml.kernel.Project;
 import org.argouml.kernel.ProjectManager;
 import org.argouml.ui.ProjectBrowser;
-import org.tigris.gef.undo.Memento;
-import org.tigris.gef.undo.UndoManager;
 
 /**
  * Action that saves the project.
@@ -51,8 +52,6 @@
      */
     private static final Logger LOG = Logger.getLogger(ActionSaveProject.class);
 
-    private static int count;
-    
     /**
      * The constructor.
      */
@@ -96,19 +95,20 @@
         if (isEnabled == this.enabled) {
             return;
         }
-        if (isEnabled && ++count == 2) {
-//            throw new IllegalArgumentException();
-        }
-        Memento memento = new Memento() {
+        Command command = new AbstractCommand() {
+            public void execute() {
+                internalSetEnabled(isEnabled);
+            }
             public void undo() {
                 internalSetEnabled(!isEnabled);
             }
-            public void redo() {
-                internalSetEnabled(isEnabled);
+            public String toString() {
+                return "save enabled = " + isEnabled;
             }
         };
-    	UndoManager.getInstance().addMemento(memento);
-        internalSetEnabled(isEnabled);
+        command.execute();
+        Project p = ProjectManager.getManager().getCurrentProject();
+    	p.getUndoManager().addCommand(command);
     }
     
     /**
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.