Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndre Weinand2001-08-06 11:18:43 -0400
committerAndre Weinand2001-08-06 11:18:43 -0400
commit929f682d4d7420854f8f5a589bdcb19b17d9c60e (patch)
tree4aef5239ac41783ae6dd5073429b1af4316b7e54 /bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer
parent9a6fed89beebb64c53a2aaecd8593b9d14565a71 (diff)
downloadeclipse.platform.team-929f682d4d7420854f8f5a589bdcb19b17d9c60e.tar.gz
eclipse.platform.team-929f682d4d7420854f8f5a589bdcb19b17d9c60e.tar.xz
eclipse.platform.team-929f682d4d7420854f8f5a589bdcb19b17d9c60e.zip
1GHBPA1: ITPVCM:WINNT - Compare - next change arrow switches to wrong file
Diffstat (limited to 'bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer')
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffNode.java47
1 files changed, 35 insertions, 12 deletions
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffNode.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffNode.java
index a25a0033f..c1cf1ee7b 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffNode.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffNode.java
@@ -290,23 +290,46 @@ public class DiffNode extends DiffContainer implements ITypedElement, ICompareIn
}
}
- //---- object
-
+ /* (non Javadoc)
+ * see Object.hashCode
+ */
public int hashCode() {
- Object id= getId();
- if (id != null)
- return id.hashCode();
- return super.hashCode();
+ String[] path= getPath(this, 0);
+ int hashCode= 1;
+ for (int i= 0; i < path.length; i++) {
+ String s= path[i];
+ hashCode= (31*hashCode) + (s != null ? s.hashCode() : 0);
+ }
+ return hashCode;
}
-
+
+ /* (non Javadoc)
+ * see Object.equals
+ */
public boolean equals(Object other) {
if (other != null && getClass() == other.getClass()) {
- DiffNode d= (DiffNode) other;
- Object id1= getId();
- Object id2= d.getId();
- if (id1 != null && id2 != null)
- return id1.equals(id2);
+ String[] path1= getPath(this, 0);
+ String[] path2= getPath((DiffNode) other, 0);
+ if (path1.length != path2.length)
+ return false;
+ for (int i= 0; i < path1.length; i++)
+ if (! path1[i].equals(path2[i]))
+ return false;
+ return true;
}
return super.equals(other);
}
+
+ private static String[] getPath(ITypedElement el, int level) {
+ String[] path= null;
+ if (el instanceof IDiffContainer) {
+ IDiffContainer parent= ((IDiffContainer)el).getParent();
+ if (parent instanceof ITypedElement)
+ path= getPath((ITypedElement)parent, level+1);
+ }
+ if (path == null)
+ path= new String[level+1];
+ path[(path.length-1)-level]= el.getName();
+ return path;
+ }
}

Back to the top