Bug 580532: [ClassDiagram][Sirius][Synchronization] Change node declaration from Not Synchronized to Unsynchronized.
-Constraint: improve semantic candidate expression

Signed-off-by: Vincent Lorenzo <vincent.lorenzo@cea.fr>
Change-Id: I7b908ebc5dbd58bea2a5c6a652127d4aebc4d482
diff --git a/plugins/uml/org.eclipse.papyrus.sirius.uml.diagram.clazz/src/org/eclipse/papyrus/sirius/uml/diagram/clazz/services/ClassDiagramServices.java b/plugins/uml/org.eclipse.papyrus.sirius.uml.diagram.clazz/src/org/eclipse/papyrus/sirius/uml/diagram/clazz/services/ClassDiagramServices.java
index b0f5099..13b9e12 100755
--- a/plugins/uml/org.eclipse.papyrus.sirius.uml.diagram.clazz/src/org/eclipse/papyrus/sirius/uml/diagram/clazz/services/ClassDiagramServices.java
+++ b/plugins/uml/org.eclipse.papyrus.sirius.uml.diagram.clazz/src/org/eclipse/papyrus/sirius/uml/diagram/clazz/services/ClassDiagramServices.java
@@ -20,7 +20,6 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
-import java.util.stream.Collectors;
 
 import org.eclipse.core.runtime.Assert;
 import org.eclipse.emf.ecore.EAnnotation;
@@ -614,35 +613,26 @@
 	 * 
 	 * @param semanticContext
 	 *            the context in which we are looking for {@link Constraint}
+	 * 
 	 * @param diagram
 	 *            the current diagram
 	 * @return
-	 *         the Constraints available in the context
+	 *         the Constraints to display
 	 */
 	public Collection<EObject> constraint_getSemanticCandidates(final EObject semanticContext, final DDiagram diagram) {
 		final Collection<EObject> constraints = new HashSet<EObject>();
 
-		// we show in the diagram all Constraint owned directly by the diagram
-		if (semanticContext instanceof Namespace) {
-			constraints.addAll(((Namespace) semanticContext).getOwnedRules());
-		}
+
 		if (semanticContext instanceof Package) {
 			final Package pack = (Package) semanticContext;
-			constraints.addAll(pack.getPackagedElements().stream().filter(Constraint.class::isInstance).collect(Collectors.toList()));
-		}
+			// the constraints directly owned by the Package
+			constraints.addAll(pack.getOwnedRules());
 
-		// we show in the diagram all Constraint owned by a element represented in the diagram
-		// this behavior avoid to make disappear the constraint of the diagram when the user create a ContextLink between the Constraint and a Namespace
-		for (final DDiagramElement diagramElement : diagram.getOwnedDiagramElements()) {
-			final EObject current = diagramElement.getTarget();
-
-			if (current instanceof Namespace) {
-				// a context link has been created
-				constraints.addAll(((Namespace) current).getOwnedRules());
-			}
-			if (current instanceof Package) {
-				// a context link has not yet been created Contraint#context==null
-				constraints.addAll(((Package) current).getPackagedElements().stream().filter(Constraint.class::isInstance).collect(Collectors.toList()));
+			// the constraint owned by the an element owned by the Package
+			for (final PackageableElement current : pack.getPackagedElements()) {
+				if ((false == current instanceof Package) && current instanceof Namespace) {
+					constraints.addAll(((Namespace) current).getOwnedRules());
+				}
 			}
 		}