org.eclipse.emf.ecp.spi.core
Class DefaultProvider

java.lang.Object
  extended by org.eclipse.emf.ecp.internal.core.util.Element
      extended by org.eclipse.emf.ecp.spi.core.DefaultProvider
All Implemented Interfaces:
Comparable<ECPElement>, org.eclipse.core.runtime.IAdaptable, ECPProvider, ECPElement, ECPModelContextProvider, ECPProviderAware, InternalProvider, AdapterProvider, ECPDisposable, InternalRegistryElement
Direct Known Subclasses:
CDOProvider, EMFStoreProvider, WorkspaceProvider

public abstract class DefaultProvider
extends Element
implements InternalProvider

Since:
1.1
Author:
Eike Stepper

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.eclipse.emf.ecp.spi.core.InternalProvider
InternalProvider.LifecycleEvent
 
Nested classes/interfaces inherited from interface org.eclipse.emf.ecp.spi.core.util.ECPDisposable
ECPDisposable.DisposeListener
 
Field Summary
 
Fields inherited from interface org.eclipse.emf.ecp.spi.core.InternalProvider
EMF_ADAPTER_FACTORY
 
Fields inherited from interface org.eclipse.emf.ecp.core.ECPProvider
TYPE
 
Method Summary
 void addDisposeListener(ECPDisposable.DisposeListener listener)
          Adds a ECPDisposable.DisposeListener to this instance.
 boolean contains(InternalProject project, Object object)
          Checks whether a specific project contains a specific object.
 org.eclipse.emf.edit.domain.EditingDomain createEditingDomain(InternalProject project)
          This method creates an editing domain each time it is called.
 void dispose()
          Disposes the current instance.
 void doSave(InternalProject project)
          Convenient implementation where nothing happens.
 void fillChildren(ECPContainer context, Object parent, InternalChildrenList childrenList)
          Fills the elements of a certain parent object, depending on the context into the childrenList.
 Object getAdapter(Class adapterType)
          Returns an object which is an instance of the given class associated with this object.
<T> T
getAdapter(Object adaptable, Class<T> adapterType)
          
 String getDescription()
          Return the description.
 String getLabel()
          Label of the ECPProvider.
 Iterator<org.eclipse.emf.ecore.EObject> getLinkElements(InternalProject project, org.eclipse.emf.ecore.EObject modelElement, org.eclipse.emf.ecore.EReference eReference)
          Convenient implementation of the getLinkElements(InternalProject, EObject, EReference) method to use the ItemPropertyDescriptor to get all object of an object.
 ECPContainer getModelContext(Object element)
          Returns the first ECPContainer that can be found for the provided Object.
 Set<InternalProject> getOpenProjects()
          Array of all ECPProjects based on this ECPProvider which are open.
 InternalProvider getProvider()
          The Provider this class references in any way.
 String getType()
          This return the type of the object.
 AdapterProvider getUIProvider()
          Allows access of the corresponding UI Adapter.
 Set<org.eclipse.emf.ecore.EPackage> getUnsupportedEPackages(Collection<org.eclipse.emf.ecore.EPackage> packages, InternalRepository repository)
          Convenient implementation of the getUnsupportedEPackages(Collection,InternalRepository) method to return an empty list.
 void handleLifecycle(ECPContainer context, InternalProvider.LifecycleEvent event)
          This method is called to handle a specific life cycle.
 boolean hasCreateProjectWithoutRepositorySupport()
          Convenient implementation that return false.
 boolean hasCreateRepositorySupport()
          Check whether a new repository can be added to this ECPProvider.
 boolean isDirty(InternalProject project)
          Convenient implementation where the provider saves changes of the project automatically, so a project never gets dirty.
 boolean isDisposed()
          Whether this instance is already disposed.
 boolean isSlow(Object parent)
          Whether this provider is slow or not.
 boolean modelExists(InternalProject project)
          Convenient implementation that return true during this check.
 void removeDisposeListener(ECPDisposable.DisposeListener listener)
          Removed a ECPDisposable.DisposeListener from this instance.
 void setDescription(String description)
          Sets the description.
 void setLabel(String label)
          Sets the label.
 void setUIProvider(AdapterProvider uiProvider)
          Allows to set the uiProvider.
 
Methods inherited from class org.eclipse.emf.ecp.internal.core.util.Element
compareTo, equals, getName, hashCode, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eclipse.emf.ecp.spi.core.InternalProvider
cloneProject, delete, getElements, getRoot, isThreadSafe
 
Methods inherited from interface org.eclipse.emf.ecp.core.util.ECPElement
getName
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Method Detail

getType

public final String getType()
This return the type of the object.

Specified by:
getType in class Element
Returns:
the type

getProvider

public final InternalProvider getProvider()
The Provider this class references in any way.

Specified by:
getProvider in interface ECPProviderAware
Returns:
the known ECPProvider

getLabel

public final String getLabel()
Label of the ECPProvider.

Specified by:
getLabel in interface ECPProvider
Specified by:
getLabel in interface InternalRegistryElement
Returns:
the name of the ECPProvider

setLabel

public final void setLabel(String label)
Sets the label.

Specified by:
setLabel in interface InternalRegistryElement
Parameters:
label - the Label to set

getDescription

public final String getDescription()
Return the description.

Specified by:
getDescription in interface InternalRegistryElement
Returns:
the description

setDescription

public final void setDescription(String description)
Sets the description.

Specified by:
setDescription in interface InternalRegistryElement
Parameters:
description - the Description to set

getUIProvider

public final AdapterProvider getUIProvider()
Allows access of the corresponding UI Adapter.

Specified by:
getUIProvider in interface InternalProvider
Returns:
the UIProvider for this provider

setUIProvider

public final void setUIProvider(AdapterProvider uiProvider)
Allows to set the uiProvider.

Specified by:
setUIProvider in interface InternalProvider
Parameters:
uiProvider - the uiProvider to set

getOpenProjects

public final Set<InternalProject> getOpenProjects()
Array of all ECPProjects based on this ECPProvider which are open.

Specified by:
getOpenProjects in interface InternalProvider
Returns:
open projects using this ECPProvider

isDisposed

public final boolean isDisposed()
Whether this instance is already disposed.

Specified by:
isDisposed in interface ECPDisposable
Returns:
true if already disposed, false otherwise.

dispose

public final void dispose()
Disposes the current instance.

Specified by:
dispose in interface ECPDisposable

addDisposeListener

public final void addDisposeListener(ECPDisposable.DisposeListener listener)
Adds a ECPDisposable.DisposeListener to this instance.

Specified by:
addDisposeListener in interface ECPDisposable
Parameters:
listener - the listener to add

removeDisposeListener

public final void removeDisposeListener(ECPDisposable.DisposeListener listener)
Removed a ECPDisposable.DisposeListener from this instance.

Specified by:
removeDisposeListener in interface ECPDisposable
Parameters:
listener - the listener to remove

getAdapter

public <T> T getAdapter(Object adaptable,
                        Class<T> adapterType)

Specified by:
getAdapter in interface AdapterProvider

getAdapter

public Object getAdapter(Class adapterType)
Returns an object which is an instance of the given class associated with this object. Returns null if no such object can be found.

This implementation of the method declared by IAdaptable passes the request along to the platform's adapter manager; roughly Platform.getAdapterManager().getAdapter(this, adapter). Subclasses may override this method (however, if they do so, they should invoke the method on their superclass to ensure that the Platform's adapter manager is consulted).

Specified by:
getAdapter in interface org.eclipse.core.runtime.IAdaptable
Parameters:
adapterType - the class to adapt to
Returns:
the adapted object or null
See Also:
IAdaptable.getAdapter(Class)

createEditingDomain

public org.eclipse.emf.edit.domain.EditingDomain createEditingDomain(InternalProject project)
This method creates an editing domain each time it is called.

Specified by:
createEditingDomain in interface InternalProvider
Parameters:
project - the InternalProject to create the domain for.
Returns:
the created EditingDomain

hasCreateRepositorySupport

public boolean hasCreateRepositorySupport()
Check whether a new repository can be added to this ECPProvider.

Specified by:
hasCreateRepositorySupport in interface ECPProvider
Returns:
true if new repositories can be added.

isSlow

public boolean isSlow(Object parent)
Whether this provider is slow or not. Slow objects are handled differently.

Specified by:
isSlow in interface InternalProvider
Parameters:
parent - to check
Returns:
true if slow, false otherwise

getModelContext

public ECPContainer getModelContext(Object element)
Returns the first ECPContainer that can be found for the provided Object.

Specified by:
getModelContext in interface ECPModelContextProvider
Parameters:
element - the element to search the ECPContainer for
Returns:
the ECPContainer of this element

fillChildren

public void fillChildren(ECPContainer context,
                         Object parent,
                         InternalChildrenList childrenList)
Fills the elements of a certain parent object, depending on the context into the childrenList.

Specified by:
fillChildren in interface InternalProvider
Parameters:
context - the context to use
parent - the parent to read the children from
childrenList - the list to fill

handleLifecycle

public void handleLifecycle(ECPContainer context,
                            InternalProvider.LifecycleEvent event)
This method is called to handle a specific life cycle.

Specified by:
handleLifecycle in interface InternalProvider
Parameters:
context - the context to handle the lifecycle for
event - the lifecycle event to handle

getUnsupportedEPackages

public Set<org.eclipse.emf.ecore.EPackage> getUnsupportedEPackages(Collection<org.eclipse.emf.ecore.EPackage> packages,
                                                                   InternalRepository repository)
Convenient implementation of the getUnsupportedEPackages(Collection,InternalRepository) method to return an empty list. The provider has to Override this method if not all EPackages are supported.

Specified by:
getUnsupportedEPackages in interface InternalProvider
Parameters:
packages - available packages
repository - the repository to check
Returns:
the Collection of EPackages unsupported by this provider for the specified repository

getLinkElements

public Iterator<org.eclipse.emf.ecore.EObject> getLinkElements(InternalProject project,
                                                               org.eclipse.emf.ecore.EObject modelElement,
                                                               org.eclipse.emf.ecore.EReference eReference)
Convenient implementation of the getLinkElements(InternalProject, EObject, EReference) method to use the ItemPropertyDescriptor to get all object of an object.

Specified by:
getLinkElements in interface InternalProvider
Parameters:
project - the project the call is from
modelElement - EObject to add the EReference to
eReference - the EReference to add
Returns:
Iterator of EObject that can be linked

doSave

public void doSave(InternalProject project)
Convenient implementation where nothing happens.

Specified by:
doSave in interface InternalProvider
Parameters:
project - the project to save

isDirty

public boolean isDirty(InternalProject project)
Convenient implementation where the provider saves changes of the project automatically, so a project never gets dirty. Thus this returns false.

Specified by:
isDirty in interface InternalProvider
Parameters:
project - the project to check
Returns:
false

modelExists

public boolean modelExists(InternalProject project)
Convenient implementation that return true during this check.

Specified by:
modelExists in interface InternalProvider
Parameters:
project - the project to check
Returns:
true

hasCreateProjectWithoutRepositorySupport

public boolean hasCreateProjectWithoutRepositorySupport()
Convenient implementation that return false.

Specified by:
hasCreateProjectWithoutRepositorySupport in interface ECPProvider
Returns:
false

contains

public boolean contains(InternalProject project,
                        Object object)
Checks whether a specific project contains a specific object.

Specified by:
contains in interface InternalProvider
Parameters:
project - the project to check
object - the object to check
Returns:
true if the project contains such an object, false otherwise


Copyright © 2015. All Rights Reserved.