Class DiffNode
java.lang.Object
org.eclipse.compare.structuremergeviewer.DiffElement
org.eclipse.compare.structuremergeviewer.DiffContainer
org.eclipse.compare.structuremergeviewer.DiffNode
- All Implemented Interfaces:
- ITypedElement,- ICompareInput,- IDiffContainer,- IDiffElement
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.
- See Also:
- 
Field SummaryFields inherited from interface org.eclipse.compare.ITypedElementFOLDER_TYPE, TEXT_TYPE, UNKNOWN_TYPE
- 
Constructor SummaryConstructorsConstructorDescriptionDiffNode(int kind) Creates a newDiffNodewith the given diff kind.DiffNode(int kind, ITypedElement ancestor, ITypedElement left, ITypedElement right) Creates a newDiffNodeand initializes with the given values.DiffNode(ITypedElement left, ITypedElement right) Creates a newDiffNodewith diff kindDifferencer.CHANGEand initializes with the given values.DiffNode(IDiffContainer parent, int kind) Creates a newDiffNodeand initializes with the given values.DiffNode(IDiffContainer parent, int kind, ITypedElement ancestor, ITypedElement left, ITypedElement right) Creates a newDiffNodeand initializes with the given values.
- 
Method SummaryModifier and TypeMethodDescriptionvoidRegisters a listener for changes of thisICompareInput.voidcopy(boolean leftToRight) Copy one side (source) to the other side (destination) depending on the value ofleftToRight.booleanReturnstrueif this node shouldn't automatically be expanded in aDiffTreeViewer.booleanprotected voidSends out notification that a change has occurred on theICompareInput.Returns the ancestor side of this input.getId()Returns the first not-nullinput of this node.getImage()TheDiffElementimplementation of thisITypedInputmethod returnsnull.getLeft()Returns the left side of this input.getName()Returns the (non-null) name of the left or right side if they are identical.getRight()Returns the right side of this input.getType()TheDiffElementimplementation of thisITypedElementmethod returnsITypedElement.UNKNOWN_TYPE.inthashCode()voidUnregisters aICompareInputlistener.voidsetAncestor(ITypedElement ancestor) Sets the ancestor input to the given value.voidsetDontExpand(boolean dontExpand) Controls whether this node is not automatically expanded when displayed in aDiffTreeViewer.voidsetLeft(ITypedElement left) Sets the left input to the given value.voidsetRight(ITypedElement right) Sets the right input to the given value.Methods inherited from class org.eclipse.compare.structuremergeviewer.DiffContaineradd, findChild, getChildren, hasChildren, remove, removeToRootMethods inherited from class org.eclipse.compare.structuremergeviewer.DiffElementgetKind, getParent, setKind, setParentMethods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.eclipse.compare.structuremergeviewer.ICompareInputgetKindMethods inherited from interface org.eclipse.compare.structuremergeviewer.IDiffElementgetKind, getParent, setParent
- 
Constructor Details- 
DiffNodepublic DiffNode(IDiffContainer parent, int kind, ITypedElement ancestor, ITypedElement left, ITypedElement right) Creates a newDiffNodeand initializes with the given values.- Parameters:
- parent- under which the new container is added as a child or- null
- kind- of difference (defined in- Differencer)
- ancestor- the common ancestor input to a compare
- left- the left input to a compare
- right- the right input to a compare
 
- 
DiffNodeCreates a newDiffNodewith diff kindDifferencer.CHANGEand initializes with the given values.- Parameters:
- left- the left input to a compare
- right- the right input to a compare
 
- 
DiffNodeCreates a newDiffNodeand initializes with the given values.- Parameters:
- kind- of difference (defined in- Differencer)
- ancestor- the common ancestor input to a compare
- left- the left input to a compare
- right- the right input to a compare
 
- 
DiffNodepublic DiffNode(int kind) Creates a newDiffNodewith the given diff kind.- Parameters:
- kind- of difference (defined in- Differencer)
 
- 
DiffNodeCreates a newDiffNodeand initializes with the given values.- Parameters:
- parent- under which the new container is added as a child or- null
- kind- of difference (defined in- Differencer)
 
 
- 
- 
Method Details- 
addCompareInputChangeListenerRegisters a listener for changes of thisICompareInput. Has no effect if an identical listener is already registered.- Specified by:
- addCompareInputChangeListenerin interface- ICompareInput
- Parameters:
- listener- the listener to add
 
- 
removeCompareInputChangeListenerUnregisters aICompareInputlistener. Has no effect if listener is not registered.- Specified by:
- removeCompareInputChangeListenerin interface- ICompareInput
- Parameters:
- listener- the listener to remove
 
- 
fireChangeprotected void fireChange()Sends out notification that a change has occurred on theICompareInput.
- 
dontExpandpublic boolean dontExpand()Returnstrueif this node shouldn't automatically be expanded in aDiffTreeViewer.- Returns:
- trueif node shouldn't automatically be expanded
 
- 
setDontExpandpublic void setDontExpand(boolean dontExpand) Controls whether this node is not automatically expanded when displayed in aDiffTreeViewer.- Parameters:
- dontExpand- if- truethis node is not automatically expanded in- DiffTreeViewer
 
- 
getIdReturns the first not-nullinput of this node. Method checks the three inputs in the order: ancestor, right, left.- Returns:
- the first not-nullinput of this node
 
- 
getNameReturns 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 interface- ICompareInput
- Specified by:
- getNamein interface- ITypedElement
- Returns:
- the name of this node.
 
- 
getImageDescription copied from class:DiffElementTheDiffElementimplementation of thisITypedInputmethod returnsnull. Subclasses may re-implement to provide an image for this element.- Specified by:
- getImagein interface- ICompareInput
- Specified by:
- getImagein interface- ITypedElement
- Overrides:
- getImagein class- DiffElement
- Returns:
- null.
 
- 
getTypeDescription copied from class:DiffElementTheDiffElementimplementation of thisITypedElementmethod returnsITypedElement.UNKNOWN_TYPE. Subclasses may re-implement to provide a type for this element.- Specified by:
- getTypein interface- ITypedElement
- Overrides:
- getTypein class- DiffElement
- Returns:
- ITypedElement.UNKNOWN_TYPE.
 
- 
setAncestorSets the ancestor input to the given value.- Parameters:
- ancestor- the new value for the ancestor input
- Since:
- 3.0
 
- 
getAncestorDescription copied from interface:ICompareInputReturns the ancestor side of this input. Returnsnullif this input has no ancestor or in the two-way compare case.- Specified by:
- getAncestorin interface- ICompareInput
- Returns:
- the ancestor of this input, or null
 
- 
setLeftSets the left input to the given value.- Parameters:
- left- the new value for the left input
 
- 
getLeftDescription copied from interface:ICompareInputReturns the left side of this input. Returnsnullif there is no left side (deletion or addition).- Specified by:
- getLeftin interface- ICompareInput
- Returns:
- the left side of this input, or null
 
- 
setRightSets the right input to the given value.- Parameters:
- right- the new value for the right input
 
- 
getRightDescription copied from interface:ICompareInputReturns the right side of this input. Returnsnullif there is no right side (deletion or addition).- Specified by:
- getRightin interface- ICompareInput
- Returns:
- the right side of this input, or null
 
- 
copypublic void copy(boolean leftToRight) Description copied from interface:ICompareInputCopy one side (source) to the other side (destination) depending on the value ofleftToRight. 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 interface- ICompareInput
- Parameters:
- leftToRight- if- truethe left side is copied to the right side. If- falsethe right side is copied to the left side
 
- 
 if the source side is 
- 
hashCodepublic int hashCode()
- 
equals
 
-