Author: bobtarling Date: 2008-05-09 17:26:50-0700 New Revision: 14684 Modified: trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/StateMachinesFactoryMDRImpl.java
Log: Move deleting of cooncurrent regions to model implementation. Fig reacts to events. Modified: trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/StateMachinesFactoryMDRImpl.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/StateMachinesFactoryMDRImpl.java?view=diff&rev=14684&p1=trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/StateMachinesFactoryMDRImpl.java&p2=trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/StateMachinesFactoryMDRImpl.java&r1=14683&r2=14684 ============================================================================== --- trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/StateMachinesFactoryMDRImpl.java (original) +++ trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/StateMachinesFactoryMDRImpl.java 2008-05-09 17:26:50-0700 @@ -24,6 +24,8 @@ package org.argouml.model.mdr; +import java.util.Collection; + import org.apache.log4j.Logger; import org.argouml.model.StateMachinesFactory; import org.omg.uml.behavioralelements.statemachines.CallEvent; @@ -485,6 +487,13 @@ /** * Deletes any associated subVertices. + * + * This also enforces the following well-formedness rule. + * <p>Well formedness rule 4.12.3.1 CompositeState + * [4] There have to be at least two composite substates in a + * concurrent composite state.<p> + * If this is broken by deletion of substate then we delete the other + * remaining substate and convert the composite state to non-concurrent * * @param elem * the UML element to be deleted @@ -494,8 +503,31 @@ throw new IllegalArgumentException(); } - for (StateVertex vertex : ((CompositeState) elem).getSubvertex()) { - modelImpl.getUmlFactory().delete(vertex); + final CompositeState compositeState = (CompositeState) elem; + final CompositeState containingCompositeState = + compositeState.getContainer(); + + // Well formedness rule 4.12.3.1 CompositeState + // [4] There have to be at least two composite substates in a + // concurrent composite state. + // If this is broken by deletion of substate then we delete the other + // remaining substates. + if (containingCompositeState != null && containingCompositeState.isConcurrent()) { + final Collection<StateVertex> siblings = + containingCompositeState.getSubvertex(); + + for (StateVertex vertex : compositeState.getSubvertex()) { + modelImpl.getUmlFactory().delete(vertex); + } + + final int substatesRemaining = siblings.size(); + if (substatesRemaining == 2) { + for (StateVertex sibling : siblings) { + if (sibling != compositeState) { + modelImpl.getUmlFactory().delete(sibling); + } + } + } } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
