Class SynchronizationContentProvider
- All Implemented Interfaces:
EventListener
,IPropertyChangeListener
,IContentProvider
,IStructuredContentProvider
,ITreeContentProvider
,IDiffChangeListener
,ICommonContentProvider
,IMementoAware
- Direct Known Subclasses:
AbstractSynchronizationContentProvider
- Since:
- 3.2
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
diffsChanged
(IDiffChangeEvent event, IProgressMonitor monitor) The diff contained in the originating tree has changed.void
dispose()
Disposes of this content provider.Object[]
getChildren
(Object parent) Returns the child elements of the given parent element.protected Object[]
getChildrenInContext
(ISynchronizationContext context, Object parent, Object[] children) Return the subset of children that are of interest from the given context.protected Object[]
getChildrenInScope
(ISynchronizationScope scope, Object parent, Object[] children) Return the subset of the given children that are in the given scope or are parents of elements that are in scope.protected ISynchronizePageConfiguration
Return the synchronization page configuration associated with the view to which this content provider applies.protected ISynchronizationContext
Return the synchronization context associated with the view to which this content provider applies.protected Object[]
getDelegateChildren
(Object parent) Return the children for the given element from the delegate content provider.protected abstract ITreeContentProvider
Return the model content provider that the team aware content provider delegates to.Object[]
getElements
(Object parent) Returns the elements to display in the viewer when its input is set to the given element.Return the Common Navigator extension site for this content provider.protected final ModelProvider
Return the model provider for this content provider.protected abstract String
Return the id of model provider for this content provider.protected abstract Object
Return the object that acts as the model root.Returns the parent for the given element, ornull
indicating that the parent can't be computed.protected ISynchronizationScope
getScope()
Return the resource mapping scope associated with the view to which this content provider applies.protected abstract ResourceTraversal[]
getTraversals
(ISynchronizationContext context, Object object) Return the traversals for the given object in the given context.protected final Viewer
Return the viewer to which the content provider is associated.protected void
Handle the given exception that occurred while calculating the children for an element.boolean
hasChildren
(Object element) Returns whether the given element has children.protected boolean
hasChildrenInContext
(ISynchronizationContext context, Object element) Return whether the given element has children in the given context.protected boolean
hasChildrenInScope
(ISynchronizationScope scope, Object element) Return whether the given element has children in the given scope.protected boolean
includeDirection
(int direction) Return whether elements with the given direction should be included in the contents.void
Initialize the content provider with the given configuration.void
inputChanged
(Viewer viewer, Object oldInput, Object newInput) Notifies this content provider that the given viewer's input has been switched to a different element.protected final boolean
Return whether the page has been set to use a flat layout.protected boolean
isInitialized
(ISynchronizationContext context) Return whether the content provider has been initialized and is ready to provide content in the given context.protected boolean
isInScope
(ISynchronizationScope scope, Object parent, Object element) Return whether the given object is within the scope of this content provider.protected boolean
Return whether the given diff should be visible based on the configuration of the synchronization page showing this content.protected boolean
isVisible
(ISynchronizationContext context, Object object) Return whether the given object is visible in the synchronization page showing this content based on the diffs in the given context.void
Notification that a property has changed.void
propertyChanged
(IDiffTree tree, int property, IPath[] paths) The given property has changed for the given paths.protected void
refresh()
Refresh the subtree associated with this model.protected void
Subclasses that need to perform extra processing to prepare their model to be displayed by this content provider should override this method and launch a background task to prepare what is required to display their model for the given context.void
restoreState
(IMemento aMemento) Restore the previous state of any actions using the flags in aMemento.void
Save flags in aMemento to remember the state of any actions that persist from session to session.
-
Constructor Details
-
SynchronizationContentProvider
public SynchronizationContentProvider()
-
-
Method Details
-
getChildren
Description copied from interface:ITreeContentProvider
Returns the child elements of the given parent element.The difference between this method and
The result is not modified by the viewer.IStructuredContentProvider.getElements
is thatgetElements
is called to obtain the tree viewer's root elements, whereasgetChildren
is used to obtain the children of a given parent element in the tree (including a root).- Specified by:
getChildren
in interfaceITreeContentProvider
- Parameters:
parent
- the parent element- Returns:
- an array of child elements
-
getElements
Description copied from interface:ITreeContentProvider
Returns the elements to display in the viewer when its input is set to the given element. These elements can be presented as rows in a table, items in a list, etc. The result is not modified by the viewer.NOTE: The returned array must not contain the given
inputElement
, since this leads to recursion issues inAbstractTreeViewer
(see bug 9262).- Specified by:
getElements
in interfaceIStructuredContentProvider
- Specified by:
getElements
in interfaceITreeContentProvider
- Parameters:
parent
- the input element- Returns:
- the array of elements to display in the viewer
-
getParent
Description copied from interface:ITreeContentProvider
Returns the parent for the given element, ornull
indicating that the parent can't be computed. In this case the tree-structured viewer can't expand a given node correctly if requested.- Specified by:
getParent
in interfaceITreeContentProvider
- Parameters:
element
- the element- Returns:
- the parent element, or
null
if it has none or if the parent cannot be computed
-
hasChildren
Description copied from interface:ITreeContentProvider
Returns whether the given element has children.Intended as an optimization for when the viewer does not need the actual children. Clients may be able to implement this more efficiently than
getChildren
.- Specified by:
hasChildren
in interfaceITreeContentProvider
- Parameters:
element
- the element- Returns:
true
if the given element has children, andfalse
if it has no children
-
isInitialized
Return whether the content provider has been initialized and is ready to provide content in the given context. By default,true
is returned. Subclasses that need to perform extra processing to prepare should override this method and also overriderequestInitialization(ISynchronizationContext)
.- Parameters:
context
- the context- Returns:
- whether the content provider has been initialized and is ready to provide content in he given context.
-
requestInitialization
Subclasses that need to perform extra processing to prepare their model to be displayed by this content provider should override this method and launch a background task to prepare what is required to display their model for the given context. An appropriate viewer refresh on the model provider should be issued when the model is prepared.- Parameters:
context
- the context
-
getDelegateChildren
Return the children for the given element from the delegate content provider.- Parameters:
parent
- the parent element- Returns:
- the children for the given element from the delegate content provider
-
hasChildrenInScope
Return whether the given element has children in the given scope. By default, true is returned if the given element contains any elements in the scope or if any of the elements in the scope contain the given element and the delegate provider returns children for the element. TheResourceMapping.contains(ResourceMapping)
is used to test for containment. Subclasses may override to provide a more efficient implementation.- Parameters:
scope
- the scopeelement
- the element- Returns:
- whether the given element has children in the given scope
-
hasChildrenInContext
Return whether the given element has children in the given context. The children may or may not exist locally. By default, this method returns true if the traversals for the element contain any diffs. This could result in false positives. Subclasses can override to provide a more efficient or precise answer.- Parameters:
element
- a model element.- Returns:
- whether the given element has children in the given context
-
dispose
public void dispose()Description copied from interface:IContentProvider
Disposes of this content provider. This is called by the viewer when it is disposed.The viewer should not be updated during this call, as it is in the process of being disposed.
The default implementation does nothing.
- Specified by:
dispose
in interfaceIContentProvider
-
inputChanged
Description copied from interface:IContentProvider
Notifies this content provider that the given viewer's input has been switched to a different element.A typical use for this method is registering the content provider as a listener to changes on the new input (using model-specific means), and deregistering the viewer from the old input. In response to these change notifications, the content provider should update the viewer (see the add, remove, update and refresh methods on the viewers).
The viewer should not be updated during this call, as it might be in the process of being disposed.
The default implementation does nothing.
- Specified by:
inputChanged
in interfaceIContentProvider
- Parameters:
viewer
- the vieweroldInput
- the old input element, ornull
if the viewer did not previously have an inputnewInput
- the new input element, ornull
if the viewer does not have an input
-
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
-
includeDirection
protected boolean includeDirection(int direction) Return whether elements with the given direction should be included in the contents. The direction is one ofIThreeWayDiff.INCOMING
,IThreeWayDiff.OUTGOING
orIThreeWayDiff.CONFLICTING
. This method is invoked by thegetChildrenInContext(ISynchronizationContext, Object, Object[])
method to filter the list of children returned whengetChildren(Object)
is called. It accessing theISynchronizePageConfiguration.P_MODE
property on the state model provided by the view to determine what kinds should be included.- Parameters:
direction
- the synchronization direction- Returns:
- whether elements with the given synchronization kind should be included in the contents
-
getContext
Return the synchronization context associated with the view to which this content provider applies. Anull
is returned if no context is available.- Returns:
- the synchronization context or
null
-
getScope
Return the resource mapping scope associated with the view to which this content provider applies. Anull
is returned if no scope is available.- Returns:
- the resource mapping scope or
null
-
getConfiguration
Return the synchronization page configuration associated with the view to which this content provider applies. Anull
is returned if no configuration is available.- Returns:
- the synchronization page configuration or
null
-
restoreState
Description copied from interface:IMementoAware
Restore the previous state of any actions using the flags in aMemento. This method allows the state of any actions that persist from session to session to be restored.
- Specified by:
restoreState
in interfaceIMementoAware
- Parameters:
aMemento
- A memento that was given to the view part to restore its state.
-
saveState
Description copied from interface:IMementoAware
Save flags in aMemento to remember the state of any actions that persist from session to session.
Extensions should qualify any keys stored in the memento with their plugin id
- Specified by:
saveState
in interfaceIMementoAware
- Parameters:
aMemento
- A memento that was given to the view part to save its state.
-
diffsChanged
Description copied from interface:IDiffChangeListener
The diff contained in the originating tree has changed.- Specified by:
diffsChanged
in interfaceIDiffChangeListener
- Parameters:
event
- the change eventmonitor
- a progress monitor
-
propertyChanged
Description copied from interface:IDiffChangeListener
The given property has changed for the given paths.- Specified by:
propertyChanged
in interfaceIDiffChangeListener
- Parameters:
tree
- the tree for which the property changedproperty
- the propertypaths
- the paths
-
refresh
protected void refresh()Refresh the subtree associated with this model. -
getDelegateContentProvider
Return the model content provider that the team aware content provider delegates to.- Returns:
- the model content provider
-
getModelProvider
Return the model provider for this content provider.- Returns:
- the model provider for this content provider
-
getModelProviderId
Return the id of model provider for this content provider.- Returns:
- the model provider for this content provider
-
getModelRoot
Return the object that acts as the model root. It is used when getting the children for a model provider.- Returns:
- the object that acts as the model root
-
getViewer
Return the viewer to which the content provider is associated.- Returns:
- the viewer to which the content provider is associated
-
getChildrenInScope
protected Object[] getChildrenInScope(ISynchronizationScope scope, Object parent, Object[] children) Return the subset of the given children that are in the given scope or are parents of elements that are in scope.- Parameters:
scope
- the scopeparent
- the parent of the given childrenchildren
- all the children of the parent that are in scope.- Returns:
- the subset of the given children that are in the scope of the content provider
-
getChildrenInContext
protected Object[] getChildrenInContext(ISynchronizationContext context, Object parent, Object[] children) Return the subset of children that are of interest from the given context. By default, this method returns those children whose traversals contain a diff in the context. However, it does not include those model elements that do not exist locally but are within the context (e.g. locally deleted elements and remotely added elements). Subclasses must override to include these.- Parameters:
context
- the contextparent
- the parent of the childrenchildren
- the children- Returns:
- the subset of children that are of interest from the given context
-
isVisible
Return whether the given object is visible in the synchronization page showing this content based on the diffs in the given context. Visibility is determined by obtaining the diffs for the object from the context by callinggetTraversals(ISynchronizationContext, Object)
to get the traversals, then obtaining the diffs from the context's diff tree and then callingisVisible(IDiff)
for each diff.- Parameters:
context
- the synchronization contextobject
- the object- Returns:
- whether the given object is visible in the synchronization page showing this content
-
isVisible
Return whether the given diff should be visible based on the configuration of the synchronization page showing this content. AnIThreeWayDiff
is visible if the direction of the change matches the mode of the synchronization page. AnITwoWayDiff
is visible if it has a kind that represents a change.- Parameters:
diff
- the diff- Returns:
- whether the diff should be visible
-
getTraversals
protected abstract ResourceTraversal[] getTraversals(ISynchronizationContext context, Object object) Return the traversals for the given object in the given context. This method must not be long running. If a long running calculation is required to calculate the traversals, an empty traversal should be returned and the content provider should initiate a background task to calculate the required traversals and update the view according when the task completes.- Parameters:
context
- the synchronization contextobject
- the object- Returns:
- the traversals for the given object in the given context
-
handleException
Handle the given exception that occurred while calculating the children for an element.- Parameters:
e
- the exception
-
isInScope
Return whether the given object is within the scope of this content provider. The object is in scope if it is part of a resource mapping in the scope or is the parent of resources covered by one or more resource mappings in the scope. By default, this compares the mapping of the given element with those in the scope using theResourceMapping.contains(ResourceMapping)
method to determine if the element is in the scope. Subclasses may override to provide a more efficient means of doing the check.- Parameters:
scope
- the scopeparent
- the parent of the objectelement
- the object- Returns:
- whether the given object is within the scope of this content provider
-
getExtensionSite
Return the Common Navigator extension site for this content provider.- Returns:
- the Common Navigator extension site for this content provider
-
isFlatLayout
protected final boolean isFlatLayout()Return whether the page has been set to use a flat layout.- Returns:
- whether the page has been set to use a flat layout
- Since:
- 3.3
-