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
FieldsModifier and TypeFieldDescriptionstatic final intConstant 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(IPath path, IDiffVisitor visitor, int depth) Accepts the given visitor.voidAdd the givenIDiffto the tree.voidaddDiffChangeListener(IDiffChangeListener listener) Add a listener to the tree.voidThis method is used to obtain a lock on the set which ensures thread safety and batches change notification.voidclear()Clear the contents of the setvoidclearBusy(IProgressMonitor monitor) Clear all busy properties in this tree.longcountFor(int state, int mask) Return the number of out-of-sync elements in the given set whose synchronization state matches the given mask.voidendInput(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, ornullif 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.booleangetProperty(IPath path, int property) Return the value of the property for the given path.booleanhasMatchingDiffs(IPath path, FastDiffFilter filter) Return whether the this diff tree contains any diffs that match the given filter at of below the given path.booleanisEmpty()Return whether the set is empty.voidRemove the given local resource from the set.voidremoveDiffChangeListener(IDiffChangeListener listener) Remove the listener from the tree.voidreportError(IStatus status) Report to any listeners that an error has occurred while populating the set.voidsetBusy(IDiff[] diffs, IProgressMonitor monitor) Set the given diff nodes and all their parents to busyvoidsetPropertyToRoot(IDiff node, int property, boolean value) intsize()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:IDiffTreeAdd 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:
addDiffChangeListenerin interfaceIDiffTree- Parameters:
listener- the listener to be added
-
removeDiffChangeListener
Description copied from interface:IDiffTreeRemove the listener from the tree. Removing a listener that is not registered has no effect.- Specified by:
removeDiffChangeListenerin interfaceIDiffTree- Parameters:
listener- the listener to be removed
-
accept
Description copied from interface:IDiffTreeAccepts the given visitor. The only kinds of deltas visited areADDED,REMOVED, andCHANGED. The visitor'svisitmethod 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:IDiffTreeReturns the delta identified by the given path, ornullif 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:IDiffTreeReturns 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:
getChildrenin 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:IDiffTreeReturn whether the set is empty. -
add
Add the givenIDiffto 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 whenendInputis 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 whenendInputis 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
endInputshould be done in a finally block as illustrated in the following code snippet.try { set.beginInput(); // do stuff } finally { set.endInput(progress); }Calls to
beginInputandendInputcan 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:IDiffTreeReturn 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:IDiffTreeReturn the number of diffs contained in the tree. -
setPropertyToRoot
-
getProperty
Description copied from interface:IDiffTreeReturn the value of the property for the given path.- Specified by:
getPropertyin interfaceIDiffTree- Parameters:
path- the pathproperty- the property- Returns:
- the value of the property
-
setBusy
Description copied from interface:IDiffTreeSet the given diff nodes and all their parents to busy -
clearBusy
Description copied from interface:IDiffTreeClear all busy properties in this tree. -
hasMatchingDiffs
Description copied from interface:IDiffTreeReturn whether the this diff tree contains any diffs that match the given filter at of below the given path.- Specified by:
hasMatchingDiffsin 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.
-