Class SubscriberParticipant
- All Implemented Interfaces:
EventListener
,IAdaptable
,IExecutableExtension
,IPropertyChangeListener
,ISynchronizeParticipant
Subscriber
. It maintains a dynamic collection of all out-of-sync resources
by listening to workspace resource changes and remote changes thus creating a live view of
changes in the workspace.
The subscriber can be configured to be synchronized in the background based on a schedule. This effectively refreshes the subscriber and updates the dynamic sync set.
Subclasses will typically want to override the following methods:
- initializeConfiguration: participants can add toolbar actions, configure the context menu, decorator.
- saveState and init: persist settings between sessions.
- Since:
- 3.0
-
Field Summary
Fields inherited from class org.eclipse.team.ui.synchronize.AbstractSynchronizeParticipant
configElement, P_PINNED, P_SCHEDULED
Fields inherited from interface org.eclipse.team.ui.synchronize.ISynchronizeParticipant
P_CONTENT
-
Constructor Summary
ConstructorDescriptionConstructor initializes the schedule.Constructor which should be called when creating a participant whose resources are to be scoped. -
Method Summary
Modifier and TypeMethodDescriptionfinal IPageBookViewPage
createPage
(ISynchronizePageConfiguration configuration) Creates and returns a new page for this synchronize participant.void
dispose()
Disposes of this synchronize participant and is called to free the resources associated with a participant.<T> T
getAdapter
(Class<T> adapter) Returns an object which is an instance of the given class associated with this object.protected String
Deprecated.protected String
getLongTaskName
(IResource[] resources) Returns the long task name to describe the behavior of the refresh operation to the user.static SubscriberParticipant
getMatchingParticipant
(String ID, IResource[] resources) Returns a participant that matches the given resource scopinggetName()
Returns the name of this synchronize participant.org.eclipse.team.internal.ui.synchronize.SubscriberRefreshSchedule
Returns the resources supervised by this participant.getScope()
Return the scope that defines the resources displayed by this participant.protected final String
Return the name of the participant as specified in the plugin manifest file.protected String
Returns the short task name (e.g. no more than 25 characters) to describe the behavior of the refresh operation to the user.Return theSubscriber
associated with this this participant.org.eclipse.team.internal.core.subscribers.SubscriberSyncInfoCollector
Return theSubscriberSyncInfoCollector
for the participant.Returns theSyncInfoTree
for this participant.void
Classes that are persisted must override this method and perform the following initialization.protected void
initializeConfiguration
(ISynchronizePageConfiguration configuration) This method is invoked after a page configuration is created but before it is returned by thecreatePageConfiguration
method.void
Notification that a property has changed.final void
refresh
(IResource[] resources, String shortTaskName, String longTaskName, IWorkbenchSite site) Refresh a participant in the background the result of the refresh are shown in the progress view.final void
refreshInDialog
(Shell shell, IResource[] resources, String jobName, String taskName, ISynchronizePageConfiguration configuration, IWorkbenchSite site) Refresh this participants synchronization state and displays the result in a model dialog.final IStatus
refreshNow
(IResource[] resources, String taskName, IProgressMonitor monitor) Refresh a participant.void
reset()
Reset the sync set of the participant by repopulating it from scratch.void
run
(IWorkbenchPart part) Runs the participants action.void
Saves the participants object state within the memento.void
setRefreshSchedule
(org.eclipse.team.internal.ui.synchronize.SubscriberRefreshSchedule schedule) protected void
setSubscriber
(Subscriber subscriber) Subclasses must call this method to initialize the participant.protected void
setSyncInfoFilter
(SyncInfoFilter filter) Provide a filter that is used to filter the contents of the sync info set for the participant.protected void
validateConfiguration
(ISynchronizePageConfiguration configuration) This method is invoked before the given configuration is used to create the page (seecreatePage(ISynchronizePageConfiguration)
).Methods inherited from class org.eclipse.team.ui.synchronize.AbstractSynchronizeParticipant
addPropertyChangeListener, createPageConfiguration, doesSupportSynchronize, equals, firePropertyChange, getHelpContextId, getId, getImageDescriptor, getPreferencePages, getSecondaryId, hashCode, isPinned, isViewerContributionsSupported, pinned, prepareCompareInput, removePropertyChangeListener, setImageDescriptor, setInitializationData, setInitializationData, setName, setPinned, setSecondaryId
-
Constructor Details
-
SubscriberParticipant
public SubscriberParticipant()Constructor initializes the schedule. Subclasses must call this method. -
SubscriberParticipant
Constructor which should be called when creating a participant whose resources are to be scoped.- Parameters:
scope
- a synchronize scope
-
-
Method Details
-
createPage
Description copied from interface:ISynchronizeParticipant
Creates and returns a new page for this synchronize participant. The page is displayed using the parameters from the configuration. For example, the configuration defines the context in which the page is shown, via theISynchronizePageSite
.- Specified by:
createPage
in interfaceISynchronizeParticipant
- Parameters:
configuration
- used to initialize the page- Returns:
- a page book view page representation of this synchronize participant
-
getResources
Returns the resources supervised by this participant. It will either be the roots of the subscriber or the resource scope provided when the subscriber was set.- Returns:
- the resources supervised by this participant.
-
refreshInDialog
public final void refreshInDialog(Shell shell, IResource[] resources, String jobName, String taskName, ISynchronizePageConfiguration configuration, IWorkbenchSite site) Refresh this participants synchronization state and displays the result in a model dialog.- Parameters:
shell
- parent shell for the dialogresources
- the resources to be refreshed.jobName
- the job name ornull
taskName
- the task name to be shown to the userconfiguration
- the configurationsite
- the site in which to run the refresh
-
refresh
public final void refresh(IResource[] resources, String shortTaskName, String longTaskName, IWorkbenchSite site) Refresh a participant in the background the result of the refresh are shown in the progress view. Refreshing can also be considered synchronizing, or refreshing the synchronization state. Basically this is a long running operation that will update the participants sync info sets with new changes detected on the server. Either or both of theshortTaskName
andlongTaskName
can benull
in which case, the default values for these are returned by the methodsgetShortTaskName()
andgetLongTaskName(IResource[])
will be used.- Parameters:
resources
- the resources to be refreshed.shortTaskName
- the taskName of the background job that will run the synchronize ornull
if the default job name is desired.longTaskName
- the taskName of the progress monitor running the synchronize ornull
if the default job name is desired.site
- the workbench site the synchronize is running from. This can be used to notify the site that a job is running.
-
refreshNow
Refresh a participant. The returned status describes the result of the refresh.- Parameters:
resources
- the resources to be refreshed.taskName
- the task name to be shown to the usermonitor
- monitor for job progress- Returns:
- a status
-
dispose
public void dispose()Description copied from interface:ISynchronizeParticipant
Disposes of this synchronize participant and is called to free the resources associated with a participant. When a participant is added to theISynchronizeManager
this method is called when the manager is shutdown or the participant is removed from the manager.Within this method a participant may release any resources, fonts, images, etc. held by this part. It is also very important to remove all listeners.
Clients should not call this method (the synchronize manager calls this method at appropriate times).
- Specified by:
dispose
in interfaceISynchronizeParticipant
-
getName
Description copied from interface:ISynchronizeParticipant
Returns the name of this synchronize participant. This name is displayed to the user.- Specified by:
getName
in interfaceISynchronizeParticipant
- Overrides:
getName
in classAbstractSynchronizeParticipant
- Returns:
- the name of this synchronize participant
-
getShortName
Return the name of the participant as specified in the plugin manifest file. This method is provided to give access to this name since it is masked by thegetName()
method defined in this class.- Returns:
- the name of the participant as specified in the plugin manifest file
- Since:
- 3.1
-
getSyncInfoSet
Returns theSyncInfoTree
for this participant. This set contains the out-of-sync resources supervised by this participant.- Returns:
- the sync info set that contains the out-of-sync resources for this participant.
-
getSubscriber
Return theSubscriber
associated with this this participant. This method will only returnnull
if the participant has not been initialized yet.- Returns:
- the
Subscriber
associated with this this participant.
-
getMatchingParticipant
Returns a participant that matches the given resource scoping- Parameters:
ID
- the type id of participants to matchresources
- the resources to match in the scope- Returns:
- a participant that matches the given resource scoping
-
propertyChange
Description copied from interface:IPropertyChangeListener
Notification that a property has changed.This method gets called when the observed object fires a property change event.
- Specified by:
propertyChange
in interfaceIPropertyChangeListener
- Parameters:
event
- the property change event object describing which property changed and how
-
init
Description copied from class:AbstractSynchronizeParticipant
Classes that are persisted must override this method and perform the following initialization.super.init(secondaryId, memento); try { ISynchronizeParticipantDescriptor descriptor = TeamUI.getSynchronizeManager().getParticipantDescriptor(PARTICIPANT_ID); setInitializationData(descriptor); } catch (CoreException e) { TeamUIPlugin.log(e); }
wherePARTICIPANT_ID
is the id of the participant as defined in the plugin manifest.- Specified by:
init
in interfaceISynchronizeParticipant
- Overrides:
init
in classAbstractSynchronizeParticipant
- Parameters:
secondaryId
- the secondayId of this participant instance ornull
if this participant doesn't support multiple instances.memento
- the participant state ornull
if there is no previous saved state- Throws:
PartInitException
- if this participant was not initialized successfully- See Also:
-
saveState
Description copied from interface:ISynchronizeParticipant
Saves the participants object state within the memento. This state will be available when the participant is restored viainit
.This method can be called multiple times during the lifetime of the participant object.
- Specified by:
saveState
in interfaceISynchronizeParticipant
- Overrides:
saveState
in classAbstractSynchronizeParticipant
- Parameters:
memento
- a memento to receive the object state
-
reset
public void reset()Reset the sync set of the participant by repopulating it from scratch. -
getSubscriberSyncInfoCollector
public org.eclipse.team.internal.core.subscribers.SubscriberSyncInfoCollector getSubscriberSyncInfoCollector()Return theSubscriberSyncInfoCollector
for the participant. This collector maintains the set of all out-of-sync resources for the subscriber.- Returns:
- the
SubscriberSyncInfoCollector
for this participant - Restriction:
- This method is not intended to be referenced by clients.
- Restriction:
- This method is not intended to be re-implemented or extended by clients.
-
setRefreshSchedule
public void setRefreshSchedule(org.eclipse.team.internal.ui.synchronize.SubscriberRefreshSchedule schedule) - Restriction:
- This method is not intended to be referenced by clients.
- Restriction:
- This method is not intended to be re-implemented or extended by clients.
-
getRefreshSchedule
public org.eclipse.team.internal.ui.synchronize.SubscriberRefreshSchedule getRefreshSchedule()- Restriction:
- This method is not intended to be referenced by clients.
- Restriction:
- This method is not intended to be re-implemented or extended by clients.
-
initializeConfiguration
Description copied from class:AbstractSynchronizeParticipant
This method is invoked after a page configuration is created but before it is returned by thecreatePageConfiguration
method. Subclasses can implement this method to tailor the configuration in ways appropriate to the participant.- Specified by:
initializeConfiguration
in classAbstractSynchronizeParticipant
- Parameters:
configuration
- the newly create page configuration
-
run
Description copied from interface:ISynchronizeParticipant
Runs the participants action. Typically this would be some action to refresh the synchronization state of the participant. This action is run from the global synchronize drop-down.- Specified by:
run
in interfaceISynchronizeParticipant
- Parameters:
part
- the part in which the action is run ornull
if the action is not being run in a workbench part.
-
getShortTaskName
Returns the short task name (e.g. no more than 25 characters) to describe the behavior of the refresh operation to the user. This is typically shown in the status line when this subscriber is refreshed in the background. When refreshed in the foreground, only the long task name is shown.- Returns:
- the short task name to show in the status line.
-
getLongTaskName
Deprecated.usegetLongTaskName(IResource[]) instead
Returns the long task name to describe the behavior of the refresh operation to the user. This is typically shown in the status line when this subscriber is refreshed in the background.- Returns:
- the long task name
-
getLongTaskName
Returns the long task name to describe the behavior of the refresh operation to the user. This is typically shown in the status line when this subscriber is refreshed in the background.- Parameters:
resources
- resources we are working on to get meaningful task name from- Returns:
- the long task name
- Since:
- 3.1
-
validateConfiguration
This method is invoked before the given configuration is used to create the page (seecreatePage(ISynchronizePageConfiguration)
). The configuration would have been initialized byinitializeConfiguration(ISynchronizePageConfiguration)
but may have also been tailored further. This method gives the participant a chance to validate those changes before the page is created.- Parameters:
configuration
- the page configuration that is about to be used to create a page.
-
setSubscriber
Subclasses must call this method to initialize the participant. Typically this method is called ininit(String, IMemento)
. This method will initialize the sync info collector.- Parameters:
subscriber
- the subscriber to associate with this participant.
-
setSyncInfoFilter
Provide a filter that is used to filter the contents of the sync info set for the participant. Normally, all out-of-sync resources from the subscriber will be included in the participant's set. However, a filter can be used to exclude some of these out-of-sync resources, if desired.Subclasses can invoke this method any time after
setSubscriber
has been invoked.- Parameters:
filter
- a sync info filter
-
getScope
Return the scope that defines the resources displayed by this participant.- Returns:
- Returns the scope.
-
getAdapter
Description copied from class:PlatformObject
Returns an object which is an instance of the given class associated with this object. Returnsnull
if no such object can be found.This implementation of the method declared by
IAdaptable
passes the request along to the platform's adapter manager; roughlyPlatform.getAdapterManager().getAdapter(this, adapter)
. Subclasses may override this method (however, if they do so, they should invoke the method on their superclass to ensure that the Platform's adapter manager is consulted).- Specified by:
getAdapter
in interfaceIAdaptable
- Overrides:
getAdapter
in classPlatformObject
- Type Parameters:
T
- the class type- Parameters:
adapter
- the class to adapt to- Returns:
- the adapted object or
null
- See Also:
-
getLongTaskName(IResource[]) instead