svn commit: r15589 - 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

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: tfmorris
Date: 2008-08-19 13:10:43-0700
New Revision: 15589

Modified:
   trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/CoreFactoryEUMLImpl.java
   trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/CoreFactoryMDRImpl.java
   trunk/src/argouml-core-model/src/org/argouml/model/CoreFactory.java

Log:
STARTED - task 5282: Allow drawing of Associations between elements where one end is in a read-only extent

Modified: trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/CoreFactoryEUMLImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/CoreFactoryEUMLImpl.java?view=diff&rev=15589&p1=trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/CoreFactoryEUMLImpl.java&p2=trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/CoreFactoryEUMLImpl.java&r1=15588&r2=15589
==============================================================================
--- trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/CoreFactoryEUMLImpl.java	(original)
+++ trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/CoreFactoryEUMLImpl.java	2008-08-19 13:10:43-0700
@@ -1055,10 +1055,15 @@
         return UMLFactory.eINSTANCE.createArtifact();
     }
 
+    @Deprecated
     public Association createAssociation() {
-        return UMLFactory.eINSTANCE.createAssociation();
+        return createAssociation(null);
     }
 
+    public Association createAssociation(Object extent) {
+        return UMLFactory.eINSTANCE.createAssociation();
+    }
+    
     public AssociationClass createAssociationClass() {
         return UMLFactory.eINSTANCE.createAssociationClass();
     }

Modified: trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/CoreFactoryMDRImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/CoreFactoryMDRImpl.java?view=diff&rev=15589&p1=trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/CoreFactoryMDRImpl.java&p2=trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/CoreFactoryMDRImpl.java&r1=15588&r2=15589
==============================================================================
--- trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/CoreFactoryMDRImpl.java	(original)
+++ trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/CoreFactoryMDRImpl.java	2008-08-19 13:10:43-0700
@@ -174,14 +174,20 @@
     }
     
 
+    @SuppressWarnings("deprecation")
+    @Deprecated
     public UmlAssociation createAssociation() {
-        UmlAssociation assoc = getCorePackage().getUmlAssociation()
-                .createUmlAssociation();
+        return createAssociation(modelImpl.getUmlPackage());
+    }
+
+
+    public UmlAssociation createAssociation(Object extent) {
+        UmlAssociation assoc = ((org.omg.uml.UmlPackage) extent).getCore()
+                .getUmlAssociation().createUmlAssociation();
         super.initialize(assoc);
         return assoc;
     }
 
-
     public AssociationClass createAssociationClass() {
         AssociationClass assoc = getCorePackage().getAssociationClass()
                 .createAssociationClass();
@@ -310,7 +316,8 @@
         return myFlow;
     }
 
-
+    @SuppressWarnings("deprecation")
+    @Deprecated
     public Generalization createGeneralization() {
         return createGeneralization(modelImpl.getUmlPackage());
     }
@@ -429,7 +436,7 @@
      *            The navigability of the second Associaton end
      * @param agg2
      *            The aggregation type of the second Associaton end
-     * @return MAssociation
+     * @return a newly created Association
      * @throws IllegalArgumentException
      *             if either Classifier is null
      */
@@ -448,17 +455,19 @@
         }
         
         // We'll put the association in the namespace of whichever end
-        // is not navigable.  If they both are, we'll use the namepace of c1.
+        // is not navigable and is writeable.  If they both are, we'll use the
+        // namepace of c1.
         Namespace ns = null;
-        if (nav2) {
+        if (nav2 && !modelImpl.getModelManagementHelper().isReadOnly(ns1)) {
             ns = ns1;
-        } else if (nav1) {
+        } else if (nav1
+                && !modelImpl.getModelManagementHelper().isReadOnly(ns2)) {
             ns = ns2;
         } else {
             throw new IllegalArgumentException(
                     "At least one end must be navigable");
         }
-        UmlAssociation assoc = createAssociation();
+        UmlAssociation assoc = createAssociation(ns.refOutermostPackage());
         assoc.setName("");
         assoc.setNamespace(ns);
         buildAssociationEnd(assoc, null, c1, null, null,
@@ -481,14 +490,19 @@
         AggregationKind agg1 = (AggregationKind) aggregationKind1;
         AggregationKind agg2 = (AggregationKind) aggregationKind2;
 
-        Namespace ns1 = from.getNamespace();
-        if (ns1 == null) {
-            throw new IllegalArgumentException("The from "
-                    + "classifiers does not " + "belong to a namespace");
+        Namespace ns = from.getNamespace();
+        if (ns == null || modelImpl.getModelManagementHelper().isReadOnly(ns)) {
+            ns = to.getNamespace();
+            if (ns == null
+                    || modelImpl.getModelManagementHelper().isReadOnly(ns)) {
+                throw new IllegalArgumentException(
+                        "At least one namespace must be non-null and writeable");
+            }
         }
-        UmlAssociation assoc = createAssociation();
+
+        UmlAssociation assoc = createAssociation(ns.refOutermostPackage());
         assoc.setName("");
-        assoc.setNamespace(ns1);
+        assoc.setNamespace(ns);
 
         boolean nav1 = true;
         boolean nav2 = true;

Modified: trunk/src/argouml-core-model/src/org/argouml/model/CoreFactory.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model/src/org/argouml/model/CoreFactory.java?view=diff&rev=15589&p1=trunk/src/argouml-core-model/src/org/argouml/model/CoreFactory.java&p2=trunk/src/argouml-core-model/src/org/argouml/model/CoreFactory.java&r1=15588&r2=15589
==============================================================================
--- trunk/src/argouml-core-model/src/org/argouml/model/CoreFactory.java	(original)
+++ trunk/src/argouml-core-model/src/org/argouml/model/CoreFactory.java	2008-08-19 13:10:43-0700
@@ -71,11 +71,18 @@
      * Create an empty but initialized instance of a UML Association.
      * 
      * @return an initialized UML Association instance.
-     * TODO: This needs an extra parameter to specify the model/extent where
-     * the new element should be created.
+     * @deprecated for 0.26 by tfmorris. Use {@link #createAssociation(Object)}.
      */
     public Object createAssociation();
-
+    
+    /**
+     * Create an empty but initialized instance of a UML Association.
+     * 
+     * @param extent outer package (extent) in which to create new Association.
+     * @return an initialized UML Association instance.
+     */
+    public Object createAssociation(Object extent);
+    
     /**
      * Create an empty but initialized instance of a UML AssociationClass.
      *
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.