svn commit: r13308 - branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/CoreFactoryEUMLImpl.java

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: b00__1
Date: 2007-08-13 10:55:00-0700
New Revision: 13308

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

Log:
Replace Realization with InterfaceRealization

Modified: branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/CoreFactoryEUMLImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/CoreFactoryEUMLImpl.java?view=diff&rev=13308&p1=branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/CoreFactoryEUMLImpl.java&p2=branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/CoreFactoryEUMLImpl.java&r1=13307&r2=13308
==============================================================================
--- branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/CoreFactoryEUMLImpl.java	(original)
+++ branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/CoreFactoryEUMLImpl.java	2007-08-13 10:55:00-0700
@@ -38,6 +38,7 @@
 import org.eclipse.uml2.uml.Association;
 import org.eclipse.uml2.uml.AssociationClass;
 import org.eclipse.uml2.uml.BehavioralFeature;
+import org.eclipse.uml2.uml.BehavioredClassifier;
 import org.eclipse.uml2.uml.Classifier;
 import org.eclipse.uml2.uml.Comment;
 import org.eclipse.uml2.uml.Component;
@@ -49,6 +50,7 @@
 import org.eclipse.uml2.uml.EnumerationLiteral;
 import org.eclipse.uml2.uml.Generalization;
 import org.eclipse.uml2.uml.Interface;
+import org.eclipse.uml2.uml.InterfaceRealization;
 import org.eclipse.uml2.uml.MultiplicityElement;
 import org.eclipse.uml2.uml.NamedElement;
 import org.eclipse.uml2.uml.Namespace;
@@ -58,7 +60,6 @@
 import org.eclipse.uml2.uml.Parameter;
 import org.eclipse.uml2.uml.PrimitiveType;
 import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.Realization;
 import org.eclipse.uml2.uml.Stereotype;
 import org.eclipse.uml2.uml.TemplateBinding;
 import org.eclipse.uml2.uml.TemplateParameter;
@@ -925,49 +926,35 @@
         return (PackageImport) run.getParams().get(0);
     }
 
-    public Realization buildRealization(final Object client,
-            final Object supplier, final Object namespace) {
-        if (!(client instanceof NamedElement)
-                || !(supplier instanceof NamedElement)) {
+    public InterfaceRealization buildRealization(final Object client,
+            final Object supplier, Object namespace) {
+        // The interface realization will be created in the client namespace
+        // (client is a namespace)
+        if (!(client instanceof BehavioredClassifier)) {
             throw new IllegalArgumentException(
-                    "The client and the supplier must be NamedElements."); //$NON-NLS-1$
+                    "The client must be instance of BehavioredClassifier"); //$NON-NLS-1$
         }
-        if ((namespace != null && !(namespace instanceof Namespace))
-                || (((NamedElement) client).getNearestPackage() != ((NamedElement) supplier).getNearestPackage() && namespace == null)
-                || (((NamedElement) client).getNearestPackage() == ((NamedElement) supplier).getNearestPackage()
-                        && ((NamedElement) supplier).getNearestPackage() == null && namespace == null)) {
+        if (!(supplier instanceof Interface)) {
             throw new IllegalArgumentException(
-                    "The namespace must be instance of Namespace."); //$NON-NLS-1$
-        } else {
-            if (((NamedElement) client).getNearestPackage() != ((NamedElement) supplier).getNearestPackage()
-                    && ((Namespace) namespace).getNearestPackage() == null) {
-                throw new NullPointerException(
-                        "The namespace must be contained in a package or be a package"); //$NON-NLS-1$
-            }
+                    "The supplier must be an Interface"); //$NON-NLS-1$
         }
         RunnableClass run = new RunnableClass() {
             public void run() {
-                Realization realization = UMLFactory.eINSTANCE.createRealization();
-                realization.getClients().add((NamedElement) client);
-                realization.getSuppliers().add((NamedElement) supplier);
-                if (((NamedElement) client).getNearestPackage() == ((NamedElement) supplier).getNearestPackage()
-                        && ((NamedElement) client).getNearestPackage() != null) {
-                    ((NamedElement) client).getNearestPackage().getPackagedElements().add(
-                            realization);
-                } else {
-                    ((Namespace) namespace).getNearestPackage().getPackagedElements().add(
-                            realization);
-                }
+                InterfaceRealization realization = UMLFactory.eINSTANCE.createInterfaceRealization();
+                realization.setImplementingClassifier((BehavioredClassifier) client);
+                realization.setContract((Interface) supplier);
+                ((BehavioredClassifier) client).getInterfaceRealizations().add(
+                        realization);
                 getParams().add(realization);
             }
         };
         ChangeCommand cmd = new ChangeCommand(
                 modelImpl, run,
-                "Create the realization # between the client # and the supplier #");
+                "Create the interface realization # between the client # and the supplier #");
         editingDomain.getCommandStack().execute(cmd);
         cmd.setObjects(run.getParams().get(0), client, supplier);
 
-        return (Realization) run.getParams().get(0);
+        return (InterfaceRealization) run.getParams().get(0);
     }
 
     public Object buildTemplateArgument(Object element) {
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.