svn commit: r18228 - trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/ModelManagementFactoryEUMLImpl.java

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: tfmorris
Date: 2010-04-08 16:29:22-0700
New Revision: 18228

Modified:
   trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/ModelManagementFactoryEUMLImpl.java

Log:
ArgoEclipse merge.  Undo support.  Header update.

Modified: trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/ModelManagementFactoryEUMLImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/ModelManagementFactoryEUMLImpl.java?view=diff&pathrev=18228&r1=18227&r2=18228
==============================================================================
--- trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/ModelManagementFactoryEUMLImpl.java	(original)
+++ trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/ModelManagementFactoryEUMLImpl.java	2010-04-08 16:29:22-0700
@@ -1,12 +1,14 @@
-/* $Id$
- *****************************************************************************
- * Copyright (c) 2009 Contributors - see below
+// $Id$
+/*******************************************************************************
+ * Copyright (c) 2007,2010 Tom Morris and other contributors
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
  *
  * Contributors:
+ *    Tom Morris - initial implementation
+ *    Bogdan Pistol - Undo support
  *    thn
  *****************************************************************************
  *
@@ -49,8 +51,8 @@
 import org.eclipse.uml2.uml.ElementImport;
 import org.eclipse.uml2.uml.Model;
 import org.eclipse.uml2.uml.Namespace;
-import org.eclipse.uml2.uml.Package;
 import org.eclipse.uml2.uml.PackageableElement;
+import org.eclipse.uml2.uml.Profile;
 import org.eclipse.uml2.uml.UMLFactory;
 
 
@@ -67,7 +69,7 @@
     
     private EditingDomain editingDomain;
     
-    private Package theRootModel;
+    private org.eclipse.uml2.uml.Package theRootModel;
 
     /**
      * Constructor.
@@ -83,15 +85,9 @@
 
     public ElementImport buildElementImport(final Object pack, 
             final Object me) {
+        UMLUtil.checkArgs(new Object[] {pack, me}, 
+                new Class[] {Namespace.class, PackageableElement.class});
         
-        if (!(pack instanceof Namespace)) {
-            throw new IllegalArgumentException(
-                    "pack must be instance of Namespace"); //$NON-NLS-1$
-        }
-        if (!(me instanceof PackageableElement)) {
-            throw new IllegalArgumentException(
-                    "me must be instance of PackageableElement"); //$NON-NLS-1$
-        }
         RunnableClass run = new RunnableClass() {
             public void run() {
                 ElementImport elementImport = createElementImport();
@@ -107,12 +103,20 @@
     }
 
 
-    public Package buildPackage(String name) {
-        Package pkg = (Package) createPackage();
+    public org.eclipse.uml2.uml.Package buildPackage(final String name) {
+        RunnableClass run = new RunnableClass() {
+            public void run() {
+                org.eclipse.uml2.uml.Package pkg =
+                    (org.eclipse.uml2.uml.Package) createPackage();
         if (name != null) {
             pkg.setName(name);
         }
-        return pkg;
+            getParams().add(pkg);
+            }
+        };
+        editingDomain.getCommandStack().execute(
+                new ChangeCommand(editingDomain, run));
+        return (org.eclipse.uml2.uml.Package) run.getParams().get(0);
     }
     
     public Object copyPackage(Object source, Object ns) {
@@ -121,22 +125,50 @@
     }
 
     public ElementImport createElementImport() {
-        return UMLFactory.eINSTANCE.createElementImport();
+       RunnableClass run = new RunnableClass() {
+            public void run() {
+                getParams().add(UMLFactory.eINSTANCE.createElementImport());
+            }
+        };
+        editingDomain.getCommandStack().execute(
+                new ChangeCommand(editingDomain, run));
+        return (ElementImport) run.getParams().get(0);
     }
 
     public Model createModel() {
         // TODO: Check for Resource to hold this and create if necessary?
         // This is a discrepancy between MDR which does it here and eUML which
         // does it as part of setRootModel
-        return UMLFactory.eINSTANCE.createModel();
+        RunnableClass run = new RunnableClass() {
+            public void run() {
+                getParams().add(UMLFactory.eINSTANCE.createModel());
+            }
+        };
+        editingDomain.getCommandStack().execute(
+                new ChangeCommand(editingDomain, run));
+        return (Model) run.getParams().get(0);
     }
 
-    public Package createPackage() {
-        return UMLFactory.eINSTANCE.createPackage();
+    public org.eclipse.uml2.uml.Package createPackage() {
+        RunnableClass run = new RunnableClass() {
+            public void run() {
+                getParams().add(UMLFactory.eINSTANCE.createPackage());
+            }
+        };
+        editingDomain.getCommandStack().execute(
+                new ChangeCommand(editingDomain, run));
+        return (org.eclipse.uml2.uml.Package) run.getParams().get(0);
     }
 
-    public Package createProfile() {
-        return UMLFactory.eINSTANCE.createProfile();
+    public Profile createProfile() {
+        RunnableClass run = new RunnableClass() {
+            public void run() {
+                getParams().add(UMLFactory.eINSTANCE.createProfile());
+            }
+        };
+        editingDomain.getCommandStack().execute(
+                new ChangeCommand(editingDomain, run));
+        return (Profile) run.getParams().get(0);
     }
 
     @Deprecated
@@ -147,13 +179,14 @@
 
     // TODO: get/setRootModel aren't specific to the Model implementation
     // they could probably be moved elsewhere - tfm - 20070530
+    @Deprecated
     public void setRootModel(Object rootModel) {
         // TODO: Hook this creating of a new resource in to someplace more
         // more appropriate (perhaps createModel() ?)
         // Better yet add a new method to Model API to create a new top level 
         // project/model/xmi file so we don't depend on side effects
         if (rootModel != null 
-                && !(rootModel instanceof Package)) {
+                && !(rootModel instanceof org.eclipse.uml2.uml.Package)) {
             throw new IllegalArgumentException(
                     "The rootModel supplied must be a Package. Got a " //$NON-NLS-1$
                     + rootModel.getClass().getName());
@@ -161,7 +194,7 @@
 	if (theRootModel != null && theRootModel.eResource() != null) {
 	    EcoreUtil.remove(theRootModel);
 	}
-        theRootModel = (Package) rootModel;
+        theRootModel = (org.eclipse.uml2.uml.Package) rootModel;
 	if (rootModel != null) {
             Resource r = UMLUtil.getResource(modelImpl, UMLUtil.DEFAULT_URI, 
                     Boolean.FALSE);
@@ -170,7 +203,8 @@
         modelImpl.getModelEventPump().setRootContainer(theRootModel);
     }
 
-    public Package getRootModel() {
+    @Deprecated
+    public org.eclipse.uml2.uml.Package getRootModel() {
         return theRootModel;
     }

------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2526401

To unsubscribe from this discussion, e-mail: [[email protected]].
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.