public abstract class SynchronizationContentProvider extends Object implements ICommonContentProvider, IDiffChangeListener, IPropertyChangeListener
Constructor and Description |
---|
SynchronizationContentProvider() |
Modifier and Type | Method and Description |
---|---|
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.
|
public Object[] getChildren(Object parent)
ITreeContentProvider
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).
getChildren
in interface ITreeContentProvider
parent
- the parent elementpublic Object[] getElements(Object parent)
ITreeContentProvider
NOTE: The returned array must not contain the given
inputElement
, since this leads to recursion issues in
AbstractTreeViewer
(see
bug 9262).
getElements
in interface IStructuredContentProvider
getElements
in interface ITreeContentProvider
parent
- the input elementpublic Object getParent(Object element)
ITreeContentProvider
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.getParent
in interface ITreeContentProvider
element
- the elementnull
if it
has none or if the parent cannot be computedpublic boolean hasChildren(Object element)
ITreeContentProvider
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
.
hasChildren
in interface ITreeContentProvider
element
- the elementtrue
if the given element has children,
and false
if it has no childrenprotected boolean isInitialized(ISynchronizationContext context)
true
is returned. Subclasses
that need to perform extra processing to prepare should override this method and
also override requestInitialization(ISynchronizationContext)
.context
- the contextprotected void requestInitialization(ISynchronizationContext context)
context
- the contextprotected Object[] getDelegateChildren(Object parent)
parent
- the parent elementprotected boolean hasChildrenInScope(ISynchronizationScope scope, Object element)
ResourceMapping.contains(ResourceMapping)
is used to test
for containment.
Subclasses may override to provide a more efficient implementation.scope
- the scopeelement
- the elementprotected boolean hasChildrenInContext(ISynchronizationContext context, Object element)
element
- a model element.public void dispose()
IContentProvider
The viewer should not be updated during this call, as it is in the process of being disposed.
dispose
in interface IContentProvider
public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
IContentProvider
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.
inputChanged
in interface IContentProvider
viewer
- the vieweroldInput
- the old input element, or null
if the viewer
did not previously have an inputnewInput
- the new input element, or null
if the viewer
does not have an inputpublic void init(ICommonContentExtensionSite site)
ICommonContentProvider
init
in interface ICommonContentProvider
site
- The extension site provides information that some extensions
will find useful to configure themselves properly in a
particular viewer.ICommonLabelProvider
public void propertyChange(PropertyChangeEvent event)
IPropertyChangeListener
This method gets called when the observed object fires a property change event.
propertyChange
in interface IPropertyChangeListener
event
- the property change event object describing which property
changed and howprotected boolean includeDirection(int direction)
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.direction
- the synchronization directionprotected ISynchronizationContext getContext()
null
is returned if
no context is available.null
protected ISynchronizationScope getScope()
null
is returned if
no scope is available.null
protected ISynchronizePageConfiguration getConfiguration()
null
is returned if
no configuration is available.null
public void restoreState(IMemento aMemento)
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.
restoreState
in interface IMementoAware
aMemento
- A memento that was given to the view part to restore its
state.public void saveState(IMemento aMemento)
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
saveState
in interface IMementoAware
aMemento
- A memento that was given to the view part to save its state.public void diffsChanged(IDiffChangeEvent event, IProgressMonitor monitor)
IDiffChangeListener
diffsChanged
in interface IDiffChangeListener
event
- the change eventmonitor
- a progress monitorpublic void propertyChanged(IDiffTree tree, int property, IPath[] paths)
IDiffChangeListener
propertyChanged
in interface IDiffChangeListener
tree
- the tree for which the property changedproperty
- the propertypaths
- the pathsprotected void refresh()
protected abstract ITreeContentProvider getDelegateContentProvider()
protected final ModelProvider getModelProvider()
protected abstract String getModelProviderId()
protected abstract Object getModelRoot()
protected final Viewer getViewer()
protected Object[] getChildrenInScope(ISynchronizationScope scope, Object parent, Object[] children)
scope
- the scopeparent
- the parent of the given childrenchildren
- all the children of the parent that are in scope.protected Object[] getChildrenInContext(ISynchronizationContext context, Object parent, Object[] children)
context
- the contextparent
- the parent of the childrenchildren
- the childrenprotected boolean isVisible(ISynchronizationContext context, Object object)
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.context
- the synchronization contextobject
- the objectprotected boolean isVisible(IDiff diff)
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.diff
- the diffprotected abstract ResourceTraversal[] getTraversals(ISynchronizationContext context, Object object)
context
- the synchronization contextobject
- the objectprotected void handleException(CoreException e)
e
- the exceptionprotected boolean isInScope(ISynchronizationScope scope, Object parent, Object element)
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.scope
- the scopeparent
- the parent of the objectelement
- the objectpublic ICommonContentExtensionSite getExtensionSite()
protected final boolean isFlatLayout()
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.