瀏覽代碼

compare equality of EObjects by URIs instead of EcoreUtil.equals

Andreas Mülder 11 年之前
父節點
當前提交
8a303143d9

+ 7 - 13
de.itemis.gmf.utils/plugins/de.itemis.gmf.runtime.commons/src/de/itemis/gmf/runtime/commons/util/EditPartUtils.java

@@ -13,23 +13,20 @@ import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
 public class EditPartUtils {
 
 	@SuppressWarnings("unchecked")
-	public static IGraphicalEditPart findEditPartForSemanticElement(
-			EditPart editPart, EObject semanticElement) {
+	public static IGraphicalEditPart findEditPartForSemanticElement(EditPart editPart, EObject semanticElement) {
 		if (semanticElement == null) {
 			return null;
 		}
 		if (editPart instanceof IGraphicalEditPart) {
-			EObject resolveSemanticElement = ((IGraphicalEditPart) editPart)
-					.resolveSemanticElement();
+			EObject resolveSemanticElement = ((IGraphicalEditPart) editPart).resolveSemanticElement();
 
-			if (EcoreUtil.equals(resolveSemanticElement, semanticElement)) {
+			if (EcoreUtil.getURI(resolveSemanticElement).equals(EcoreUtil.getURI(semanticElement))) {
 				return (IGraphicalEditPart) editPart;
 			}
 		}
 
 		for (Object child : editPart.getChildren()) {
-			IGraphicalEditPart recursiveEditPart = findEditPartForSemanticElement(
-					(EditPart) child, semanticElement);
+			IGraphicalEditPart recursiveEditPart = findEditPartForSemanticElement((EditPart) child, semanticElement);
 			if (recursiveEditPart != null) {
 				return recursiveEditPart;
 			}
@@ -37,13 +34,10 @@ public class EditPartUtils {
 
 		if (editPart instanceof NodeEditPart) {
 			List<Connection> connections = new ArrayList<Connection>();
-			connections
-					.addAll(((NodeEditPart) editPart).getSourceConnections());
-			connections
-					.addAll(((NodeEditPart) editPart).getTargetConnections());
+			connections.addAll(((NodeEditPart) editPart).getSourceConnections());
+			connections.addAll(((NodeEditPart) editPart).getTargetConnections());
 			for (Object connection : connections) {
-				EObject resolveSemanticElement = ((IGraphicalEditPart) connection)
-						.resolveSemanticElement();
+				EObject resolveSemanticElement = ((IGraphicalEditPart) connection).resolveSemanticElement();
 				if (EcoreUtil.equals(resolveSemanticElement, semanticElement)) {
 					return (IGraphicalEditPart) connection;
 				}