Author: bobtarling Date: 2010-04-27 05:27:26-0700 New Revision: 18336 Modified: trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/CoreHelperMDRImpl.java trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/FacadeMDRImpl.java
Log: Issue 6038: If changing multiplicity leaves an orphan then make sure that gets deleted. 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=18336&r1=18335&r2=18336 ============================================================================== --- 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-04-27 05:27:26-0700 @@ -2936,27 +2936,26 @@ if (arg == null || arg instanceof Multiplicity) { Multiplicity mult = (Multiplicity) arg; - + Multiplicity previousMult = + (Multiplicity) Model.getFacade().getMultiplicity(handle); if (handle instanceof AssociationRole) { ((AssociationRole) handle).setMultiplicity(mult); - return; - } - if (handle instanceof ClassifierRole) { + } else if (handle instanceof ClassifierRole) { ((ClassifierRole) handle).setMultiplicity(mult); - return; - } - if (handle instanceof StructuralFeature) { + } else if (handle instanceof StructuralFeature) { ((StructuralFeature) handle).setMultiplicity(mult); - return; - } - if (handle instanceof AssociationEnd) { - LOG.debug("Setting association end mult to " + mult); + } else if (handle instanceof AssociationEnd) { ((AssociationEnd) handle).setMultiplicity(mult); - return; - } - if (handle instanceof TagDefinition) { + } else if (handle instanceof TagDefinition) { ((TagDefinition) handle).setMultiplicity(mult); - return; + } + if (previousMult != null && + Model.getFacade().getModelElementContainer(previousMult) + == null) { + if (LOG.isDebugEnabled()) { + LOG.debug("Previous multiplicity of " + handle + " will be deleted." + mult); + } + Model.getUmlFactory().delete(previousMult); } } Modified: trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/FacadeMDRImpl.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/FacadeMDRImpl.java?view=diff&pathrev=18336&r1=18335&r2=18336 ============================================================================== --- trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/FacadeMDRImpl.java (original) +++ trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/FacadeMDRImpl.java 2010-04-27 05:27:26-0700 @@ -2130,18 +2130,18 @@ if (handle instanceof StructuralFeature) { StructuralFeature sf = (StructuralFeature) handle; return sf.getMultiplicity(); - } - if (handle instanceof TagDefinition) { + } else if (handle instanceof TagDefinition) { TagDefinition td = (TagDefinition) handle; return td.getMultiplicity(); - } - if (handle instanceof ClassifierRole) { + } else if (handle instanceof ClassifierRole) { ClassifierRole cr = (ClassifierRole) handle; return cr.getMultiplicity(); - } - if (handle instanceof AssociationEnd) { + } else if (handle instanceof AssociationEnd) { AssociationEnd ae = (AssociationEnd) handle; return ae.getMultiplicity(); + } else if (handle instanceof AssociationRole) { + AssociationRole ar = (AssociationRole) handle; + return ar.getMultiplicity(); } } catch (InvalidObjectException e) { throw new InvalidElementException(e); ------------------------------------------------------ http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2596901 To unsubscribe from this discussion, e-mail: [[email protected]].
