svn commit: r17424 - trunk/src: argouml-core-model-euml/src/org/argouml/model/euml argouml-core-model-mdr/src/org/argouml/model/mdr argouml-core-model/src/org/argouml/model

Thomas Neustupny <[email protected]>
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: thn
Date: 2009-10-24 16:00:53-0700
New Revision: 17424

Modified:
   trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/ExtensionMechanismsHelperEUMLImpl.java
   trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/ExtensionMechanismsHelperMDRImpl.java
   trunk/src/argouml-core-model/src/org/argouml/model/AbstractExtensionMechanismsHelperDecorator.java
   trunk/src/argouml-core-model/src/org/argouml/model/ExtensionMechanismsHelper.java

Log:
UML2 only: extending extension mechanism helper to handle the shift from UML-style profile model to the applicable profile that extends the UML metamodel

Modified: trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/ExtensionMechanismsHelperEUMLImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/ExtensionMechanismsHelperEUMLImpl.java?view=diff&pathrev=17424&r1=17423&r2=17424
==============================================================================
--- trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/ExtensionMechanismsHelperEUMLImpl.java	(original)
+++ trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/ExtensionMechanismsHelperEUMLImpl.java	2009-10-24 16:00:53-0700
@@ -30,7 +30,14 @@
 import java.util.Collections;
 
 import org.argouml.model.ExtensionMechanismsHelper;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.util.EcoreUtil;
 import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.Profile;
+import org.eclipse.uml2.uml.Stereotype;
+import org.eclipse.uml2.uml.UMLPackage;
 
 /**
  * The implementation of the ExtensionMechanismsHelper for EUML2.
@@ -44,7 +51,7 @@
 
     /**
      * Constructor.
-     *
+     * 
      * @param implementation The ModelImplementation.
      */
     public ExtensionMechanismsHelperEUMLImpl(
@@ -53,23 +60,48 @@
     }
 
     public void addBaseClass(Object handle, Object baseClass) {
-        // TODO: Auto-generated method stub
-        
+        if (handle instanceof Stereotype) {
+            Profile profile = (Profile) modelImpl.getFacade().getRoot(handle);
+            org.eclipse.uml2.uml.Class metaclass = null;
+            if (profile != null && baseClass instanceof String) {
+                // metaclass =
+                // (org.eclipse.uml2.uml.Class)
+                // ExtensionMechanismsFactoryEUMLImpl
+                // .getUMLMetamodel(). .getOwnedType((String) baseClass);
+                Resource res = modelImpl.getEditingDomain().getResourceSet()
+                        .getResource(URI.createURI(UMLPackage.eNS_URI), true);
+                Model m = (Model) EcoreUtil.getObjectByType(res.getContents(),
+                        UMLPackage.Literals.PACKAGE);
+                metaclass = (org.eclipse.uml2.uml.Class) m
+                        .getOwnedType((String) baseClass);
+            } else if (profile != null
+                    && baseClass instanceof org.eclipse.uml2.uml.Class) {
+                metaclass = (org.eclipse.uml2.uml.Class) baseClass;
+            }
+            if (metaclass != null) {
+                profile.createMetaclassReference(metaclass);
+                Stereotype st = (Stereotype) handle;
+                st.createExtension(metaclass, false);
+                return;
+            }
+        }
+        throw new IllegalArgumentException(
+                "Not a Stereotype or illegal base class"); //$NON-NLS-1$
     }
 
     public void addCopyStereotype(Object modelElement, Object stereotype) {
         // TODO: Auto-generated method stub
-        
+
     }
 
     public void addExtendedElement(Object handle, Object extendedElement) {
         // TODO: Auto-generated method stub
-        
+
     }
 
     public void addTaggedValue(Object handle, Object taggedValue) {
         // TODO: Auto-generated method stub
-        
+
     }
 
     public Collection getAllPossibleStereotypes(Collection models,
@@ -86,15 +118,13 @@
     }
 
     /**
-     * @param clazz
-     *            the UML class
+     * @param clazz the UML class
      * @return the meta name of the UML class
      */
     protected String getMetaModelName(Class clazz) {
         return modelImpl.getMetaTypes().getName(clazz);
     }
-    
-    
+
     public Object getStereotype(Object ns, Object stereo) {
         // TODO: Auto-generated method stub
         return null;
@@ -153,11 +183,11 @@
     }
 
     public void setTagType(Object handle, String tagType) {
-        // TODO: Auto-generated method stub        
+        // TODO: Auto-generated method stub
     }
-    
+
     public void setType(Object handle, Object type) {
-        // TODO: Auto-generated method stub        
+        // TODO: Auto-generated method stub
     }
 
     public void setValueOfTag(Object handle, String value) {
@@ -167,5 +197,12 @@
     public void setDataValues(Object handle, String[] value) {
         // TODO: Auto-generated method stub
     }
-
+    
+    public Object makeProfileApplicable(Object handle) {
+        Object result = null;
+        if (handle instanceof Profile) {
+            result = ((Profile) handle).define();
+        }
+        return result;
+    }
 }

Modified: trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/ExtensionMechanismsHelperMDRImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/ExtensionMechanismsHelperMDRImpl.java?view=diff&pathrev=17424&r1=17423&r2=17424
==============================================================================
--- trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/ExtensionMechanismsHelperMDRImpl.java	(original)
+++ trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/ExtensionMechanismsHelperMDRImpl.java	2009-10-24 16:00:53-0700
@@ -486,4 +486,9 @@
         }
         return false;
     }
+    
+    public Object makeProfileApplicable(Object handle) {
+        // this method makes no sense in UML1.4
+        return null;
+    }
 }

Modified: trunk/src/argouml-core-model/src/org/argouml/model/AbstractExtensionMechanismsHelperDecorator.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model/src/org/argouml/model/AbstractExtensionMechanismsHelperDecorator.java?view=diff&pathrev=17424&r1=17423&r2=17424
==============================================================================
--- trunk/src/argouml-core-model/src/org/argouml/model/AbstractExtensionMechanismsHelperDecorator.java	(original)
+++ trunk/src/argouml-core-model/src/org/argouml/model/AbstractExtensionMechanismsHelperDecorator.java	2009-10-24 16:00:53-0700
@@ -150,5 +150,8 @@
     public boolean hasStereotype(Object handle, String name) {
         return impl.hasStereotype(handle, name);
     }
-
+    
+    public Object makeProfileApplicable(Object handle) {
+        return impl.makeProfileApplicable(handle);
+    }
 }

Modified: trunk/src/argouml-core-model/src/org/argouml/model/ExtensionMechanismsHelper.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model/src/org/argouml/model/ExtensionMechanismsHelper.java?view=diff&pathrev=17424&r1=17423&r2=17424
==============================================================================
--- trunk/src/argouml-core-model/src/org/argouml/model/ExtensionMechanismsHelper.java	(original)
+++ trunk/src/argouml-core-model/src/org/argouml/model/ExtensionMechanismsHelper.java	2009-10-24 16:00:53-0700
@@ -271,4 +271,15 @@
      * @return true if there is such a stereotype
      */
     boolean hasStereotype(Object element, String name);
-}
+
+    /**
+     * Make a profile applicable. Usually a profile edited in a UML design
+     * environment like ArgoUML is not directly applicable, but needs to be
+     * shifted to the metamodel level, so that it can serve as an extension
+     * to the UML metamodel.
+     * 
+     * @param handle the profile before made applicable to a model
+     * @return the profile made applicable to a model
+     */
+    Object makeProfileApplicable(Object handle);
+}
\ No newline at end of file

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

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.