Bug 539011 - [SysML1.4] It is impossible to create a connector between
flowport inside two properties

Change-Id: Ie360bd5af6d1f9b4e17b7fc48e6dd1da1d775aaa
Signed-off-by: Pauline DEVILLE <pauline.deville@cea.fr>
diff --git a/core/org.eclipse.papyrus.sysml14.service.types/src/org/eclipse/papyrus/sysml14/service/types/util/ConnectorUtil.java b/core/org.eclipse.papyrus.sysml14.service.types/src/org/eclipse/papyrus/sysml14/service/types/util/ConnectorUtil.java
index 3bf2b27..42e0f57 100644
--- a/core/org.eclipse.papyrus.sysml14.service.types/src/org/eclipse/papyrus/sysml14/service/types/util/ConnectorUtil.java
+++ b/core/org.eclipse.papyrus.sysml14.service.types/src/org/eclipse/papyrus/sysml14/service/types/util/ConnectorUtil.java
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * Copyright (c) 2012, 2017 CEA LIST.
+ * Copyright (c) 2012, 2017, 2018 CEA LIST.
  *
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -12,6 +12,7 @@
  *
  *	CEA LIST - Initial API and implementation
  *  Pauline DEVILLE (CEA LIST) - Bug 528159 nestedConnectorEnd in wrong order
+ *  Pauline DEVILLE (CEA LIST) - Bug 539011 It is impossible to create a connector between flowport inside two properties
  *
  *****************************************************************************/
 package org.eclipse.papyrus.sysml14.service.types.util;
@@ -61,8 +62,8 @@
 	 *
 	 */
 	private ConnectorUtil() {
-	}	
-	
+	}
+
 	/**
 	 * Gets the encapsulated container.
 	 *
@@ -85,7 +86,7 @@
 
 			StructuredClassifier structuredClassifier = umlUtility.getStructuredClassifier(containerView);
 			Block block = UMLUtil.getStereotypeApplication(structuredClassifier, Block.class);
-			if (block!= null && block.isEncapsulated()) {
+			if (block != null && block.isEncapsulated()) {
 				encapsulatedContainer = containerView;
 				break;
 			}
@@ -256,7 +257,7 @@
 	/**
 	 * Inverse of property path from the view to the class
 	 * 
-	 * [SysML 1.4 - 8.3.2.9]: "The ordering of properties is from a property of the context block, through a 
+	 * [SysML 1.4 - 8.3.2.9]: "The ordering of properties is from a property of the context block, through a
 	 * property of each intermediate block that types the preceding property, ending in a property with a type
 	 * that owns or inherits the fully nested property."
 	 * 
@@ -268,10 +269,19 @@
 		List<Property> propertyPath = new ArrayList<>();
 		View currentView = ViewUtil.getContainerView(view);
 		// get the path from view to clazz
-		while (!clazz.equals(currentView.getElement())) {
+		boolean stop = false;
+		while (!stop && currentView != null) {
 			EObject property = currentView.getElement();
 			if (property instanceof Property) {
-				propertyPath.add((Property) property);
+				if (((Property) property).getType() == clazz) {
+					stop = true;
+				} else {
+					propertyPath.add((Property) property);
+				}
+			} else {
+				if (clazz.equals(currentView.getElement())) {
+					stop = true;
+				}
 			}
 			currentView = ViewUtil.getContainerView(currentView);
 		}