svn commit: r13396 - branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: b00__1
Date: 2007-08-18 11:22:16-0700
New Revision: 13396

Modified:
   branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/CommandStackImpl.java
   branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/EUMLModelImplementation.java
   branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/ModelEventPumpEUMLImpl.java

Log:
Changed the undo/redo mechanism to use ModelMemento

Modified: branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/CommandStackImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/CommandStackImpl.java?view=diff&rev=13396&p1=branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/CommandStackImpl.java&p2=branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/CommandStackImpl.java&r1=13395&r2=13396
==============================================================================
--- branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/CommandStackImpl.java	(original)
+++ branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/CommandStackImpl.java	2007-08-18 11:22:16-0700
@@ -26,16 +26,27 @@
 
 package org.argouml.model.euml;
 
-import org.argouml.model.CommandStack;
+import org.argouml.model.ModelMemento;
 
-public class CommandStackImpl implements CommandStack {
+public class CommandStackImpl extends ModelMemento {
 
     private EUMLModelImplementation modelImplementation;
+    
+    private static CommandStackImpl instance;
+    
+    public static final String COMMAND_STACK_UPDATE_EVENT = "COMMAND_STACK_CHANGED"; //$NON-NLS-1$
 
-    public CommandStackImpl(EUMLModelImplementation modelImplementation) {
+    private CommandStackImpl(EUMLModelImplementation modelImplementation) {
         this.modelImplementation = modelImplementation;
         modelImplementation.getEditingDomain().getCommandStack().flush();
     }
+    
+    public static ModelMemento getInstance(EUMLModelImplementation modelImplementation) {
+        if (instance == null) {
+            instance = new CommandStackImpl(modelImplementation);
+        }
+        return instance;
+    }
 
     public boolean canRedo() {
         return modelImplementation.getEditingDomain().getCommandStack().canRedo();
@@ -55,10 +66,6 @@
                 : null;
     }
 
-    public boolean isCommandStackCapabilityAvailable() {
-        return true;
-    }
-
     public void redo() {
         modelImplementation.getEditingDomain().getCommandStack().redo();
     }

Modified: branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/EUMLModelImplementation.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/EUMLModelImplementation.java?view=diff&rev=13396&p1=branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/EUMLModelImplementation.java&p2=branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/EUMLModelImplementation.java&r1=13395&r2=13396
==============================================================================
--- branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/EUMLModelImplementation.java	(original)
+++ branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/EUMLModelImplementation.java	2007-08-18 11:22:16-0700
@@ -47,7 +47,6 @@
 import java.util.Map;
 
 import org.apache.log4j.Logger;
-import org.argouml.model.CommandStack;
 import org.argouml.model.DiagramInterchangeModel;
 import org.argouml.model.ModelImplementation;
 import org.argouml.model.UmlException;
@@ -510,11 +509,4 @@
         return null;
     }
 
-    public CommandStack getCommandStack() {
-        if (theCommandStack == null) {
-            theCommandStack = new CommandStackImpl(this);
-        }
-        return theCommandStack;
-    }
-
 }

Modified: branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/ModelEventPumpEUMLImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/ModelEventPumpEUMLImpl.java?view=diff&rev=13396&p1=branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/ModelEventPumpEUMLImpl.java&p2=branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/ModelEventPumpEUMLImpl.java&r1=13395&r2=13396
==============================================================================
--- branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/ModelEventPumpEUMLImpl.java	(original)
+++ branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/ModelEventPumpEUMLImpl.java	2007-08-18 11:22:16-0700
@@ -42,7 +42,6 @@
 import org.argouml.model.AbstractModelEventPump;
 import org.argouml.model.AddAssociationEvent;
 import org.argouml.model.AttributeChangeEvent;
-import org.argouml.model.CommandStack;
 import org.argouml.model.DeleteInstanceEvent;
 import org.argouml.model.RemoveAssociationEvent;
 import org.eclipse.emf.common.command.CommandStackListener;
@@ -169,7 +168,7 @@
     public void addModelEventListener(PropertyChangeListener listener,
             Object modelelement, String[] propertyNames) {
         if (!(modelelement instanceof EObject)
-                && !(modelelement instanceof String && modelelement.equals(CommandStack.COMMAND_STACK_UPDATE_EVENT))) {
+                && !(modelelement instanceof String && modelelement.equals(CommandStackImpl.COMMAND_STACK_UPDATE_EVENT))) {
             throw new IllegalArgumentException(
                     "The modelelement must be instance of EObject."); //$NON-NLS-1$
         }
@@ -231,7 +230,7 @@
     public void removeModelEventListener(PropertyChangeListener listener,
             Object modelelement, String[] propertyNames) {
         if (!(modelelement instanceof EObject)
-                && !(modelelement instanceof String && modelelement.equals(CommandStack.COMMAND_STACK_UPDATE_EVENT))) {
+                && !(modelelement instanceof String && modelelement.equals(CommandStackImpl.COMMAND_STACK_UPDATE_EVENT))) {
             throw new IllegalArgumentException();
         }
         unregisterListener(
@@ -381,9 +380,9 @@
         } else if (notification.getEventType() == COMMAND_STACK_UPDATE) {
             events.add(new EventAndListeners(
                     new PropertyChangeEvent(
-                            this, CommandStack.COMMAND_STACK_UPDATE_EVENT,
+                            this, CommandStackImpl.COMMAND_STACK_UPDATE_EVENT,
                             false, false),
-                    getListeners(CommandStack.COMMAND_STACK_UPDATE_EVENT)));
+                    getListeners(CommandStackImpl.COMMAND_STACK_UPDATE_EVENT)));
         }
 
         for (EventAndListeners e : events) {
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.