mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-26 18:35:32 +02:00
[183247] updating element comparer to account for different subsystems
This commit is contained in:
parent
0df2ceb4ec
commit
eb9e3ee4bd
1 changed files with 56 additions and 47 deletions
|
@ -385,54 +385,8 @@ ISelectionChangedListener, ITreeViewerListener, ISystemResourceChangeEvents, ISy
|
||||||
busyCursor = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
|
busyCursor = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
|
||||||
|
|
||||||
setUseHashlookup(true); // new for our 2nd release. Attempt to fix 38 minutes to refresh for 15K elements
|
setUseHashlookup(true); // new for our 2nd release. Attempt to fix 38 minutes to refresh for 15K elements
|
||||||
setComparer(new IElementComparer()
|
setComparer(new ElementComparer());
|
||||||
{
|
|
||||||
public boolean equals(Object a, Object b)
|
|
||||||
{
|
|
||||||
if(a==b) return true;
|
|
||||||
if(a==null || b==null) return false;
|
|
||||||
if(a.equals(b)) return true;
|
|
||||||
|
|
||||||
ISystemViewElementAdapter identa= null;
|
|
||||||
if(a instanceof IAdaptable) {
|
|
||||||
identa = (ISystemViewElementAdapter)
|
|
||||||
((IAdaptable)a).getAdapter(ISystemViewElementAdapter.class);
|
|
||||||
}
|
|
||||||
if(identa != null) {
|
|
||||||
ISystemViewElementAdapter identb = null;
|
|
||||||
if(b instanceof IAdaptable) {
|
|
||||||
identb = (ISystemViewElementAdapter)
|
|
||||||
((IAdaptable)b).getAdapter(ISystemViewElementAdapter.class);
|
|
||||||
}
|
|
||||||
if (identb != null){
|
|
||||||
if(identa.getAbsoluteName(a).equals(identb.getAbsoluteName(b))) return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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();
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// set content provider
|
// set content provider
|
||||||
|
@ -4324,6 +4278,61 @@ ISelectionChangedListener, ITreeViewerListener, ISystemResourceChangeEvents, ISy
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected class ElementComparer implements IElementComparer
|
||||||
|
{
|
||||||
|
public boolean equals(Object a, Object b)
|
||||||
|
{
|
||||||
|
if(a==b) return true;
|
||||||
|
if(a==null || b==null) return false;
|
||||||
|
if(a.equals(b)) return true;
|
||||||
|
|
||||||
|
ISystemViewElementAdapter identa= null;
|
||||||
|
if(a instanceof IAdaptable) {
|
||||||
|
identa = (ISystemViewElementAdapter)
|
||||||
|
((IAdaptable)a).getAdapter(ISystemViewElementAdapter.class);
|
||||||
|
}
|
||||||
|
if(identa != null) {
|
||||||
|
ISystemViewElementAdapter identb = null;
|
||||||
|
if(b instanceof IAdaptable) {
|
||||||
|
identb = (ISystemViewElementAdapter)
|
||||||
|
((IAdaptable)b).getAdapter(ISystemViewElementAdapter.class);
|
||||||
|
}
|
||||||
|
if (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 not subsystems (the absolute name will distinguish them)
|
||||||
|
{
|
||||||
|
if(identa.getAbsoluteName(a).equals(identb.getAbsoluteName(b))) return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
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
|
* For many actions we have to walk the selection list and examine each selected
|
||||||
|
|
Loading…
Add table
Reference in a new issue