public class BasicExplorerContentProvider
extends java.lang.Object
implements org.eclipse.ui.navigator.ICommonContentProvider, org.eclipse.emf.common.ui.viewer.IViewerProvider
Modifier and Type | Field and Description |
---|---|
protected org.eclipse.ui.navigator.INavigatorContentDescriptor |
contentDescriptor |
protected org.eclipse.emf.transaction.ResourceSetListener |
crossReferenceChangedListener |
protected static int |
LIMIT_INDIVIDUAL_OBJECTS_REFRESH |
protected static int |
LIMIT_INDIVIDUAL_RESOURCES_REFRESH |
protected java.util.Map<org.eclipse.emf.transaction.TransactionalEditingDomain,org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider> |
modelContentProviders |
protected org.eclipse.emf.transaction.ResourceSetListener |
modelContentRootChangedListener |
protected org.eclipse.emf.transaction.ResourceSetListener |
resourceChangedListener |
protected org.eclipse.emf.transaction.ResourceSetListener |
resourceMovedListener |
protected org.eclipse.jface.viewers.Viewer |
viewer |
Constructor and Description |
---|
BasicExplorerContentProvider() |
Modifier and Type | Method and Description |
---|---|
protected void |
addTransactionalEditingDomainListeners(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain) |
protected void |
applyViewerState(ITreeViewerState state) |
protected org.eclipse.emf.transaction.ResourceSetListener |
createCrossReferenceChangedListener() |
protected org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider |
createModelContentProvider(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain) |
protected org.eclipse.emf.transaction.ResourceSetListener |
createModelContentRootChangedListener()
Explicitly refreshes the corresponding workspace resources in case of changes among the direct children of the
model root objects.
|
protected org.eclipse.emf.transaction.ResourceSetListener |
createResourceChangedListener()
Creates a ResourceSetChangedListener that detects (re-)loaded resources resources and refreshes their parent(s).
|
protected org.eclipse.emf.transaction.ResourceSetListener |
createResourceMovedListener() |
void |
dispose() |
protected org.eclipse.emf.common.notify.AdapterFactory |
getAdapterFactory(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain)
Returns the
adapter factory to be used by this content
provider for creating item provider s which control the way how model
element s from given editingDomain are displayed and can be edited. |
java.lang.Object[] |
getChildren(java.lang.Object parentElement) |
protected ExtendedCommonNavigator |
getCommonNavigator() |
protected org.eclipse.emf.common.notify.AdapterFactory |
getCustomAdapterFactory()
Returns a custom
adapter factory to be used by this content provider for creating item provider s which control the way how
model element s from given editingDomain are displayed and can be edited. |
java.lang.Object[] |
getElements(java.lang.Object inputElement) |
protected java.lang.Object |
getMappedModelRoot(org.eclipse.emf.ecore.EObject object)
Deprecated.
Use
getModelContentRoot(EObject) instead. |
protected org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider |
getModelContentProvider(java.lang.Object object) |
protected java.lang.Object |
getModelContentRoot(org.eclipse.emf.ecore.EObject object)
Deprecated.
Use
getModelContentRoots(Resource) instead. |
protected java.lang.Object |
getModelContentRoot(org.eclipse.emf.ecore.util.FeatureMap.Entry entry)
Deprecated.
Use
getModelContentRoots(Resource) instead. |
protected java.lang.Object |
getModelContentRoot(org.eclipse.emf.edit.provider.IWrapperItemProvider wrapperItemProvider)
Deprecated.
Use
getModelContentRoots(Resource) instead. |
protected java.lang.Object |
getModelContentRoot(java.lang.Object object)
Deprecated.
Use
getModelContentRoots(Resource) instead. |
protected java.lang.Object |
getModelContentRoot(TransientItemProvider transientItemProvider)
Deprecated.
Use
getModelContentRoots(Resource) instead. |
protected java.util.List<java.lang.Object> |
getModelContentRoots(org.eclipse.emf.ecore.resource.Resource modelResource)
Returns a list of objects which are to be used as roots of the model content provided by this
content provider for the given model resource. |
protected org.eclipse.emf.ecore.resource.Resource |
getModelResource(org.eclipse.core.resources.IResource workspaceResource)
Retrieves the model
resource behind specified workspace resource . |
protected java.lang.Object |
getModelRoot(org.eclipse.core.resources.IResource resource)
Deprecated.
|
protected org.eclipse.emf.ecore.EObject |
getModelRoot(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain,
org.eclipse.core.resources.IFile file)
Deprecated.
Use
getModelRoot(IResource) instead. Rationale: Navigation into models should not be
supported only from files but also from projects and folders. The TransactionalEditingDomain can be
easily retrieved inside the method and therefore does not need to be provided by the caller. |
java.lang.Object |
getParent(java.lang.Object element) |
protected org.eclipse.core.resources.IResource |
getUnderlyingWorkspaceResource(java.lang.Object modelContentRoot)
Deprecated.
Use
getWorkspaceResource(Resource) instead. |
org.eclipse.jface.viewers.Viewer |
getViewer()
Returns the viewer whose content is provided by this content provider.
|
protected org.eclipse.core.resources.IResource |
getWorkspaceResource(org.eclipse.emf.ecore.resource.Resource modelResource)
Returns the
resource corresponding to given model resource . |
boolean |
hasChildren(java.lang.Object element) |
void |
init(org.eclipse.ui.navigator.ICommonContentExtensionSite config) |
void |
inputChanged(org.eclipse.jface.viewers.Viewer viewer,
java.lang.Object oldInput,
java.lang.Object newInput) |
protected boolean |
isPossibleChild(java.lang.Object object) |
protected boolean |
isTriggerPoint(org.eclipse.core.resources.IResource resource) |
protected ITreeViewerState |
recordViewerState() |
protected void |
refreshViewer()
Refreshes viewer completely.
|
protected void |
refreshViewerOnModelObjects(java.util.Set<?> objects)
Refreshes viewer on specified model objects.
|
protected void |
refreshViewerOnModelResources(java.util.Set<? extends org.eclipse.emf.ecore.resource.Resource> resources)
Refreshes viewer on specified model resources.
|
protected void |
refreshViewerOnObject(java.lang.Object object)
Refreshes viewer on specified object.
|
protected void |
refreshViewerOnWorkspaceResources(java.util.Set<? extends org.eclipse.core.resources.IResource> resources)
Refreshes viewer on specified workspace resources.
|
protected void |
removeTransactionalEditingDomainListeners(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain) |
void |
restoreState(org.eclipse.ui.IMemento memento) |
void |
saveState(org.eclipse.ui.IMemento memento) |
protected static final int LIMIT_INDIVIDUAL_RESOURCES_REFRESH
protected static final int LIMIT_INDIVIDUAL_OBJECTS_REFRESH
protected org.eclipse.jface.viewers.Viewer viewer
protected org.eclipse.ui.navigator.INavigatorContentDescriptor contentDescriptor
protected java.util.Map<org.eclipse.emf.transaction.TransactionalEditingDomain,org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider> modelContentProviders
protected org.eclipse.emf.transaction.ResourceSetListener resourceChangedListener
protected org.eclipse.emf.transaction.ResourceSetListener resourceMovedListener
protected org.eclipse.emf.transaction.ResourceSetListener crossReferenceChangedListener
protected org.eclipse.emf.transaction.ResourceSetListener modelContentRootChangedListener
public org.eclipse.jface.viewers.Viewer getViewer()
getViewer
in interface org.eclipse.emf.common.ui.viewer.IViewerProvider
protected ExtendedCommonNavigator getCommonNavigator()
protected ITreeViewerState recordViewerState()
protected void applyViewerState(ITreeViewerState state)
public void init(org.eclipse.ui.navigator.ICommonContentExtensionSite config)
init
in interface org.eclipse.ui.navigator.ICommonContentProvider
protected boolean isTriggerPoint(org.eclipse.core.resources.IResource resource)
protected boolean isPossibleChild(java.lang.Object object)
public void saveState(org.eclipse.ui.IMemento memento)
saveState
in interface org.eclipse.ui.navigator.IMementoAware
public void restoreState(org.eclipse.ui.IMemento memento)
restoreState
in interface org.eclipse.ui.navigator.IMementoAware
protected org.eclipse.emf.ecore.resource.Resource getModelResource(org.eclipse.core.resources.IResource workspaceResource)
resource
behind specified workspace resource
. Returns
null
if no such is available or the model
behind specified workspace
resource has not been loaded yet.
Default implementation supports the handling of file
resources including lazy loading of the
underlying model
s: if the given file belongs to some model that has not been loaded yet
then the loading of that model, i.e., the given file and all other files belonging to the same, will be
triggered. The model loading will be performed asynchronously and therefore won't block the UI. When the model
loading has been completed, the resourceChangedListener
automatically refreshes the underlying
viewer
so that the model elements contained by the given file become visible.
Clients may override this method so as to add support for other resource types (e.g., project
s
or folder
s) or implement different lazy or eager loading strategies.
workspaceResource
- The workspace resource of which the model resource is to be retrieved.null
if no such is available or
the model behind specified workspace resource has not been loaded yet.protected java.util.List<java.lang.Object> getModelContentRoots(org.eclipse.emf.ecore.resource.Resource modelResource)
content provider
for the given model resource. They may or may not be the
actual root objects of the model resource.
The model content roots can be thought of being mapped to the workspace resource
behind given
model resource and are the actual parent objects of the model objects to be displayed as virtual children of the
workspace resource. The model content roots themselves will not become visible in the underlying viewer, only the
workspace resource they are mapped to and their children will.
This implementation returns a list containing the provided model resource itself as default. Clients are free to override and implement alternative behaviors as appropriate.
modelResource
- The model resource of which the model content roots are to be retrieved.content provider
.protected org.eclipse.core.resources.IResource getWorkspaceResource(org.eclipse.emf.ecore.resource.Resource modelResource)
resource
corresponding to given model resource
.modelResource
- The model resource of which the workspace resource it to be returned.resource
corresponding to given model resource.getModelResource(IResource)
@Deprecated protected java.lang.Object getModelRoot(org.eclipse.core.resources.IResource resource)
resource
. Returns null
if no such is
available or the model
behind specified resource has not been loaded yet.
Default implementation supports the handling of file
resources including lazy loading of the
underlying model
s: if the given file belongs to some model that has not been loaded yet
then the loading of that model, i.e., the given file and all other files belonging to the same model, will be
triggered. The model loading will be done asynchronously and therefore won't block the UI. When the model loading
has been completed, the resourceChangedListener
automatically refreshes the underlying viewer
so that the model elements contained by the given file become visible.
Clients may override this method so as to add support for other resource types (e.g., project
s
or folder
s) or implement different lazy or eager loading strategies.
resource
- The resource
whose model root is to be retrieved.null
if no such is available or the model behind
specified resource has not been loaded yet.@Deprecated protected org.eclipse.emf.ecore.EObject getModelRoot(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain, org.eclipse.core.resources.IFile file)
getModelRoot(IResource)
instead. Rationale: Navigation into models should not be
supported only from files but also from projects and folders. The TransactionalEditingDomain can be
easily retrieved inside the method and therefore does not need to be provided by the caller.file
. Returns
null
if that file has not yet been loaded into the ResourceSet of the specified
editingDomain
or if it is empty.
Default implementation provides a lazy loading mechanism. When the user expands an model file of some
model
which has not been loaded yet, this and all other model files which belong to that
model
will be loaded by that time. This loading will be done asynchronously using
ModelLoadManager API, and therefore won't block the UI while the loading process is ongoing. Once
the loading of the model
will be finished, the refresh mechanism (i.e., the
resource changed listener) will make sure that the view gets refreshed and the
model elements inside the expanded model file become visible.
Clients may override this method in order to provide a custom lazy or eager loading strategy.
editingDomain
- The editing domain owning the resource
set inside which the resource corresponding to the specified file
should be loaded.file
- The file which model root must be returned.file
; or null
if file has
not been loaded.@Deprecated protected java.lang.Object getModelContentRoot(java.lang.Object object)
getModelContentRoots(Resource)
instead.object
or resource
which is used as root of the model content
provided by this content provider
for given model object. The model content
root is the model object that is mapped to the workspace resource
under which the model behind
given model object is made visible. It may or may not be the actual root object of the model. The model content
root itself will not become visible in the underlying viewer, only the workspace resource it is mapped to and its
children will.object
- An arbitrary model object to be investigated.object
or resource
which is used as root of the model content
provided by this content provider for given model object or null
if given object is no model
object or has no parent that corresponds to the expected model content root.@Deprecated protected java.lang.Object getModelContentRoot(org.eclipse.emf.ecore.EObject object)
getModelContentRoots(Resource)
instead.object
or resource
which is used as root of the model content
provided by this content provider
for given model object
.
The model content root is the model object that is mapped to the workspace resource
under which
the model behind given model object is made visible. It may or may not be the actual root object of the model.
The model content root itself will not become visible in the underlying viewer, only the workspace resource it is
mapped to and its children will.
This implementation returns the resource
behind given model object
as model
content root. Clients should override this method if they require some other model object to be used instead.
The most typical use cases and implementations of this method are as follows:
resource
behind given model object is to be used as model content root:return object.eResource();
model root object
behind given model object is to be used as model content root:return EcoreUtil.getRootContainer(object);
object
- An arbitrary object
to be investigated.object
or resource
which is used as root of the model content
provided by this content provider for given model object or null
if given object is no model
object or has no parent that corresponds to the expected model content root.@Deprecated protected java.lang.Object getMappedModelRoot(org.eclipse.emf.ecore.EObject object)
getModelContentRoot(EObject)
instead.@Deprecated protected java.lang.Object getModelContentRoot(org.eclipse.emf.edit.provider.IWrapperItemProvider wrapperItemProvider)
getModelContentRoots(Resource)
instead.@Deprecated protected java.lang.Object getModelContentRoot(org.eclipse.emf.ecore.util.FeatureMap.Entry entry)
getModelContentRoots(Resource)
instead.@Deprecated protected java.lang.Object getModelContentRoot(TransientItemProvider transientItemProvider)
getModelContentRoots(Resource)
instead.@Deprecated protected org.eclipse.core.resources.IResource getUnderlyingWorkspaceResource(java.lang.Object modelContentRoot)
getWorkspaceResource(Resource)
instead.resource
corresponding to given model content
root
.modelContentRoot
- The model content root
object in question.resource
corresponding to given model content root.getModelContentRoot(Object)
protected org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider getModelContentProvider(java.lang.Object object)
protected org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider createModelContentProvider(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain)
protected org.eclipse.emf.common.notify.AdapterFactory getAdapterFactory(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain)
adapter factory
to be used by this content
provider
for creating item provider
s which control the way how model
element
s from given editingDomain
are displayed and can be edited.
This implementation returns the adapter factory
which is embedded in the given
editingDomain
by default. Clients which want to use an alternative adapter
factory
(e.g., an adapter factory
that creates item provider
s
which are specifically designed for the editor
in which this
content provider
is used) may override getCustomAdapterFactory()
and return any adapter factory
of their choice. This custom adapter
factory
will then be returned as result by this method.
editingDomain
- The editing domain
whose embedded adapter
factory
is to be returned as default. May be left null
if
getCustomAdapterFactory()
has been overridden and returns a non-null
result.adapter factory
that will be used by this content provider
. null
if no custom adapter factory
is provided
through getCustomAdapterFactory()
and no editingDomain
has been specified.getCustomAdapterFactory()
protected org.eclipse.emf.common.notify.AdapterFactory getCustomAdapterFactory()
adapter factory
to be used by this content provider
for creating item provider
s which control the way how
model element
s from given editingDomain
are displayed and can be edited.
This implementation returns null
as default. Clients which want to use their own
adapter factory
(e.g., an adapter factory
that creates
item provider
s which are specifically designed for the editor
in
which this content provider
is used) may override this method and return any
adapter factory
of their choice. This custom adapter factory
will
then be returned as result by getAdapterFactory(TransactionalEditingDomain)
.
adapter factory
that is to be used by this
content provider
. null
the default
adapter factory
returned by getAdapterFactory(TransactionalEditingDomain)
should be used instead.getAdapterFactory(TransactionalEditingDomain)
public void inputChanged(org.eclipse.jface.viewers.Viewer viewer, java.lang.Object oldInput, java.lang.Object newInput)
inputChanged
in interface org.eclipse.jface.viewers.IContentProvider
public java.lang.Object[] getElements(java.lang.Object inputElement)
getElements
in interface org.eclipse.jface.viewers.IStructuredContentProvider
getElements
in interface org.eclipse.jface.viewers.ITreeContentProvider
public boolean hasChildren(java.lang.Object element)
hasChildren
in interface org.eclipse.jface.viewers.ITreeContentProvider
public java.lang.Object[] getChildren(java.lang.Object parentElement)
getChildren
in interface org.eclipse.jface.viewers.ITreeContentProvider
public java.lang.Object getParent(java.lang.Object element)
getParent
in interface org.eclipse.jface.viewers.ITreeContentProvider
public void dispose()
dispose
in interface org.eclipse.jface.viewers.IContentProvider
protected void addTransactionalEditingDomainListeners(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain)
protected void removeTransactionalEditingDomainListeners(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain)
protected org.eclipse.emf.transaction.ResourceSetListener createResourceChangedListener()
protected org.eclipse.emf.transaction.ResourceSetListener createResourceMovedListener()
protected org.eclipse.emf.transaction.ResourceSetListener createCrossReferenceChangedListener()
protected org.eclipse.emf.transaction.ResourceSetListener createModelContentRootChangedListener()
!! Important note !! This is necessary because viewer refreshes triggered by the model content provider only affect the model content root objects but not the corresponding workspace resources. As the former are not represented by any tree item in the viewer none of these refreshes performed will have any visible effect.
protected void refreshViewerOnWorkspaceResources(java.util.Set<? extends org.eclipse.core.resources.IResource> resources)
resources
- protected void refreshViewerOnModelResources(java.util.Set<? extends org.eclipse.emf.ecore.resource.Resource> resources)
resources
- protected void refreshViewerOnModelObjects(java.util.Set<?> objects)
objects
- protected void refreshViewerOnObject(java.lang.Object object)
object
- protected void refreshViewer()