svn commit: r19236 - trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/CoreHelperMDRImpl.java

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: mvw
Date: 2011-04-13 11:01:28-0700
New Revision: 19236

Modified:
   trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/CoreHelperMDRImpl.java

Log:
Fix the functionality of the checkbox for multiplicity on an attribute's proppanel.
Also fixed the deletion of unused Multiplicity elements outside the UML Model when using this checkbox.

Modified: trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/CoreHelperMDRImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/CoreHelperMDRImpl.java?view=diff&pathrev=19236&r1=19235&r2=19236
==============================================================================
--- trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/CoreHelperMDRImpl.java	(original)
+++ trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/CoreHelperMDRImpl.java	2011-04-13 11:01:28-0700
@@ -2995,10 +2995,19 @@
     }
 
     public void setMultiplicity(Object handle, String arg) {
-        setMultiplicity(handle,createMultiplicity(arg));
+        if (arg == null) {
+            setMultiplicityInternal(handle, null);
+        } else {
+            setMultiplicityInternal(handle,createMultiplicity(arg));
+        }
     }
 
-    private void setMultiplicity(Object handle, Multiplicity arg) {
+    /**
+     * @param handle shall not be null. Shall be one of AssociationRole, 
+     * ClassifierRole, StructuralFeature, AssociationEnd, TagDefinition.
+     * @param arg null is allowed
+     */
+    private void setMultiplicityInternal(Object handle, Multiplicity arg) {
         Multiplicity previousMult =
             (Multiplicity) Model.getFacade().getMultiplicity(handle);
         if (handle instanceof AssociationRole) {
@@ -3012,9 +3021,8 @@
         } else if (handle instanceof TagDefinition) {
             ((TagDefinition) handle).setMultiplicity(arg);
         }
-        if (previousMult != null &&
-                Model.getFacade().getModelElementContainer(previousMult)
-                == null) {
+        /* See issue 6038 for the reason behind the next statements: */
+        if (previousMult != null) {
             if (LOG.isDebugEnabled()) {
                 LOG.debug("Previous multiplicity of " + handle + " will be deleted." + arg);
             }
@@ -3029,13 +3037,16 @@
             return;
         }
         if (arg == null || arg instanceof Multiplicity) {
-            setMultiplicity(handle, (Multiplicity) arg);
+            setMultiplicityInternal(handle, (Multiplicity) arg);
         } else {
             throw new IllegalArgumentException("handle: " + handle + " or arg: "
                     + arg);
         }
     }
 
+    /**
+     * @param sarg may not be null
+     */
     private Multiplicity createMultiplicity(String sarg) {
         boolean allDigits = true;
         for (int i=0; i < sarg.length(); ++i) {
@@ -3065,7 +3076,7 @@
         Multiplicity arg = modelImpl.getDataTypesFactoryInternal()
                 .createMultiplicityInternal(lower, upper);
         
-        setMultiplicity(handle, arg);
+        setMultiplicityInternal(handle, arg);
     }
 
     public void setName(final Object handle, final String name) {

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

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.