svn commit: r18699 - 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: bobtarling
Date: 2010-08-28 04:44:45-0700
New Revision: 18699

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

Log:
Allow setMultiplicity to interpret complex multiplicity strings from combobox or from reverse engineering

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=18699&r1=18698&r2=18699
==============================================================================
--- 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	2010-08-28 04:44:45-0700
@@ -2931,14 +2931,26 @@
 
     public void setMultiplicity(Object handle, Object arg) {
         if (arg instanceof String) {
-            // TODO: We have multiple string representations for multiplicities
-            // these should be consolidated. This form is used by
-            // org.argouml.uml.reveng
-            if ("1_N".equals(arg)) {
+            String sarg = (String) arg;
+            boolean allDigits = true;
+            for (int i=0; i < sarg.length(); ++i) {
+                if (!Character.isDigit(sarg.charAt(i))) {
+                    allDigits = false;
+                }
+            }
+            if (allDigits || sarg.indexOf('.') > -1 || sarg.indexOf(',') > -1) {
                 arg =
-                    modelImpl.getDataTypesFactory().createMultiplicity(1, -1);
+                    modelImpl.getDataTypesFactory().createMultiplicity(sarg);
             } else {
-                arg = modelImpl.getDataTypesFactory().createMultiplicity(1, 1);
+                // TODO: We have multiple string representations for multiplicities
+                // these should be consolidated. This form is used by
+                // org.argouml.uml.reveng
+                if ("1_N".equals(arg)) {
+                    arg =
+                        modelImpl.getDataTypesFactory().createMultiplicity(1, -1);
+                } else {
+                    arg = modelImpl.getDataTypesFactory().createMultiplicity(1, 1);
+                }
             }
         }

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

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.