Lines 31-36
Link Here
|
31 |
* Kevin Doyle (IBM) - [194602] handleDoubleClick does expand/collapse on treepath instead of element |
31 |
* Kevin Doyle (IBM) - [194602] handleDoubleClick does expand/collapse on treepath instead of element |
32 |
* David McKnight (IBM) - [194897] Should not remote refresh objects above subsystem. |
32 |
* David McKnight (IBM) - [194897] Should not remote refresh objects above subsystem. |
33 |
* Kevin Doyle - [193380] Deleting connection Refresh's Entire Remote Systems view |
33 |
* Kevin Doyle - [193380] Deleting connection Refresh's Entire Remote Systems view |
|
|
34 |
* Kevin Doyle - [195537] Move ElementComparer to Separate File |
34 |
********************************************************************************/ |
35 |
********************************************************************************/ |
35 |
|
36 |
|
36 |
package org.eclipse.rse.internal.ui.view; |
37 |
package org.eclipse.rse.internal.ui.view; |
Lines 61-67
Link Here
|
61 |
import org.eclipse.jface.viewers.IBasicPropertyConstants; |
62 |
import org.eclipse.jface.viewers.IBasicPropertyConstants; |
62 |
import org.eclipse.jface.viewers.IContentProvider; |
63 |
import org.eclipse.jface.viewers.IContentProvider; |
63 |
import org.eclipse.jface.viewers.IDoubleClickListener; |
64 |
import org.eclipse.jface.viewers.IDoubleClickListener; |
64 |
import org.eclipse.jface.viewers.IElementComparer; |
|
|
65 |
import org.eclipse.jface.viewers.ILabelDecorator; |
65 |
import org.eclipse.jface.viewers.ILabelDecorator; |
66 |
import org.eclipse.jface.viewers.IPostSelectionProvider; |
66 |
import org.eclipse.jface.viewers.IPostSelectionProvider; |
67 |
import org.eclipse.jface.viewers.ISelection; |
67 |
import org.eclipse.jface.viewers.ISelection; |
Lines 4599-4670
Link Here
|
4599 |
} |
4599 |
} |
4600 |
} |
4600 |
} |
4601 |
|
4601 |
|
4602 |
protected class ElementComparer implements IElementComparer |
|
|
4603 |
{ |
4604 |
public boolean equals(Object a, Object b) |
4605 |
{ |
4606 |
if(a==b) return true; |
4607 |
if(a==null || b==null) return false; |
4608 |
//TODO not sure if this equals() check is a good idea. |
4609 |
//It may be expensive and unnecessary. It might be better |
4610 |
//to do this as a fallback instead, in case the adapter |
4611 |
//is not found. |
4612 |
if(a.equals(b)) return true; |
4613 |
|
4614 |
if( (a instanceof IAdaptable) && (b instanceof IAdaptable) ) { |
4615 |
ISystemViewElementAdapter identa = |
4616 |
(ISystemViewElementAdapter) |
4617 |
((IAdaptable)a).getAdapter(ISystemViewElementAdapter.class); |
4618 |
ISystemViewElementAdapter identb = |
4619 |
(ISystemViewElementAdapter) |
4620 |
((IAdaptable)b).getAdapter(ISystemViewElementAdapter.class); |
4621 |
if(identa != null && identb != null) { |
4622 |
// first need to check subsystems |
4623 |
ISubSystem ssa = identa.getSubSystem(a); |
4624 |
ISubSystem ssb = identb.getSubSystem(b); |
4625 |
if (ssa == ssb) { |
4626 |
// if the subsystems are the same OR if both are null |
4627 |
// (the absolute name will distinguish them) |
4628 |
String ana = identa.getAbsoluteName(a); |
4629 |
if (ana!=null) { |
4630 |
return ana.equals(identb.getAbsoluteName(b)); |
4631 |
} |
4632 |
} |
4633 |
} |
4634 |
} |
4635 |
return false; |
4636 |
} |
4637 |
|
4638 |
public int hashCode(Object element) |
4639 |
{ |
4640 |
ISystemViewElementAdapter ident=null; |
4641 |
if(element instanceof IAdaptable) { |
4642 |
ident = (ISystemViewElementAdapter) |
4643 |
((IAdaptable)element).getAdapter(ISystemViewElementAdapter.class); |
4644 |
if(ident!=null) { |
4645 |
String absName = ident.getAbsoluteName(element); |
4646 |
if(absName!=null) return absName.hashCode(); |
4647 |
//Since one adapter is typically used for many elements in RSE, |
4648 |
//performance would be better if the original Element's hashCode |
4649 |
//were used rather than the adapter's hashCode. The problem with |
4650 |
//this is, that if the remote object changes, it cannot be |
4651 |
//identified any more. |
4652 |
//Note that even if the SAME object is modified during refresh |
4653 |
//(so object a==b), the hashCode of the object can change |
4654 |
//over time if properties are modified. Therefore, play it |
4655 |
//safe and return the adapter's hashCode which won't ever change. |
4656 |
return ident.hashCode(); |
4657 |
} |
4658 |
} |
4659 |
if (element != null) { // adding check because I hit a null exception here once at startup |
4660 |
return element.hashCode(); |
4661 |
} else { |
4662 |
//System.out.println("null element"); |
4663 |
return 0; |
4664 |
} |
4665 |
} |
4666 |
} |
4667 |
|
4668 |
/** |
4602 |
/** |
4669 |
* -------------------------------------------------------------------------------- |
4603 |
* -------------------------------------------------------------------------------- |
4670 |
* For many actions we have to walk the selection list and examine each selected |
4604 |
* For many actions we have to walk the selection list and examine each selected |