Author: thn
Date: 2011-02-17 08:34:04-0800
New Revision: 19038

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/ExtensionMechanismsHelper.java

Log:
new method for getting common types for tagged values

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=19038&r1=19037&r2=19038
==============================================================================
--- 
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
 2011-02-17 08:34:04-0800
@@ -8,7 +8,7 @@
  *
  * Contributors:
  *    Tom Morris - initial framework 
- *    thn
+ *    Thomas Neustupny
  *****************************************************************************/
 
 package org.argouml.model.euml;
@@ -33,6 +33,7 @@
 import org.eclipse.uml2.uml.Profile;
 import org.eclipse.uml2.uml.Property;
 import org.eclipse.uml2.uml.Stereotype;
+import org.eclipse.uml2.uml.Type;
 import org.eclipse.uml2.uml.UMLPackage;
 import org.eclipse.uml2.uml.resource.UMLResource;
 
@@ -47,6 +48,11 @@
     private EUMLModelImplementation modelImpl;
 
     /**
+     * Lazily initialized collection of common tagged value types.
+     */
+    private Collection commonTaggedValueTypes;
+
+    /**
      * Constructor.
      * 
      * @param implementation The ModelImplementation.
@@ -80,8 +86,16 @@
     }
 
     public void addTaggedValue(Object handle, Object taggedValue) {
-        // TODO: Auto-generated method stub
-
+        if (!(handle instanceof Element)) {
+            return;
+        }
+        if (!(taggedValue instanceof Property)) {
+            return;
+        }
+        Element elem = (Element) handle;
+        Property property = (Property) taggedValue;
+        Stereotype stereotype = (Stereotype) property.eContainer();
+        elem.setValue(stereotype, property.getName(), null);
     }
 
     public void applyProfile(Object handle, Object profile) {
@@ -214,6 +228,27 @@
         return l;
     }
 
+    /*
+     * @see 
org.argouml.model.ExtensionMechanismsHelper#getCommonTaggedValueTypes()
+     */
+    public Collection<Type> getCommonTaggedValueTypes() {
+        // TODO: still not used, because in ArgoUML String is "hardwired"
+        if (commonTaggedValueTypes == null) {
+            commonTaggedValueTypes = new ArrayList<Type>();
+            
//commonTaggedValueTypes.add(org.eclipse.uml2.uml.resource.UMLResource.)
+            URI uri = 
URI.createURI(UMLResource.UML_PRIMITIVE_TYPES_LIBRARY_URI);
+            ResourceSet rs = modelImpl.getEditingDomain().getResourceSet();
+            Resource res = rs.getResource(uri, true);
+            Model m = (Model) (org.eclipse.uml2.uml.Package) 
EcoreUtil.getObjectByType(
+                    res.getContents(), UMLPackage.Literals.MODEL);
+            commonTaggedValueTypes.add(m.getOwnedMember("Boolean"));
+            commonTaggedValueTypes.add(m.getOwnedMember("Integer"));
+            commonTaggedValueTypes.add(m.getOwnedMember("String"));
+            commonTaggedValueTypes.add(m.getOwnedMember("UnlimitedNatural"));
+        }
+        return commonTaggedValueTypes;
+    }
+
     public boolean hasStereotype(Object handle, String name) {
         if (name == null || !(handle instanceof Element)) {
             throw new IllegalArgumentException();

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=19038&r1=19037&r2=19038
==============================================================================
--- 
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
    2011-02-17 08:34:04-0800
@@ -219,6 +219,13 @@
         return ret;
     }
 
+    /*
+     * @see 
org.argouml.model.ExtensionMechanismsHelper#getCommonTaggedValueTypes()
+     */
+    public Collection getCommonTaggedValueTypes() {
+        // TODO: still not used, because in ArgoUML String is "hardwired"
+        return null;
+    }
 
 
     /**

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=19038&r1=19037&r2=19038
==============================================================================
--- 
trunk/src/argouml-core-model/src/org/argouml/model/ExtensionMechanismsHelper.java
   (original)
+++ 
trunk/src/argouml-core-model/src/org/argouml/model/ExtensionMechanismsHelper.java
   2011-02-17 08:34:04-0800
@@ -7,7 +7,7 @@
  * http://www.eclipse.org/legal/epl-v10.html
  *
  * Contributors:
- *    thn
+ *    Thomas Neustupny
  
*******************************************************************************
  *
  * Some portions of this file was previously release using the BSD License:
@@ -141,6 +141,18 @@
     Collection getStereotypes(Collection models);
 
     /**
+     * Get commonly used tagged value types. <p>
+     * While in early UML 1.x versions only String was provided, in UML 2.x
+     * tagged values are stereotype properties with any possible type. However
+     * even in UML 2.x only primitive types are used in most cases. The client
+     * of the model subsystem should be able to handle at least the returned
+     * types, but is still free to provide support for any type.
+     * 
+     * @return a collection of types
+     */
+    Collection getCommonTaggedValueTypes();
+
+    /**
      * Sets the stereotype of some modelelement. The method also
      * copies a stereotype that is not a part of the current model to
      * the current model.<p>

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

To unsubscribe from this discussion, e-mail: 
[[email protected]].

Reply via email to