diff options
author | Silenio Quarti <silenio> | 2010-05-13 16:59:27 +0000 |
---|---|---|
committer | Silenio Quarti <silenio> | 2010-05-13 16:59:27 +0000 |
commit | bd6625b33ee8355959ac2791f092e41f5e4be559 (patch) | |
tree | 2bb993c01bf5d43677be40be2684a9e42656915e /bundles | |
parent | 094d741e56b6f436da51b017270886d4b72c6a8d (diff) | |
download | eclipse.platform.swt-bd6625b33ee8355959ac2791f092e41f5e4be559.tar.gz eclipse.platform.swt-bd6625b33ee8355959ac2791f092e41f5e4be559.tar.xz eclipse.platform.swt-bd6625b33ee8355959ac2791f092e41f5e4be559.zip |
Bug 312795 - Accessible Relations should only be added once
Diffstat (limited to 'bundles')
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT Accessibility/gtk/org/eclipse/swt/accessibility/Accessible.java | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/gtk/org/eclipse/swt/accessibility/Accessible.java b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/gtk/org/eclipse/swt/accessibility/Accessible.java index 425ab258bb..683d944a36 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/gtk/org/eclipse/swt/accessibility/Accessible.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/gtk/org/eclipse/swt/accessibility/Accessible.java @@ -65,6 +65,13 @@ public class Accessible { this.type = type; this.target = target; } + + public boolean equals(Object object) { + if (object == this) return true; + if (!(object instanceof Relation)) return false; + Relation relation = (Relation)object; + return (relation.type == this.type) && (relation.target == this.target); + } } /** @@ -373,7 +380,9 @@ public class Accessible { public void addRelation(int type, Accessible target) { checkWidget(); if (relations == null) relations = new Vector(); - relations.add(new Relation(type, target)); + Relation relation = new Relation(type, target); + if (relations.indexOf(relation) != -1) return; + relations.add(relation); if (accessibleObject != null) accessibleObject.addRelation(type, target); } @@ -749,16 +758,11 @@ public class Accessible { public void removeRelation(int type, Accessible target) { checkWidget(); if (relations == null) return; - for (int i = relations.size() - 1; i >= 0; i--) { - Relation relation = (Relation)relations.elementAt(i); - if (relation.type == type && relation.target == target) { - relations.remove(i); - if (accessibleObject != null) { - accessibleObject.removeRelation(relation.type, relation.target); - } - break; - } - } + Relation relation = new Relation(type, target); + int index = relations.indexOf(relation); + if (index == -1) return; + relations.remove(index); + if (accessibleObject != null) accessibleObject.removeRelation(type, target); } /** |