svn commit: r13126 - branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/CoreHelperEUMLImpl.java

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: b00__1
Date: 2007-07-23 21:23:23-0700
New Revision: 13126

Modified:
   branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/CoreHelperEUMLImpl.java

Log:
Set the owner of an element with the EditingDomain in an undoable way.

Modified: branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/CoreHelperEUMLImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/CoreHelperEUMLImpl.java?view=diff&rev=13126&p1=branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/CoreHelperEUMLImpl.java&p2=branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/CoreHelperEUMLImpl.java&r1=13125&r2=13126
==============================================================================
--- branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/CoreHelperEUMLImpl.java	(original)
+++ branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/CoreHelperEUMLImpl.java	2007-07-23 21:23:23-0700
@@ -33,6 +33,9 @@
 
 import org.argouml.model.CoreHelper;
 import org.argouml.model.NotImplementedException;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.uml2.common.edit.command.ChangeCommand;
+import org.eclipse.uml2.uml.AggregationKind;
 import org.eclipse.uml2.uml.Association;
 import org.eclipse.uml2.uml.BehavioralFeature;
 import org.eclipse.uml2.uml.Classifier;
@@ -146,15 +149,29 @@
         throw new NotYetImplementedException();
     }
 
-    public void addOwnedElement(Object handle, Object me) {
+    public void addOwnedElement(final Object handle, final Object me) {
+        EditingDomain editingDomain = modelImpl.getEditingDomain();
         if (handle instanceof org.eclipse.uml2.uml.Package
                 && me instanceof Type) {
-            ((org.eclipse.uml2.uml.Package) handle).getOwnedTypes().add(
-                    (Type) me);
+            RunnableClass run = new RunnableClass() {
+                public void run() {
+                    ((org.eclipse.uml2.uml.Package) handle).getOwnedTypes().add(
+                            (Type) me);
+                }
+            };
+            editingDomain.getCommandStack().execute(
+                    new ChangeCommand(editingDomain, run));
+
         } else if (handle instanceof org.eclipse.uml2.uml.Package
                 && me instanceof PackageableElement) {
-            ((org.eclipse.uml2.uml.Package) handle).getPackagedElements().add(
-                    (PackageableElement) me);
+            RunnableClass run = new RunnableClass() {
+                public void run() {
+                    ((org.eclipse.uml2.uml.Package) handle).getPackagedElements().add(
+                            (PackageableElement) me);
+                }
+            };
+            editingDomain.getCommandStack().execute(
+                    new ChangeCommand(editingDomain, run));
         } else {
             throw new NotYetImplementedException();
         }
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.