From b5980ec2a678f53afc6a627c2a7e54aacb2b258b Mon Sep 17 00:00:00 2001 From: David McKnight Date: Wed, 25 Apr 2007 16:39:34 +0000 Subject: [PATCH] [184053] recursiveFindExactMatches to find exact match when hash lookup fails --- .../rse/internal/ui/view/SystemView.java | 54 +++++++++++++++++-- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemView.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemView.java index 369532eba00..9f7696aa952 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemView.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemView.java @@ -2608,7 +2608,7 @@ public class SystemView extends SafeTreeViewer disassociate(match); match.dispose(); } else { - toRemove.add(data); + toRemove.add(match); //System.out.println(".....calling remove(data) on this match"); //remove(data); // remove this item from the tree } @@ -2616,7 +2616,12 @@ public class SystemView extends SafeTreeViewer } // do the remove now - remove(toRemove.toArray()); + for (int i = 0; i < toRemove.size(); i++) + { + Item childItem = (Item)toRemove.get(i); + disassociate(childItem); + childItem.dispose(); + } // STEP 4: if we removed a selected item, select its parent if (wasSelected && (parentItem != null) && (parentItem instanceof TreeItem) && (parentItem.getData() != null)) { @@ -3992,12 +3997,55 @@ public class SystemView extends SafeTreeViewer // try new map lookup method - won't work in cases of rename if (!mappedFindAllRemoteItemReferences(elementObject, matches)){ + + boolean foundExact = false; for (int idx = 0; idx < roots.length; idx++){ - matches = recursiveFindAllRemoteItemReferences(roots[idx], searchString, elementObject, subsystem, matches); + if (recursiveFindExactMatches((TreeItem)roots[idx], elementObject, subsystem, matches)){ + foundExact = true; + } + } + + if (!foundExact) + { + for (int idx = 0; idx < roots.length; idx++){ + matches = recursiveFindAllRemoteItemReferences(roots[idx], searchString, elementObject, subsystem, matches); + } } } return matches; } + + + private boolean recursiveFindExactMatches(TreeItem root, Object elementObject, ISubSystem subsystem, Vector matches) + { + boolean foundSomething = false; + Object data = root.getData(); + if (data == elementObject) + { + matches.add(root); + foundSomething = true; + } + if (subsystem != null){ + if (data instanceof ISubSystem){ + if (data != subsystem) + return false; + } + else if (data instanceof IHost){ + if (subsystem.getHost() != data) + return false; + } + } + + TreeItem[] children = root.getItems(); + for (int i = 0; i < children.length; i++) + { + if (recursiveFindExactMatches(children[i], elementObject, subsystem, matches)) + { + foundSomething = true; + } + } + return foundSomething; + } /** * Recursively tries to find the first occurrence of a given remote object, starting at the tree root.