|
|||||||||
| Home >> All >> org >> eclipse >> compare >> [ structuremergeviewer overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.eclipse.compare.structuremergeviewer
Class DiffNode

java.lang.Objectorg.eclipse.compare.structuremergeviewer.DiffElement
org.eclipse.compare.structuremergeviewer.DiffContainer
org.eclipse.compare.structuremergeviewer.DiffNode
- All Implemented Interfaces:
- ICompareInput, IDiffContainer, IDiffElement, org.eclipse.compare.ITypedElement
- public class DiffNode
- extends DiffContainer
- implements org.eclipse.compare.ITypedElement, ICompareInput
- extends DiffContainer
Diff node are used as the compare result of the differencing engine.
Since it implements the ITypedElement and ICompareInput
interfaces it can be used directly to display the
compare result in a DiffTreeViewer and as the input to any other
compare/merge viewer.
DiffNodes are typically created as the result of performing
a compare with the Differencer.
Clients typically use this class as is, but may subclass if required.
| Field Summary | |
private org.eclipse.compare.ITypedElement |
fAncestor
|
private boolean |
fDontExpand
|
private org.eclipse.compare.ITypedElement |
fLeft
|
private org.eclipse.jface.util.ListenerList |
fListener
|
private org.eclipse.compare.ITypedElement |
fRight
|
private boolean |
fSwapSides
|
| Fields inherited from class org.eclipse.compare.structuremergeviewer.DiffContainer |
|
| Fields inherited from class org.eclipse.compare.structuremergeviewer.DiffElement |
|
| Fields inherited from interface org.eclipse.compare.ITypedElement |
FOLDER_TYPE, TEXT_TYPE, UNKNOWN_TYPE |
| Constructor Summary | |
DiffNode(IDiffContainer parent,
int kind)
Creates a new DiffNode and initializes with the given values. |
|
DiffNode(IDiffContainer parent,
int kind,
org.eclipse.compare.ITypedElement ancestor,
org.eclipse.compare.ITypedElement left,
org.eclipse.compare.ITypedElement right)
Creates a new DiffNode and initializes with the given values. |
|
DiffNode(int kind)
Creates a new DiffNode with the given diff kind. |
|
DiffNode(int kind,
org.eclipse.compare.ITypedElement ancestor,
org.eclipse.compare.ITypedElement left,
org.eclipse.compare.ITypedElement right)
Creates a new DiffNode and initializes with the given values. |
|
DiffNode(org.eclipse.compare.ITypedElement left,
org.eclipse.compare.ITypedElement right)
Creates a new DiffNode with diff kind Differencer.CHANGE
and initializes with the given values. |
|
| Method Summary | |
void |
addCompareInputChangeListener(ICompareInputChangeListener listener)
Registers a listener for changes of this ICompareInput. |
void |
copy(boolean leftToRight)
Copy one side (source) to the other side (destination) depending on the value of leftToRight. |
boolean |
dontExpand()
Returns true if this node shouldn't automatically be expanded in
a DiffTreeViewer. |
boolean |
equals(java.lang.Object other)
Determine whether this Object is semantically equal to another Object. |
protected void |
fireChange()
Sends out notification that a change has occured on the ICompareInput. |
org.eclipse.compare.ITypedElement |
getAncestor()
Returns the ancestor side of this input. |
org.eclipse.compare.ITypedElement |
getId()
Returns the first not- null input of this node. |
org.eclipse.swt.graphics.Image |
getImage()
Returns an image for this object. |
org.eclipse.compare.ITypedElement |
getLeft()
Returns the left side of this input. |
java.lang.String |
getName()
Returns the (non- null) name of the left or right side if they are identical. |
private static java.lang.String[] |
getPath(org.eclipse.compare.ITypedElement el,
int level)
|
org.eclipse.compare.ITypedElement |
getRight()
Returns the right side of this input. |
java.lang.String |
getType()
Returns the type of this object. |
int |
hashCode()
Get a value that represents this Object, as uniquely as possible within the confines of an int. |
void |
removeCompareInputChangeListener(ICompareInputChangeListener listener)
Unregisters a ICompareInput listener. |
void |
setAncestor(org.eclipse.compare.ITypedElement ancestor)
Sets the ancestor input to the given value. |
void |
setDontExpand(boolean dontExpand)
Controls whether this node is not automatically expanded when displayed in a DiffTreeViewer. |
void |
setLeft(org.eclipse.compare.ITypedElement left)
Sets the left input to the given value. |
void |
setRight(org.eclipse.compare.ITypedElement right)
Sets the right input to the given value. |
(package private) void |
swapSides(boolean swap)
|
| Methods inherited from class org.eclipse.compare.structuremergeviewer.DiffContainer |
add, findChild, getChildren, hasChildren, remove, removeToRoot |
| Methods inherited from class org.eclipse.compare.structuremergeviewer.DiffElement |
getKind, getParent, setKind, setParent |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.eclipse.compare.structuremergeviewer.ICompareInput |
getKind |
| Methods inherited from interface org.eclipse.compare.structuremergeviewer.IDiffElement |
getKind, getParent, setParent |
| Field Detail |
fAncestor
private org.eclipse.compare.ITypedElement fAncestor
fLeft
private org.eclipse.compare.ITypedElement fLeft
fRight
private org.eclipse.compare.ITypedElement fRight
fDontExpand
private boolean fDontExpand
fListener
private org.eclipse.jface.util.ListenerList fListener
fSwapSides
private boolean fSwapSides
| Constructor Detail |
DiffNode
public DiffNode(IDiffContainer parent, int kind, org.eclipse.compare.ITypedElement ancestor, org.eclipse.compare.ITypedElement left, org.eclipse.compare.ITypedElement right)
- Creates a new
DiffNodeand initializes with the given values.
DiffNode
public DiffNode(org.eclipse.compare.ITypedElement left, org.eclipse.compare.ITypedElement right)
- Creates a new
DiffNodewith diff kindDifferencer.CHANGEand initializes with the given values.
DiffNode
public DiffNode(int kind,
org.eclipse.compare.ITypedElement ancestor,
org.eclipse.compare.ITypedElement left,
org.eclipse.compare.ITypedElement right)
- Creates a new
DiffNodeand initializes with the given values.
DiffNode
public DiffNode(int kind)
- Creates a new
DiffNodewith the given diff kind.
DiffNode
public DiffNode(IDiffContainer parent, int kind)
- Creates a new
DiffNodeand initializes with the given values.
| Method Detail |
addCompareInputChangeListener
public void addCompareInputChangeListener(ICompareInputChangeListener listener)
- Registers a listener for changes of this
ICompareInput. Has no effect if an identical listener is already registered.- Specified by:
addCompareInputChangeListenerin interfaceICompareInput
removeCompareInputChangeListener
public void removeCompareInputChangeListener(ICompareInputChangeListener listener)
- Unregisters a
ICompareInputlistener. Has no effect if listener is not registered.- Specified by:
removeCompareInputChangeListenerin interfaceICompareInput
fireChange
protected void fireChange()
- Sends out notification that a change has occured on the
ICompareInput.
dontExpand
public boolean dontExpand()
- Returns
trueif this node shouldn't automatically be expanded in a DiffTreeViewer.
setDontExpand
public void setDontExpand(boolean dontExpand)
- Controls whether this node is not automatically expanded when displayed in
a DiffTreeViewer.
getId
public org.eclipse.compare.ITypedElement getId()
- Returns the first not-
nullinput of this node. Method checks the three inputs in the order: ancestor, right, left.
getName
public java.lang.String getName()
- Returns the (non-
null) name of the left or right side if they are identical. Otherwise both names are concatenated (separated with a slash ('/')).Subclasses may re-implement to provide a different name for this node.
- Specified by:
getNamein interfaceorg.eclipse.compare.ITypedElement
swapSides
void swapSides(boolean swap)
getImage
public org.eclipse.swt.graphics.Image getImage()
- Description copied from interface:
org.eclipse.compare.ITypedElement - Returns an image for this object.
This image is used when displaying this object in the UI.
- Specified by:
getImagein interfaceorg.eclipse.compare.ITypedElement- Overrides:
getImagein classDiffElement
getType
public java.lang.String getType()
- Description copied from interface:
org.eclipse.compare.ITypedElement - Returns the type of this object. For objects with a file name
this is typically the file extension. For folders its the constant
FOLDER_TYPE. The type is used for determining a suitable viewer for this object.- Specified by:
getTypein interfaceorg.eclipse.compare.ITypedElement- Overrides:
getTypein classDiffElement
setAncestor
public void setAncestor(org.eclipse.compare.ITypedElement ancestor)
- Sets the ancestor input to the given value.
- Since:
- 3.0
getAncestor
public org.eclipse.compare.ITypedElement getAncestor()
- Description copied from interface:
ICompareInput - Returns the ancestor side of this input.
Returns
nullif this input has no ancestor or in the two-way compare case.- Specified by:
getAncestorin interfaceICompareInput
setLeft
public void setLeft(org.eclipse.compare.ITypedElement left)
- Sets the left input to the given value.
getLeft
public org.eclipse.compare.ITypedElement getLeft()
- Description copied from interface:
ICompareInput - Returns the left side of this input.
Returns
nullif there is no left side (deletion or addition).- Specified by:
getLeftin interfaceICompareInput
setRight
public void setRight(org.eclipse.compare.ITypedElement right)
- Sets the right input to the given value.
getRight
public org.eclipse.compare.ITypedElement getRight()
- Description copied from interface:
ICompareInput - Returns the right side of this input.
Returns
nullif there is no right side (deletion or addition).- Specified by:
getRightin interfaceICompareInput
copy
public void copy(boolean leftToRight)
- Description copied from interface:
ICompareInput - Copy one side (source) to the other side (destination) depending on the
value of
leftToRight. This method is called from a merge viewer if a corresponding action ("take left" or "take right") has been pressed.The implementation should handle the following cases:
-
if the source side is
nullthe destination must be deleted, -
if the destination is
nullthe destination must be created and filled with the contents from the source, -
if both sides are non-
nullthe contents of source must be copied to destination.
ICompareInputChangeListener.- Specified by:
copyin interfaceICompareInput
-
if the source side is
hashCode
public int hashCode()
- Description copied from class:
java.lang.Object - Get a value that represents this Object, as uniquely as
possible within the confines of an int.
There are some requirements on this method which subclasses must follow:
- Semantic equality implies identical hashcodes. In other
words, if
a.equals(b)is true, thena.hashCode() == b.hashCode()must be as well. However, the reverse is not necessarily true, and two objects may have the same hashcode without being equal. - It must be consistent. Whichever value o.hashCode() returns on the first invocation must be the value returned on all later invocations as long as the object exists. Notice, however, that the result of hashCode may change between separate executions of a Virtual Machine, because it is not invoked on the same object.
Notice that since
hashCodeis used in java.util.Hashtable and other hashing classes, a poor implementation will degrade the performance of hashing (so don't blindly implement it as returning a constant!). Also, if calculating the hash is time-consuming, a class may consider caching the results.The default implementation returns
System.identityHashCode(this) - Semantic equality implies identical hashcodes. In other
words, if
equals
public boolean equals(java.lang.Object other)
- Description copied from class:
java.lang.Object - Determine whether this Object is semantically equal
to another Object.
There are some fairly strict requirements on this method which subclasses must follow:
- It must be transitive. If
a.equals(b)andb.equals(c), thena.equals(c)must be true as well. - It must be symmetric.
a.equals(b)andb.equals(a)must have the same value. - It must be reflexive.
a.equals(a)must always be true. - It must be consistent. Whichever value a.equals(b) returns on the first invocation must be the value returned on all later invocations.
a.equals(null)must be false.- It must be consistent with hashCode(). That is,
a.equals(b)must implya.hashCode() == b.hashCode(). The reverse is not true; two objects that are not equal may have the same hashcode, but that has the potential to harm hashing performance.
This is typically overridden to throw a java.lang.ClassCastException if the argument is not comparable to the class performing the comparison, but that is not a requirement. It is legal for
a.equals(b)to be true even thougha.getClass() != b.getClass(). Also, it is typical to never cause a java.lang.NullPointerException.In general, the Collections API (
java.util) use theequalsmethod rather than the==operator to compare objects. However, java.util.IdentityHashMap is an exception to this rule, for its own good reasons.The default implementation returns
this == o. - It must be transitive. If
getPath
private static java.lang.String[] getPath(org.eclipse.compare.ITypedElement el, int level)
|
|||||||||
| Home >> All >> org >> eclipse >> compare >> [ structuremergeviewer overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC