--- orig/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/RegionOperations.java 2013-01-02 10:31:50.000000000 +0100 +++ org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/RegionOperations.java 2013-03-09 12:37:09.769894973 +0100 @@ -19,17 +19,17 @@ import org.eclipse.emf.common.util.DiagnosticChain; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.common.util.UniqueEList; - import org.eclipse.uml2.uml.BehavioredClassifier; import org.eclipse.uml2.uml.Classifier; import org.eclipse.uml2.uml.ProtocolStateMachine; +import org.eclipse.uml2.uml.Pseudostate; +import org.eclipse.uml2.uml.PseudostateKind; import org.eclipse.uml2.uml.RedefinableElement; import org.eclipse.uml2.uml.Region; import org.eclipse.uml2.uml.State; import org.eclipse.uml2.uml.StateMachine; import org.eclipse.uml2.uml.Transition; import org.eclipse.uml2.uml.Vertex; - import org.eclipse.uml2.uml.util.UMLValidator; /** @@ -78,15 +78,19 @@ * @param diagnostics The chain of diagnostics to which problems are to be appended. * @param context The cache of context-specific information. * - * @generated + * @generated NOT */ public static boolean validateInitialVertex(Region region, DiagnosticChain diagnostics, Map context) { - // TODO: implement this method - // -> specify the condition that violates the invariant - // -> verify the details of the diagnostic, including severity and message - // Ensure that you remove @generated or mark it @generated NOT - if (false) { + int initialVertex = 0; + for(Vertex vertex : region.getSubvertices()) { + if(vertex instanceof Pseudostate) { + if(((Pseudostate)vertex).getKind() == PseudostateKind.INITIAL_LITERAL) { + initialVertex++; + } + } + } + if(initialVertex > 1) { if (diagnostics != null) { diagnostics .add(new BasicDiagnostic( @@ -115,15 +119,19 @@ * @param diagnostics The chain of diagnostics to which problems are to be appended. * @param context The cache of context-specific information. * - * @generated + * @generated NOT */ public static boolean validateDeepHistoryVertex(Region region, DiagnosticChain diagnostics, Map context) { - // TODO: implement this method - // -> specify the condition that violates the invariant - // -> verify the details of the diagnostic, including severity and message - // Ensure that you remove @generated or mark it @generated NOT - if (false) { + int deepHistory = 0; + for(Vertex vertex : region.getSubvertices()) { + if(vertex instanceof Pseudostate) { + if(((Pseudostate)vertex).getKind() == PseudostateKind.SHALLOW_HISTORY_LITERAL) { + deepHistory++; + } + } + } + if(deepHistory > 1) { if (diagnostics != null) { diagnostics .add(new BasicDiagnostic( @@ -152,15 +160,19 @@ * @param diagnostics The chain of diagnostics to which problems are to be appended. * @param context The cache of context-specific information. * - * @generated + * @generated NOT */ public static boolean validateShallowHistoryVertex(Region region, DiagnosticChain diagnostics, Map context) { - // TODO: implement this method - // -> specify the condition that violates the invariant - // -> verify the details of the diagnostic, including severity and message - // Ensure that you remove @generated or mark it @generated NOT - if (false) { + int shallowHistory = 0; + for(Vertex vertex : region.getSubvertices()) { + if(vertex instanceof Pseudostate) { + if(((Pseudostate)vertex).getKind() == PseudostateKind.SHALLOW_HISTORY_LITERAL) { + shallowHistory++; + } + } + } + if(shallowHistory > 1) { if (diagnostics != null) { diagnostics .add(new BasicDiagnostic( @@ -187,15 +199,12 @@ * @param diagnostics The chain of diagnostics to which problems are to be appended. * @param context The cache of context-specific information. * - * @generated + * @generated NOT */ public static boolean validateOwned(Region region, DiagnosticChain diagnostics, Map context) { - // TODO: implement this method - // -> specify the condition that violates the invariant - // -> verify the details of the diagnostic, including severity and message - // Ensure that you remove @generated or mark it @generated NOT - if (false) { + // ownerships must be different + if((region.getState() != null) == (region.getStateMachine() != null)) { if (diagnostics != null) { diagnostics .add(new BasicDiagnostic(