Index: UI/org/eclipse/rse/internal/ui/view/scratchpad/SystemScratchpadView.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/scratchpad/SystemScratchpadView.java,v --- UI/org/eclipse/rse/internal/ui/view/scratchpad/SystemScratchpadView.java 4 Jul 2007 17:51:00 -0000 1.13 +++ UI/org/eclipse/rse/internal/ui/view/scratchpad/SystemScratchpadView.java 9 Jul 2007 17:31:16 -0000 @@ -15,6 +15,7 @@ * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry * Kevin Doyle (IBM) - [192278] Removed handleKeyPressed * Kevin Doyle (IBM) - [189150] _selectionFlagsUpdated reset after clear action performed + * Kevin Doyle (IBM) - [195537] Use Hashlookup and ElementComparer ********************************************************************************/ package org.eclipse.rse.internal.ui.view.scratchpad; @@ -65,6 +66,7 @@ import org.eclipse.rse.internal.ui.actions.SystemOpenExplorerPerspectiveAction; import org.eclipse.rse.internal.ui.actions.SystemShowInTableAction; import org.eclipse.rse.internal.ui.actions.SystemSubMenuManager; +import org.eclipse.rse.internal.ui.view.ElementComparer; import org.eclipse.rse.internal.ui.view.SystemView; import org.eclipse.rse.internal.ui.view.SystemViewDataDragAdapter; import org.eclipse.rse.internal.ui.view.SystemViewDataDropAdapter; @@ -185,7 +187,9 @@ _provider = new SystemScratchpadViewProvider(this); - + setUseHashlookup(true); + setComparer(new ElementComparer()); + setContentProvider(_provider); IWorkbench wb = PlatformUI.getWorkbench(); Index: UI/org/eclipse/rse/internal/ui/view/SystemView.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemView.java,v --- UI/org/eclipse/rse/internal/ui/view/SystemView.java 4 Jul 2007 20:35:28 -0000 1.135 +++ UI/org/eclipse/rse/internal/ui/view/SystemView.java 9 Jul 2007 17:31:16 -0000 @@ -31,6 +31,7 @@ * Kevin Doyle (IBM) - [194602] handleDoubleClick does expand/collapse on treepath instead of element * David McKnight (IBM) - [194897] Should not remote refresh objects above subsystem. * Kevin Doyle - [193380] Deleting connection Refresh's Entire Remote Systems view + * Kevin Doyle - [195537] Move ElementComparer to Separate File ********************************************************************************/ package org.eclipse.rse.internal.ui.view; @@ -61,7 +62,6 @@ import org.eclipse.jface.viewers.IBasicPropertyConstants; import org.eclipse.jface.viewers.IContentProvider; import org.eclipse.jface.viewers.IDoubleClickListener; -import org.eclipse.jface.viewers.IElementComparer; import org.eclipse.jface.viewers.ILabelDecorator; import org.eclipse.jface.viewers.IPostSelectionProvider; import org.eclipse.jface.viewers.ISelection; @@ -4599,72 +4599,6 @@ } } - protected class ElementComparer implements IElementComparer - { - public boolean equals(Object a, Object b) - { - if(a==b) return true; - if(a==null || b==null) return false; - //TODO not sure if this equals() check is a good idea. - //It may be expensive and unnecessary. It might be better - //to do this as a fallback instead, in case the adapter - //is not found. - if(a.equals(b)) return true; - - if( (a instanceof IAdaptable) && (b instanceof IAdaptable) ) { - ISystemViewElementAdapter identa = - (ISystemViewElementAdapter) - ((IAdaptable)a).getAdapter(ISystemViewElementAdapter.class); - ISystemViewElementAdapter identb = - (ISystemViewElementAdapter) - ((IAdaptable)b).getAdapter(ISystemViewElementAdapter.class); - if(identa != null && identb != null) { - // first need to check subsystems - ISubSystem ssa = identa.getSubSystem(a); - ISubSystem ssb = identb.getSubSystem(b); - if (ssa == ssb) { - // if the subsystems are the same OR if both are null - // (the absolute name will distinguish them) - String ana = identa.getAbsoluteName(a); - if (ana!=null) { - return ana.equals(identb.getAbsoluteName(b)); - } - } - } - } - return false; - } - - public int hashCode(Object element) - { - ISystemViewElementAdapter ident=null; - if(element instanceof IAdaptable) { - ident = (ISystemViewElementAdapter) - ((IAdaptable)element).getAdapter(ISystemViewElementAdapter.class); - if(ident!=null) { - String absName = ident.getAbsoluteName(element); - if(absName!=null) return absName.hashCode(); - //Since one adapter is typically used for many elements in RSE, - //performance would be better if the original Element's hashCode - //were used rather than the adapter's hashCode. The problem with - //this is, that if the remote object changes, it cannot be - //identified any more. - //Note that even if the SAME object is modified during refresh - //(so object a==b), the hashCode of the object can change - //over time if properties are modified. Therefore, play it - //safe and return the adapter's hashCode which won't ever change. - return ident.hashCode(); - } - } - if (element != null) { // adding check because I hit a null exception here once at startup - return element.hashCode(); - } else { - //System.out.println("null element"); - return 0; - } - } - } - /** * -------------------------------------------------------------------------------- * For many actions we have to walk the selection list and examine each selected Index: UI/org/eclipse/rse/internal/ui/view/ElementComparer.java =================================================================== RCS file: UI/org/eclipse/rse/internal/ui/view/ElementComparer.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ UI/org/eclipse/rse/internal/ui/view/ElementComparer.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,69 @@ +/******************************************************************************** +* Copyright (c) 2007 IBM Corporation. All rights reserved. +* This program and the accompanying materials are made available under the terms +* of the Eclipse Public License v1.0 which accompanies this distribution, and is +* available at http://www.eclipse.org/legal/epl-v10.html +* +* Initial Contributors: +* The following IBM employees contributed to the Remote System Explorer +* component that contains this file: David McKnight, Kushal Munir, +* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, +* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. +* +* Contributors: +* Kevin Doyle (IBM) - [195537] Move ElementComparer From SystemView to Separate File +********************************************************************************/ + +package org.eclipse.rse.internal.ui.view; + +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.jface.viewers.IElementComparer; +import org.eclipse.rse.core.RSECorePlugin; +import org.eclipse.rse.core.model.ISystemRegistry; +import org.eclipse.rse.ui.internal.model.SystemRegistry; +import org.eclipse.rse.ui.view.ISystemViewElementAdapter; + +public class ElementComparer implements IElementComparer +{ + + public boolean equals(Object a, Object b) + { + ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry(); + if (registry instanceof SystemRegistry) + { + return ((SystemRegistry) registry).isSameObjectByAbsoluteName(a, null, b, null); + } + return false; + } + + public int hashCode(Object element) + { + ISystemViewElementAdapter ident=null; + if(element instanceof IAdaptable) { + ident = (ISystemViewElementAdapter) + ((IAdaptable)element).getAdapter(ISystemViewElementAdapter.class); + if(ident!=null) { + String absName = ident.getAbsoluteName(element); + if(absName!=null) return absName.hashCode(); + //Since one adapter is typically used for many elements in RSE, + //performance would be better if the original Element's hashCode + //were used rather than the adapter's hashCode. The problem with + //this is, that if the remote object changes, it cannot be + //identified any more. + //Note that even if the SAME object is modified during refresh + //(so object a==b), the hashCode of the object can change + //over time if properties are modified. Therefore, play it + //safe and return the adapter's hashCode which won't ever change. + return ident.hashCode(); + } + } + if (element != null) { // adding check because I hit a null exception here once at startup + return element.hashCode(); + } else { + //System.out.println("null element"); + return 0; + } + } + +} +