|
Eclipse Platform Release 3.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.team.core.synchronize.SyncInfoSet
A dynamic collection of SyncInfo
objects that provides
change notification to registered listeners. Batching of change notifications
can be accomplished using the beginInput/endInput
methods.
SyncInfoTree
,
SyncInfo
,
ISyncInfoSetChangeListener
Constructor Summary | |
SyncInfoSet()
Create an empty set. |
|
SyncInfoSet(SyncInfo[] infos)
Create a SyncInfoSet containing the given SyncInfo
instances. |
Method Summary | |
void |
add(SyncInfo info)
Add the given SyncInfo to the set. |
void |
addAll(SyncInfoSet set)
Add all the syncinfo from the given set to this set. |
void |
addError(ITeamStatus status)
Add the error to the set. |
void |
addSyncSetChangedListener(ISyncInfoSetChangeListener listener)
Registers the given listener for sync info set notifications. |
void |
beginInput()
This method is used to obtain a lock on the set which ensures thread safety and batches change notification. |
void |
clear()
Reset the sync set so it is empty. |
void |
connect(ISyncInfoSetChangeListener listener,
IProgressMonitor monitor)
Connect the listener to the sync set in such a fashion that the listener will be connected the the sync set using addChangeListener
and issued a reset event. |
long |
countFor(int kind,
int mask)
Return the number of out-of-sync resources in the given set whose sync kind matches the given kind and mask (e.g. |
protected org.eclipse.team.internal.core.subscribers.SyncSetChangedEvent |
createEmptyChangeEvent()
Create an empty change event. |
void |
endInput(IProgressMonitor monitor)
This method is used to release the lock on this set. |
protected org.eclipse.team.internal.core.subscribers.SyncSetChangedEvent |
getChangeEvent()
Return the change event that is accumulating the changes to the set. |
ITeamStatus[] |
getErrors()
Return an array of the errors the occurred while populating this set. |
protected ISyncInfoSetChangeListener[] |
getListeners()
Return a copy of all the listeners registered with this set |
SyncInfo[] |
getNodes(FastSyncInfoFilter filter)
Return all nodes in this set that match the given filter. |
IResource[] |
getResources()
Return all out-of-sync resources contained in this set. |
SyncInfo |
getSyncInfo(IResource resource)
Return the SyncInfo for the given resource or null
if the resource is not contained in the set. |
SyncInfo[] |
getSyncInfos()
Return an array of SyncInfo for all out-of-sync resources that are contained by the set. |
boolean |
hasConflicts()
Returns true if there are any conflicting nodes in the set, and
false otherwise. |
boolean |
hasIncomingChanges()
Returns true if this sync set has incoming changes.
|
boolean |
hasNodes(FastSyncInfoFilter filter)
Indicate whether the set has nodes matching the given filter. |
boolean |
hasOutgoingChanges()
Returns true if this sync set has outgoing changes.
|
protected void |
internalAdd(SyncInfo info)
Add the SyncInfo to the set, replacing any previously existing one. |
protected SyncInfo |
internalRemove(IResource resource)
Remove the resource from the set, updating all internal data structures. |
boolean |
isEmpty()
Return whether the set is empty. |
void |
rejectNodes(FastSyncInfoFilter filter)
Removes all nodes from this set that match the given filter leaving those that do not match the filter. |
void |
remove(IResource resource)
Remove the given local resource from the set. |
void |
removeAll(IResource[] resources)
Remove all the given resources from the set. |
void |
removeConflictingNodes()
Removes all conflicting nodes from this set. |
void |
removeIncomingNodes()
Removes all incoming nodes from this set. |
void |
removeOutgoingNodes()
Removes all outgoing nodes from this set. |
void |
removeSyncSetChangedListener(ISyncInfoSetChangeListener listener)
Deregisters the given listener for participant notifications. |
protected void |
resetChanges()
Reset the changes accumulated so far by this set. |
void |
selectNodes(FastSyncInfoFilter filter)
Removes all nodes from this set that do not match the given filter leaving only those that do match the filter. |
int |
size()
Return the number of out-of-sync resources contained in this set. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public SyncInfoSet()
public SyncInfoSet(SyncInfo[] infos)
SyncInfoSet
containing the given SyncInfo
instances.
infos
- the SyncInfo
instances to be contained by this setMethod Detail |
public SyncInfo[] getSyncInfos()
SyncInfo
for all out-of-sync resources that are contained by the set.
SyncInfo
public IResource[] getResources()
getSyncInfos()
to determine the resources contained in the set.
Subclasses may override to optimize.
public SyncInfo getSyncInfo(IResource resource)
SyncInfo
for the given resource or null
if the resource is not contained in the set.
resource
- the resource
SyncInfo
for the resource or null
if
the resource is in-sync or doesn't have synchronization information in this set.public int size()
countFor(int, int)
public long countFor(int kind, int mask)
(SyncInfo#getKind() & mask) == kind
).
For example, this will return the number of outgoing changes in the set:
long outgoing = countFor(SyncInfo.OUTGOING, SyncInfo.DIRECTION_MASK);
kind
- the sync kindmask
- the sync kind mask
public boolean hasConflicts()
true
if there are any conflicting nodes in the set, and
false
otherwise.
true
if there are any conflicting nodes in the set, and
false
otherwise.public boolean isEmpty()
true
if the set is emptyprotected void internalAdd(SyncInfo info)
SyncInfo
to the set, replacing any previously existing one.
info
- the new SyncInfo
protected SyncInfo internalRemove(IResource resource)
resource
- the resource to be removed
SyncInfo
that was just removedpublic void addSyncSetChangedListener(ISyncInfoSetChangeListener listener)
listener
- listener to registerpublic void removeSyncSetChangedListener(ISyncInfoSetChangeListener listener)
listener
- listener to deregisterpublic void clear()
public void connect(ISyncInfoSetChangeListener listener, IProgressMonitor monitor)
addChangeListener
and issued a reset event. This is done to provide a means of connecting to the
sync set and initializing a model based on the sync set without worrying about
missing events.
The reset event may be done in the context of this method invocation or may be
done in another thread at the discretion of the SyncInfoSet
implementation.
Disconnecting is done by calling removeChangeListener
. Once disconnected,
a listener can reconnect to be reinitialized.
listener
- the listener that should be connected to this setmonitor
- a progress monitorpublic void add(SyncInfo info)
SyncInfo
to 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 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
.
info
- the sync info to be added to this set.public void addAll(SyncInfoSet set)
set
- the set whose sync info should be added to this setpublic void remove(IResource resource)
resource
- the local resource to removepublic void removeAll(IResource[] resources)
resources
- the resources to be removedpublic void removeConflictingNodes()
public void removeOutgoingNodes()
public void removeIncomingNodes()
public boolean hasNodes(FastSyncInfoFilter filter)
filter
- a sync info filterpublic void selectNodes(FastSyncInfoFilter filter)
filter
- a sync info filterpublic void rejectNodes(FastSyncInfoFilter filter)
filter
- a sync info filterpublic SyncInfo[] getNodes(FastSyncInfoFilter filter)
filter
- a sync info filterpublic boolean hasIncomingChanges()
true
if this sync set has incoming changes.
Note that conflicts are not considered to be incoming changes.
true
if this sync set has incoming changes.public boolean hasOutgoingChanges()
true
if this sync set has outgoing changes.
Note that conflicts are not considered to be outgoing changes.
true
if this sync set has outgoing changes.public void beginInput()
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.
public void endInput(IProgressMonitor monitor)
protected void resetChanges()
protected org.eclipse.team.internal.core.subscribers.SyncSetChangedEvent createEmptyChangeEvent()
protected ISyncInfoSetChangeListener[] getListeners()
protected org.eclipse.team.internal.core.subscribers.SyncSetChangedEvent getChangeEvent()
public void addError(ITeamStatus status)
SyncInfo
for one
or more resources due to an exception or some other problem. Listeners
will be notified that an error occurred and can react accordingly.
Only one error can be associated with a resource (which is obtained from
the ITeamStatus
). It is up to the
client populating the set to ensure that the error associated with a
resource contains all relevent information.
The error will remain in the set until the set is reset.
status
- the status that describes the error that occurred.public ITeamStatus[] getErrors()
|
Eclipse Platform Release 3.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Guidelines for using Eclipse APIs.
Copyright (c) IBM Corp. and others 2000, 2004. All rights reserved.