svn commit: r16963 - trunk/src/argouml-app/src/org/argouml/uml/ui/UMLMultiplicityPanel.java

Tom Morris <[email protected]>
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: tfmorris
Date: 2009-03-26 12:37:29-0700
New Revision: 16963

Modified:
   trunk/src/argouml-app/src/org/argouml/uml/ui/UMLMultiplicityPanel.java

Log:
Don't delete multiplicities for UML 2.x.  They aren't data objects.

Modified: trunk/src/argouml-app/src/org/argouml/uml/ui/UMLMultiplicityPanel.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/ui/UMLMultiplicityPanel.java?view=diff&pathrev=16963&r1=16962&r2=16963
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/ui/UMLMultiplicityPanel.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/ui/UMLMultiplicityPanel.java	2009-03-26 12:37:29-0700
@@ -1,5 +1,5 @@
 // $Id$
-// Copyright (c) 1996-2008 The Regents of the University of California. All
+// Copyright (c) 1996-2009 The Regents of the University of California. All
 // Rights Reserved. Permission to use, copy, modify, and distribute this
 // software and its documentation without fee, and without a written
 // agreement is hereby granted, provided that the above copyright notice
@@ -108,9 +108,7 @@
             if (Model.getFacade().isAMultiplicity(item)) {
                 if (!item.equals(multiplicity)) {
                     Model.getCoreHelper().setMultiplicity(target, item);
-                    if (multiplicity != null) {
-                        Model.getUmlFactory().delete(multiplicity);
-                    }
+                    delete(multiplicity);
                 }
             } else if (item instanceof String) {
                 if (!item.equals(Model.getFacade().toString(multiplicity))) {
@@ -118,18 +116,26 @@
                             target,
                             Model.getDataTypesFactory().createMultiplicity(
                                     (String) item));
-                    if (multiplicity != null) {
-                        Model.getUmlFactory().delete(multiplicity);
-                    }
+                    delete(multiplicity);
                 }
             } else {
                 if (multiplicity != null) {
                     Model.getCoreHelper().setMultiplicity(target, null);
-                    Model.getUmlFactory().delete(multiplicity);
+                    delete(multiplicity);
                 }
             }
         }
     }
+
+    private void delete(Object multiplicity) {
+        if ("1.4".equals(Model.getFacade().getUmlVersion()) 
+                && multiplicity != null) {
+            // For UML 1.4 Multiplicities are value objects, but
+            // for UML 2.x, the bounds are contained by the Property
+            // so they shouldn't be cleaned up
+            Model.getUmlFactory().delete(multiplicity);
+        }
+    }
     
     private Object getTarget() {
 	return multiplicityComboBoxModel.getTarget();
@@ -172,7 +178,7 @@
                     Model.getDataTypesFactory().createMultiplicity(text);
                 if (multi != null) {
                     setSelectedItem(text);
-                    Model.getUmlFactory().delete(multi);
+                    delete(multi);
                     return;
                 }
             } catch (IllegalArgumentException e) {
@@ -310,9 +316,7 @@
                     } else {
                         Model.getCoreHelper().setMultiplicity(target, multi);
                     }
-                    if (oldValue != null) {
-                        Model.getUmlFactory().delete(oldValue);
-                    }
+                    delete(oldValue);
                 }
 		multiplicityComboBox.setEnabled(true);
 		multiplicityComboBox.setEditable(true);
@@ -320,9 +324,7 @@
 		multiplicityComboBox.setEnabled(false);
 		multiplicityComboBox.setEditable(false);
                 Model.getCoreHelper().setMultiplicity(target, null);
-                if (oldValue != null) {
-                    Model.getUmlFactory().delete(oldValue);
-                }
+                delete(oldValue);
 	    }
 	}
     }

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

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.