Class DiffTree
- All Implemented Interfaces:
IDiffTree
- Direct Known Subclasses:
ResourceDiffTree
IDiffTree
.- Since:
- 3.2
- Restriction:
- This class is not intended to be subclassed by clients. Clients can
instead use
DiffTree
.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Constant that indicates the start of the property value range that clients can use when storing properties in this tree.Fields inherited from interface org.eclipse.team.core.diff.IDiffTree
P_BUSY_HINT, P_HAS_DESCENDANT_CONFLICTS
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(IPath path, IDiffVisitor visitor, int depth) Accepts the given visitor.void
Add the givenIDiff
to the tree.void
addDiffChangeListener
(IDiffChangeListener listener) Add a listener to the tree.void
This method is used to obtain a lock on the set which ensures thread safety and batches change notification.void
clear()
Clear the contents of the setvoid
clearBusy
(IProgressMonitor monitor) Clear all busy properties in this tree.long
countFor
(int state, int mask) Return the number of out-of-sync elements in the given set whose synchronization state matches the given mask.void
endInput
(IProgressMonitor monitor) This method is used to release the lock on this set.IPath[]
getChildren
(IPath path) Returns the child paths of the given path that either point to a sync delta or have a descendant path that points to a sync delta.Returns the delta identified by the given path, ornull
if there is no delta at that path.IDiff[]
getDiffs()
Return all the diffs contained in this diff tree.IPath[]
getPaths()
Return the paths in this tree that contain diffs.boolean
getProperty
(IPath path, int property) Return the value of the property for the given path.boolean
hasMatchingDiffs
(IPath path, FastDiffFilter filter) Return whether the this diff tree contains any diffs that match the given filter at of below the given path.boolean
isEmpty()
Return whether the set is empty.void
Remove the given local resource from the set.void
removeDiffChangeListener
(IDiffChangeListener listener) Remove the listener from the tree.void
reportError
(IStatus status) Report to any listeners that an error has occurred while populating the set.void
setBusy
(IDiff[] diffs, IProgressMonitor monitor) Set the given diff nodes and all their parents to busyvoid
setPropertyToRoot
(IDiff node, int property, boolean value) int
size()
Return the number of diffs contained in the tree.
-
Field Details
-
START_CLIENT_PROPERTY_RANGE
public static final int START_CLIENT_PROPERTY_RANGEConstant that indicates the start of the property value range that clients can use when storing properties in this tree.- See Also:
-
-
Constructor Details
-
DiffTree
public DiffTree()Create an empty diff tree.
-
-
Method Details
-
addDiffChangeListener
Description copied from interface:IDiffTree
Add a listener to the tree. The listener will be informed of any changes in the tree. Registering a listener that is already registered will have no effects.- Specified by:
addDiffChangeListener
in interfaceIDiffTree
- Parameters:
listener
- the listener to be added
-
removeDiffChangeListener
Description copied from interface:IDiffTree
Remove the listener from the tree. Removing a listener that is not registered has no effect.- Specified by:
removeDiffChangeListener
in interfaceIDiffTree
- Parameters:
listener
- the listener to be removed
-
accept
Description copied from interface:IDiffTree
Accepts the given visitor. The only kinds of deltas visited areADDED
,REMOVED
, andCHANGED
. The visitor'svisit
method is called with the given delta if applicable. If the visitor returnstrue
, any of the delta's children in this tree are also visited. -
getDiff
Description copied from interface:IDiffTree
Returns the delta identified by the given path, ornull
if there is no delta at that path. The supplied path may be absolute or relative; in either case, it is interpreted as relative to the workspace. Trailing separators are ignored.This method only returns a delta if there is a change at the given path. To know if there are deltas in descendent paths, clients should class
IDiffTree.getChildren(IPath)
. -
getChildren
Description copied from interface:IDiffTree
Returns the child paths of the given path that either point to a sync delta or have a descendant path that points to a sync delta. Returns an empty array if there are no sync deltas that are descendents of the given path.- Specified by:
getChildren
in interfaceIDiffTree
- Returns:
- the child paths of the given path that either point to a sync delta or have a descendant path that points to a sync delta
-
isEmpty
public boolean isEmpty()Description copied from interface:IDiffTree
Return whether the set is empty. -
add
Add the givenIDiff
to the tree. A change event will be generated unless the call to this method is nested in between calls tobeginInput()
andendInput(IProgressMonitor)
in which case the event for this addition and any other sync set change will be fired in a batched event whenendInput
is invoked.Invoking this method outside of the above mentioned block will result in the
endInput(IProgressMonitor)
being invoked with a null progress monitor. If responsiveness is required, the client should always nest sync set modifications withinbeginInput/endInput
.- Parameters:
delta
- the delta to be added to this set.
-
remove
Remove the given local resource from the set. A change event will be generated unless the call to this method is nested in between calls tobeginInput()
andendInput(IProgressMonitor)
in which case the event for this removal and any other sync set change will be fired in a batched event whenendInput
is invoked.Invoking this method outside of the above mentioned block will result in the
endInput(IProgressMonitor)
being invoked with a null progress monitor. If responsiveness is required, the client should always nest sync set modifications withinbeginInput/endInput
.- Parameters:
path
- the path to remove
-
clear
public void clear()Clear the contents of the set -
beginInput
public void beginInput()This method is used to obtain a lock on the set which ensures thread safety and batches change notification. If the set is locked by another thread, the calling thread will block until the lock becomes available. This method uses anorg.eclipse.core.runtime.jobs.ILock
.It is important that the lock is released after it is obtained. Calls to
endInput
should be done in a finally block as illustrated in the following code snippet.try { set.beginInput(); // do stuff } finally { set.endInput(progress); }
Calls to
beginInput
andendInput
can be nested and must be matched. -
endInput
This method is used to release the lock on this set. The progress monitor is needed to allow listeners to perform long-running operations is response to the set change. The lock is held while the listeners are notified so listeners must be cautious in order to avoid deadlock.- Parameters:
monitor
- a progress monitor- See Also:
-
getPaths
Return the paths in this tree that contain diffs.- Returns:
- the paths in this tree that contain diffs.
-
getDiffs
Return all the diffs contained in this diff tree.- Returns:
- all the diffs contained in this diff tree
-
countFor
public long countFor(int state, int mask) Description copied from interface:IDiffTree
Return the number of out-of-sync elements in the given set whose synchronization state matches the given mask. A state of 0 assumes a count of all changes. A mask of 0 assumes a direct match of the given state.For example, this will return the number of outgoing changes in the set:
long outgoing = countFor(IThreeWayDiff.OUTGOING, IThreeWayDiff.DIRECTION_MASK);
-
size
public int size()Description copied from interface:IDiffTree
Return the number of diffs contained in the tree. -
setPropertyToRoot
-
getProperty
Description copied from interface:IDiffTree
Return the value of the property for the given path.- Specified by:
getProperty
in interfaceIDiffTree
- Parameters:
path
- the pathproperty
- the property- Returns:
- the value of the property
-
setBusy
Description copied from interface:IDiffTree
Set the given diff nodes and all their parents to busy -
clearBusy
Description copied from interface:IDiffTree
Clear all busy properties in this tree. -
hasMatchingDiffs
Description copied from interface:IDiffTree
Return whether the this diff tree contains any diffs that match the given filter at of below the given path.- Specified by:
hasMatchingDiffs
in interfaceIDiffTree
- Parameters:
path
- the pathfilter
- the diff node filter- Returns:
- whether the given diff tree contains any deltas that match the given filter
-
reportError
Report to any listeners that an error has occurred while populating the set. Listeners will be notified that an error occurred and can react accordingly.- Parameters:
status
- the status that describes the error that occurred.
-