Class ContentProvider
- All Implemented Interfaces:
IProviderFlagsChangeListener,EventListener,IAdaptable,IContentProvider,ISelectionChangedListener,IStructuredContentProvider,ITreeContentProvider,ICommonContentProvider,IMementoAware,IPipelinedTreeContentProvider,IPipelinedTreeContentProvider2
References:
- http://www.techjava.de/topics/2009/04/eclipse-common-navigator-framework/
- http://cvalcarcel.wordpress.com/2010/06/29/writing-an-eclipse-plug-in-the-missing-zip-files/
- http://git.eclipse.org/c/gmp/org.eclipse.gmp.graphiti.git/tree/examples/org.eclipse.graphiti.examples.common/src/org/eclipse/graphiti/examples/common/navigator
- Author:
- Christopher Mindus
Field Summary
FieldsConstructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionvoiddispose()Disposes of this content provider.<T> TgetAdapter(Class<T> adapter) Adapts the content provider.Object[]getChildren(Object element) Returns the child elements of the given parent element.Object[]getElements(Object element) Returns the elements to display in the viewer when its input is set to the given element.intgetFlags()Gets the flags.static StructuredViewerGets the viewer that was last used to set the selection.Returns the parent for the given element, ornullindicating that the parent can't be computed.voidgetPipelinedChildren(Object aParent, Set theCurrentChildren) Intercept the children that would be contributed to the viewer and determine how to change the shape of those children.voidgetPipelinedElements(Object anInput, Set theCurrentElements) Intercept the elements that would be contributed to the root of the viewer and determine how to change the shape of those children.getPipelinedParent(Object anObject, Object aSuggestedParent) Intercept requests for a parent of the given object.booleanhasChildren(Object element) Returns whether the given element has children.booleanhasPipelinedChildren(Object anInput, boolean currentHasChildren) Intercept the fact of having children and optionally modify this.voidinit(ICommonContentExtensionSite aConfig) Initialize the content provider with the given configuration.voidinputChanged(Viewer v, Object oldInput, Object newInput) Notifies this content provider that the given viewer's input has been switched to a different element.interceptAdd(PipelinedShapeModification anAddModification) Intercept attempts to add elements directly to the viewer.booleaninterceptRefresh(PipelinedViewerUpdate aRefreshSynchronization) Intercept calls to viewerrefresh()methods.interceptRemove(PipelinedShapeModification aRemoveModification) Intercept attempts to remove elements directly from the viewer.booleaninterceptUpdate(PipelinedViewerUpdate anUpdateSynchronization) Intercept calls to viewerupdate()methods.voidAn IIZI event processed here to see if the viewer needs update.voidonNewFlags(int flags) Called when the flags changed.voidrestoreState(IMemento aMemento) Restore the previous state of any actions using the flags in aMemento.voidSave flags in aMemento to remember the state of any actions that persist from session to session.voidSelection changes in the viewer, forwarded to the ActionExecutor class.voidsetFlags(int flags) Sets the flags.
Field Details
EMPTY_ARRAY
An empty array.
Constructor Details
ContentProvider
public ContentProvider()Constructor.ContentProvider
public ContentProvider(int flags) Constructor.- Parameters:
flags- The flags for the information.
Method Details
onNewFlags
public void onNewFlags(int flags) Called when the flags changed.- Specified by:
onNewFlagsin interfaceIProviderFlagsChangeListener- Parameters:
flags- The flags from INavigatorPresentation.
setFlags
public void setFlags(int flags) Sets the flags.getFlags
public int getFlags()Gets the flags.restoreState
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:
restoreStatein interfaceIMementoAware
saveState
Save flags in aMemento to remember the state of any actions that persist from session to session.- Specified by:
saveStatein interfaceIMementoAware
dispose
public void dispose()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:
disposein interfaceIContentProvider
inputChanged
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 de-registering 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:
inputChangedin interfaceIContentProvider- Parameters:
v- The viewer.oldInput- The old input element, ornullif the viewer did not previously have an input.newInput- The new input element, ornullif the viewer does not have an input.
getElements
Returns the elements to display in the viewer when its input is set to the given element.- Specified by:
getElementsin interfaceIStructuredContentProvider- Specified by:
getElementsin interfaceITreeContentProvider- Parameters:
element- The input element.- Returns:
- the array of elements to display in the viewer.
getChildren
Returns the child elements of the given parent element.The difference between this method and
IStructuredContentProvider.getElementsis thatgetElementsis called to obtain the tree viewer's root elements, whereasgetChildrenis 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:
getChildrenin interfaceITreeContentProvider- Parameters:
element- the parent element- Returns:
- an array of child elements
getParent
Returns the parent for the given element, ornullindicating 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:
getParentin interfaceITreeContentProvider- Parameters:
element- The element.- Returns:
- the parent element, or
nullif it has none or if the parent cannot be computed.
hasChildren
Returns whether the given element has children.Intended as an optimization for when the viewer does not need the actual children. Implementation is more efficient than
getChildren.- Specified by:
hasChildrenin interfaceITreeContentProvider- Parameters:
element- The element.- Returns:
trueif the given element has children, andfalseif it has no children.
onEvent
An IIZI event processed here to see if the viewer needs update. This call can be done from any thread, so it must be "queued" over to the viewer for processing.- Specified by:
onEventin interfaceEventListener- Parameters:
e- The event.
selectionChanged
Selection changes in the viewer, forwarded to the ActionExecutor class.- Specified by:
selectionChangedin interfaceISelectionChangedListener- Parameters:
event-
getLastViewer
Gets the viewer that was last used to set the selection.getPipelinedElements
Intercept the elements that would be contributed to the root of the viewer and determine how to change the shape of those children. The given set of elements should be modified to contain the correct elements to return to the viewer.- Specified by:
getPipelinedElementsin interfaceIPipelinedTreeContentProvider- Parameters:
anInput- An input from the viewer.theCurrentElements- The set of children contributed thus far from upstream content providers.
getPipelinedChildren
Intercept the children that would be contributed to the viewer and determine how to change the shape of those children. The set of children should be modified to contain the correct children to return to the viewer.- Specified by:
getPipelinedChildrenin interfaceIPipelinedTreeContentProvider- Parameters:
aParent- A parent from the viewer.theCurrentChildren- The set of children contributed thus far from upstream content providers.
hasPipelinedChildren
Intercept the fact of having children and optionally modify this. This calculation should match whether children will be actually provided.- Specified by:
hasPipelinedChildrenin interfaceIPipelinedTreeContentProvider2- Parameters:
anInput- An input from the viewer.currentHasChildren- The current proposed setting of hasChildren thus far from the upstream content providers.- Returns:
- The new value for hasChildren.
getPipelinedParent
Intercept requests for a parent of the given object.- Specified by:
getPipelinedParentin interfaceIPipelinedTreeContentProvider- Parameters:
anObject- The object being queried for a parent.aSuggestedParent- The parent already suggested from upstream extensions.- Returns:
- The intended parent from this pipelined content provider. If you wish to not influence the parent, then return the aSuggestedParent value.
getAdapter
Adapts the content provider.- Specified by:
getAdapterin interfaceIAdaptable- Parameters:
adapter- The adapter class.- Returns:
- The object adapting to the class.