org.eclipse.team.core.diff.provider
Class DiffTree
java.lang.Object
org.eclipse.team.core.diff.provider.DiffTree
-
All Implemented Interfaces:
-
IDiffTree
-
Direct Known Subclasses:
-
ResourceDiffTree
-
public class DiffTree
- extends
Object
- implements
IDiffTree
Implementation of
IDiffTree
.
-
Since:
- 3.2
-
Restriction:
- This class is not intended to be subclassed by clients. Clients can
instead use
DiffTree
.
Field Summary
|
static int
|
START_CLIENT_PROPERTY_RANGE
Constant that indicates the start of the property value
range that clients can use when storing properties in this tree. |
Constructor Summary
|
DiffTree
()
Create an empty diff tree. |
Method Summary
|
void
|
accept
(
IPath path,
IDiffVisitor visitor,
int depth)
Accepts the given visitor. |
void
|
add
(
IDiff delta)
Add the given
IDiff to the tree. |
void
|
addDiffChangeListener
(
IDiffChangeListener listener)
Add a listener to the tree. |
void
|
beginInput
()
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 set |
void
|
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. |
IDiff
|
getDiff
(
IPath path)
Returns the delta identified by the given path,
or null 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
(
IPath path)
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 busy |
void
|
setPropertyToRoot
(
IDiff node,
int property,
boolean value)
|
int
|
size
()
Return the number of diffs contained in the tree. |
Methods inherited from class java.lang.
Object
|
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
|
START_CLIENT_PROPERTY_RANGE
public static final int START_CLIENT_PROPERTY_RANGE
- Constant that indicates the start of the property value
range that clients can use when storing properties in this tree.
-
See Also:
-
Constant Field Values
DiffTree
public DiffTree()
- Create an empty diff tree.
addDiffChangeListener
public void addDiffChangeListener(
IDiffChangeListener listener)
-
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 interface
IDiffTree
-
-
Parameters:
-
listener
- the listener to be added
removeDiffChangeListener
public void removeDiffChangeListener(
IDiffChangeListener listener)
-
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 interface
IDiffTree
-
-
Parameters:
-
listener
- the listener to be removed
accept
public void accept(
IPath path,
IDiffVisitor visitor,
int depth)
-
Description copied from interface:
IDiffTree
- Accepts the given visitor. The only kinds of deltas visited are
ADDED
, REMOVED
, and CHANGED
.
The visitor's visit
method is called with the given delta
if applicable. If the visitor returns true
, any of the
delta's children in this tree are also visited.
-
-
Specified by:
-
accept
in interface
IDiffTree
-
-
Parameters:
-
path
- the path to start the visit in the tree -
visitor
- the visitor -
depth
- the depth to visit -
See Also:
-
IDiffVisitor.visit(IDiff)
getDiff
public
IDiff getDiff(
IPath path)
-
Description copied from interface:
IDiffTree
- Returns the delta identified by the given path,
or
null
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)
.
-
-
Specified by:
-
getDiff
in interface
IDiffTree
-
-
Parameters:
-
path
- the path of the desired delta
-
Returns:
- the delta, or
null
if no such
delta exists
getChildren
public
IPath[] getChildren(
IPath path)
-
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 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
isEmpty
public boolean isEmpty()
-
Description copied from interface:
IDiffTree
- Return whether the set is empty.
-
-
Specified by:
-
isEmpty
in interface
IDiffTree
-
-
Returns:
- whether the set is empty
add
public void add(
IDiff delta)
- Add the given
IDiff
to the tree. A change event will
be generated unless the call to this method is nested in between calls
to beginInput()
and endInput(IProgressMonitor)
in which case the event for this addition and any other sync set
change will be fired in a batched event when endInput
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 within beginInput/endInput
.
-
-
-
Parameters:
-
delta
- the delta to be added to this set.
remove
public void remove(
IPath path)
- 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
to
beginInput()
and endInput(IProgressMonitor)
in which case the event for this removal and any other sync set
change will be fired in a batched event when endInput
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 within beginInput/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 an
org.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
and endInput
can be nested and must be matched.
-
-
endInput
public void endInput(
IProgressMonitor monitor)
- 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:
-
beginInput()
getPaths
public
IPath[] getPaths()
- Return the paths in this tree that contain diffs.
-
-
-
Returns:
- the paths in this tree that contain diffs.
getDiffs
public
IDiff[] 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);
-
-
Specified by:
-
countFor
in interface
IDiffTree
-
-
Parameters:
-
state
- the sync state -
mask
- the sync state mask
-
Returns:
- the number of matching resources in the set.
size
public int size()
-
Description copied from interface:
IDiffTree
- Return the number of diffs contained in the tree.
-
-
Specified by:
-
size
in interface
IDiffTree
-
-
Returns:
- the number of diffs contained in the tree
setPropertyToRoot
public void setPropertyToRoot(
IDiff node,
int property,
boolean value)
-
-
getProperty
public boolean getProperty(
IPath path,
int property)
-
Description copied from interface:
IDiffTree
- Return the value of the property for the given path.
-
-
Specified by:
-
getProperty
in interface
IDiffTree
-
-
Parameters:
-
path
- the path -
property
- the property
-
Returns:
- the value of the property
setBusy
public void setBusy(
IDiff[] diffs,
IProgressMonitor monitor)
-
Description copied from interface:
IDiffTree
- Set the given diff nodes and all their parents to busy
-
-
Specified by:
-
setBusy
in interface
IDiffTree
-
-
Parameters:
-
diffs
- the busy diffs -
monitor
- a progress monitor or null
if progress indication
is not required
clearBusy
public void clearBusy(
IProgressMonitor monitor)
-
Description copied from interface:
IDiffTree
- Clear all busy properties in this tree.
-
-
Specified by:
-
clearBusy
in interface
IDiffTree
-
-
Parameters:
-
monitor
- a progress monitor or null
if progress indication
is not required
hasMatchingDiffs
public boolean hasMatchingDiffs(
IPath path,
FastDiffFilter filter)
-
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 interface
IDiffTree
-
-
Parameters:
-
path
- the path -
filter
- the diff node filter
-
Returns:
- whether the given diff tree contains any deltas that match the given filter
reportError
public void reportError(
IStatus status)
- 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.
Guidelines for using Eclipse APIs.
Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.