org.eclipse.team.ui.mapping
Class SynchronizationContentProvider
java.lang.Object
org.eclipse.team.ui.mapping.SynchronizationContentProvider
-
All Implemented Interfaces:
-
EventListener,
IPropertyChangeListener,
IContentProvider,
IStructuredContentProvider,
ITreeContentProvider,
IDiffChangeListener,
ICommonContentProvider,
IMementoAware
-
Direct Known Subclasses:
-
AbstractSynchronizationContentProvider
-
public abstract class SynchronizationContentProvider
- extends
Object
- implements
ICommonContentProvider,
IDiffChangeListener,
IPropertyChangeListener
Abstract team aware content provider that delegates to another content provider.
-
Since:
- 3.2
Method Summary
|
void
|
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
|
getConfiguration
()
Return the synchronization page configuration associated with the view to which
this content provider applies. |
protected
ISynchronizationContext
|
getContext
()
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
|
getDelegateContentProvider
()
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. |
ICommonContentExtensionSite
|
getExtensionSite
()
Return the Common Navigator extension site for this
content provider. |
protected
ModelProvider
|
getModelProvider
()
Return the model provider for this content provider. |
protected abstract
String
|
getModelProviderId
()
Return the id of model provider for this content provider. |
protected abstract
Object
|
getModelRoot
()
Return the object that acts as the model root. |
Object
|
getParent
(
Object element)
Returns the parent for the given element, or null
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
Viewer
|
getViewer
()
Return the viewer to which the content provider is associated. |
protected void
|
handleException
(
CoreException e)
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
|
init
(
ICommonContentExtensionSite site)
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 boolean
|
isFlatLayout
()
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
|
isVisible
(
IDiff diff)
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
|
propertyChange
(
PropertyChangeEvent event)
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
|
requestInitialization
(
ISynchronizationContext context)
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
|
saveState
(
IMemento aMemento)
Save flags in aMemento to remember the state of any actions that persist
from session to session. |
Methods inherited from class java.lang.
Object
|
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
|
SynchronizationContentProvider
public SynchronizationContentProvider()
getChildren
public
Object[] getChildren(
Object parent)
-
Description copied from interface:
ITreeContentProvider
- Returns the child elements of the given parent element.
The difference between this method and IStructuredContentProvider.getElements
is that getElements
is called to obtain the
tree viewer's root elements, whereas getChildren
is used
to obtain the children of a given parent element in the tree (including a root).
The result is not modified by the viewer.
-
-
Specified by:
-
getChildren
in interface
ITreeContentProvider
-
-
Parameters:
-
parent
- the parent element
-
Returns:
- an array of child elements
getElements
public
Object[] getElements(
Object parent)
-
Description copied from interface:
IStructuredContentProvider
- 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: For instances where the viewer is displaying a tree
containing a single 'root' element it is still necessary that the
'input' does not return itself from this method. This leads
to recursion issues (see bug 9262).
-
-
Specified by:
-
getElements
in interface
IStructuredContentProvider
-
-
Parameters:
-
parent
- the input element
-
Returns:
- the array of elements to display in the viewer
getParent
public
Object getParent(
Object element)
-
Description copied from interface:
ITreeContentProvider
- Returns the parent for the given element, or
null
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 interface
ITreeContentProvider
-
-
Parameters:
-
element
- the element
-
Returns:
- the parent element, or
null
if it
has none or if the parent cannot be computed
hasChildren
public boolean hasChildren(
Object element)
-
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 interface
ITreeContentProvider
-
-
Parameters:
-
element
- the element
-
Returns:
-
true
if the given element has children,
and false
if it has no children
isInitialized
protected boolean isInitialized(
ISynchronizationContext context)
- 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 override
requestInitialization(ISynchronizationContext)
.
-
-
-
Parameters:
-
context
- the context
-
Returns:
- whether the content provider has been initialized and is ready to
provide content in he given context.
requestInitialization
protected void requestInitialization(
ISynchronizationContext context)
- 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
protected
Object[] getDelegateChildren(
Object parent)
- 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
protected boolean hasChildrenInScope(
ISynchronizationScope scope,
Object element)
- 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.
The
ResourceMapping.contains(ResourceMapping)
is used to test
for containment.
Subclasses may override to provide a more efficient implementation.
-
-
-
Parameters:
-
scope
- the scope -
element
- the element
-
Returns:
- whether the given element has children in the given scope
hasChildrenInContext
protected boolean hasChildrenInContext(
ISynchronizationContext context,
Object element)
- 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.
-
-
Specified by:
-
dispose
in interface
IContentProvider
-
inputChanged
public void inputChanged(
Viewer viewer,
Object oldInput,
Object newInput)
-
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.
-
-
Specified by:
-
inputChanged
in interface
IContentProvider
-
-
Parameters:
-
viewer
- the viewer -
oldInput
- the old input element, or null
if the viewer
did not previously have an input -
newInput
- the new input element, or null
if the viewer
does not have an input
init
public void init(
ICommonContentExtensionSite site)
-
Description copied from interface:
ICommonContentProvider
- Initialize the content provider with the given configuration.
-
-
Specified by:
-
init
in interface
ICommonContentProvider
-
-
Parameters:
-
site
- The extension site provides information that some extensions
will find useful to configure themselves properly in a
particular viewer. -
See Also:
-
ICommonLabelProvider
propertyChange
public void propertyChange(
PropertyChangeEvent event)
-
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 interface
IPropertyChangeListener
-
-
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 of
IThreeWayDiff.INCOMING
,
IThreeWayDiff.OUTGOING
or
IThreeWayDiff.CONFLICTING
.
This method is invoked by the
getChildrenInContext(ISynchronizationContext, Object, Object[])
method to filter the list of children returned when
getChildren(Object)
is called. It accessing the
ISynchronizePageConfiguration.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
protected
ISynchronizationContext getContext()
- Return the synchronization context associated with the view to which
this content provider applies. A
null
is returned if
no context is available.
-
-
-
Returns:
- the synchronization context or
null
getScope
protected
ISynchronizationScope getScope()
- Return the resource mapping scope associated with the view to which
this content provider applies. A
null
is returned if
no scope is available.
-
-
-
Returns:
- the resource mapping scope or
null
getConfiguration
protected
ISynchronizePageConfiguration getConfiguration()
- Return the synchronization page configuration associated with the view to which
this content provider applies. A
null
is returned if
no configuration is available.
-
-
-
Returns:
- the synchronization page configuration or
null
restoreState
public void restoreState(
IMemento aMemento)
-
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 interface
IMementoAware
-
-
Parameters:
-
aMemento
- A memento that was given to the view part to restore its
state.
saveState
public void saveState(
IMemento aMemento)
-
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 interface
IMementoAware
-
-
Parameters:
-
aMemento
- A memento that was given to the view part to save its state.
diffsChanged
public void diffsChanged(
IDiffChangeEvent event,
IProgressMonitor monitor)
-
Description copied from interface:
IDiffChangeListener
- The diff contained in the originating tree has changed.
-
-
Specified by:
-
diffsChanged
in interface
IDiffChangeListener
-
-
Parameters:
-
event
- the change event -
monitor
- a progress monitor
propertyChanged
public void propertyChanged(
IDiffTree tree,
int property,
IPath[] paths)
-
Description copied from interface:
IDiffChangeListener
- The given property has changed for the given paths.
-
-
Specified by:
-
propertyChanged
in interface
IDiffChangeListener
-
-
Parameters:
-
tree
- the tree for which the property changed -
property
- the property -
paths
- the paths
refresh
protected void refresh()
- Refresh the subtree associated with this model.
-
-
getDelegateContentProvider
protected abstract
ITreeContentProvider getDelegateContentProvider()
- Return the model content provider that the team aware content
provider delegates to.
-
-
-
Returns:
- the model content provider
getModelProvider
protected final
ModelProvider getModelProvider()
- Return the model provider for this content provider.
-
-
-
Returns:
- the model provider for this content provider
getModelProviderId
protected abstract
String getModelProviderId()
- Return the id of model provider for this content provider.
-
-
-
Returns:
- the model provider for this content provider
getModelRoot
protected abstract
Object 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
protected final
Viewer 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 scope -
parent
- the parent of the given children -
children
- 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 context -
parent
- the parent of the children -
children
- the children
-
Returns:
- the subset of children that are of interest from the given context
isVisible
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. Visibility
is determined by obtaining the diffs for the object from the context by
calling
getTraversals(ISynchronizationContext, Object)
to get
the traversals, then obtaining the diffs from the context's diff tree and
then calling
isVisible(IDiff)
for each diff.
-
-
-
Parameters:
-
context
- the synchronization context -
object
- the object
-
Returns:
- whether the given object is visible in the synchronization page
showing this content
isVisible
protected boolean isVisible(
IDiff diff)
- Return whether the given diff should be visible based on the
configuration of the synchronization page showing this content. An
IThreeWayDiff
is visible if the direction of the change matches
the mode of the synchronization page. An
ITwoWayDiff
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 context -
object
- the object
-
Returns:
- the traversals for the given object in the given context
handleException
protected void handleException(
CoreException e)
- Handle the given exception that occurred while calculating the
children for an element.
-
-
-
Parameters:
-
e
- the exception
isInScope
protected boolean isInScope(
ISynchronizationScope scope,
Object parent,
Object element)
- 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 the
ResourceMapping.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 scope -
parent
- the parent of the object -
element
- the object
-
Returns:
- whether the given object is within the scope of this
content provider
getExtensionSite
public
ICommonContentExtensionSite 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
Guidelines for using Eclipse APIs.
Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.