Class ECPProjectImpl
- java.lang.Object
-
- org.eclipse.emf.ecp.internal.core.util.Element
-
- org.eclipse.emf.ecp.internal.core.util.PropertiesElement
-
- org.eclipse.emf.ecp.internal.core.ECPProjectImpl
-
- All Implemented Interfaces:
java.lang.Cloneable
,java.lang.Comparable<ECPElement>
,ECPProject
,ECPContainer
,ECPElement
,ECPProjectAware
,ECPPropertiesAware
,ECPProviderAware
,ECPRepositoryAware
,PropertiesStore.StorableElement
,InternalProject
,ECPDisposable.DisposeListener
,org.eclipse.emf.edit.domain.IEditingDomainProvider
public final class ECPProjectImpl extends PropertiesElement implements InternalProject, ECPDisposable.DisposeListener
- Author:
- Eike Stepper, Eugen Neufeld
-
-
Field Summary
-
Fields inherited from interface org.eclipse.emf.ecp.core.ECPProject
TYPE
-
-
Constructor Summary
Constructors Constructor Description ECPProjectImpl(java.io.ObjectInput in)
Constructor used to load persisted projects on startup.ECPProjectImpl(ECPRepository repository, java.lang.String name, ECPProperties properties)
Constructor used when an online project is created.ECPProjectImpl(InternalProvider provider, java.lang.String name, ECPProperties properties)
Constructor used when an offline project is created.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
canDelete()
Whether this instance can be deleted or not.InternalProject
clone(java.lang.String name)
This method clones a project.void
close()
This closes an opened object.boolean
contains(java.lang.Object object)
Check whether a project contains an Object.void
delete()
Deletes the current instance.void
deleteElements(java.util.Collection<java.lang.Object> objects)
Deletes a collection ofObject
s by delegating the task to the provider.void
disposed(ECPDisposable disposable)
Callback method being used to notify listeners about a dispose.java.lang.Object
getAdapter(java.lang.Class adapterType)
Returns an object which is an instance of the given class associated with this object.org.eclipse.emf.common.util.EList<java.lang.Object>
getContents()
Returns the list of the direct content objects; each is of type Object.org.eclipse.emf.edit.domain.EditingDomain
getEditingDomain()
InternalProject
getProject()
This returns the project this object belongs to or references in any way.InternalProvider
getProvider()
This method returns the provider of this project.java.lang.Object
getProviderSpecificData()
This method returns the provider specific data of this project.java.util.Iterator<org.eclipse.emf.ecore.EObject>
getReferenceCandidates(org.eclipse.emf.ecore.EObject modelElement, org.eclipse.emf.ecore.EReference eReference)
Get all possibleEObject
s from the provider to which a reference can be added from a certainEObject
based on the type of theEReference
.InternalRepository
getRepository()
This method returns the repository this project is shared on.java.lang.String
getType()
This return the type of the object.java.util.Set<org.eclipse.emf.ecore.EPackage>
getUnsupportedEPackages()
Returns a collection ofEPackage
s which are not supported by the provider.java.util.Set<org.eclipse.emf.ecore.EClass>
getVisibleEClasses()
Get the currently visibleEClass
es.java.util.Set<org.eclipse.emf.ecore.EPackage>
getVisiblePackages()
Get the currently visibleEPackage
s.boolean
hasDirtyContents()
Checks whether the model, associated with this project is dirty.boolean
isModelRoot(java.lang.Object object)
This method checks whether the provided object is the model root of the project.boolean
isOpen()
Whether an object is open or not.boolean
isStorable()
void
notifyObjectsChanged(java.util.Collection<java.lang.Object> objects, boolean structural)
This method is a callback for the provider to notify the project about changes.void
notifyProvider(InternalProvider.LifecycleEvent event)
This method is used to notify the provider about aInternalProvider.LifecycleEvent
of this project.void
open()
This opens a closed object.protected void
propertiesChanged(java.util.Collection<java.util.Map.Entry<java.lang.String,java.lang.String>> oldProperties, java.util.Collection<java.util.Map.Entry<java.lang.String,java.lang.String>> newProperties)
Called if the properties of the element change.void
saveContents()
Saves the currently pending changes of the model.void
saveProperties()
Deprecated.void
setProviderSpecificData(java.lang.Object providerSpecificData)
This method sets the provider specific data of this project.void
setVisibleEClasses(java.util.Set<org.eclipse.emf.ecore.EClass> filteredEClasses)
Set the visibleEClass
es.void
setVisiblePackages(java.util.Set<org.eclipse.emf.ecore.EPackage> filteredPackages)
Set the visibleEPackage
s.void
undispose(InternalRepository repository)
This method undisposes the project based on a repository.void
write(java.io.ObjectOutput out)
-
Methods inherited from class org.eclipse.emf.ecp.internal.core.util.PropertiesElement
cleanup, getProperties
-
Methods inherited from class org.eclipse.emf.ecp.internal.core.util.Element
compareTo, equals, getName, hashCode, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.emf.ecp.core.util.ECPElement
getName
-
Methods inherited from interface org.eclipse.emf.ecp.core.util.ECPPropertiesAware
getProperties
-
-
-
-
Constructor Detail
-
ECPProjectImpl
public ECPProjectImpl(InternalProvider provider, java.lang.String name, ECPProperties properties)
Constructor used when an offline project is created.- Parameters:
provider
- theInternalProvider
of this projectname
- the name of the projectproperties
- the properties of the project
-
ECPProjectImpl
public ECPProjectImpl(ECPRepository repository, java.lang.String name, ECPProperties properties)
Constructor used when an online project is created.- Parameters:
repository
- theECPRepository
of this projectname
- the name of the projectproperties
- the properties of the project
-
ECPProjectImpl
public ECPProjectImpl(java.io.ObjectInput in) throws java.io.IOException
Constructor used to load persisted projects on startup.- Parameters:
in
- theObjectInput
to parse- Throws:
java.io.IOException
- is thrown when file can't be read.
-
-
Method Detail
-
write
public void write(java.io.ObjectOutput out) throws java.io.IOException
Description copied from class:PropertiesElement
- Specified by:
write
in interfacePropertiesStore.StorableElement
- Overrides:
write
in classPropertiesElement
- Throws:
java.io.IOException
-
getType
public java.lang.String getType()
This return the type of the object.
-
disposed
public void disposed(ECPDisposable disposable)
Callback method being used to notify listeners about a dispose.- Specified by:
disposed
in interfaceECPDisposable.DisposeListener
- Parameters:
disposable
- the object being disposed
-
isStorable
public boolean isStorable()
- Specified by:
isStorable
in interfacePropertiesStore.StorableElement
-
getProject
public InternalProject getProject()
This returns the project this object belongs to or references in any way.- Specified by:
getProject
in interfaceECPProjectAware
- Returns:
- the known
ECPProject
-
getRepository
public InternalRepository getRepository()
This method returns the repository this project is shared on.- Specified by:
getRepository
in interfaceECPRepositoryAware
- Specified by:
getRepository
in interfaceInternalProject
- Returns:
- the repository of this project or null if not shared
-
getProvider
public InternalProvider getProvider()
This method returns the provider of this project.- Specified by:
getProvider
in interfaceECPProviderAware
- Specified by:
getProvider
in interfaceInternalProject
- Returns:
- the provider of this project
-
getProviderSpecificData
public java.lang.Object getProviderSpecificData()
This method returns the provider specific data of this project.- Specified by:
getProviderSpecificData
in interfaceInternalProject
- Returns:
- the provider specific data of this project
-
setProviderSpecificData
public void setProviderSpecificData(java.lang.Object providerSpecificData)
This method sets the provider specific data of this project.- Specified by:
setProviderSpecificData
in interfaceInternalProject
- Parameters:
providerSpecificData
- the provider specific data of this project
-
notifyObjectsChanged
public void notifyObjectsChanged(java.util.Collection<java.lang.Object> objects, boolean structural)
This method is a callback for the provider to notify the project about changes.- Specified by:
notifyObjectsChanged
in interfaceInternalProject
- Parameters:
objects
- the objects that have changedstructural
- if the changes where structural (e.g. delete)
-
getEditingDomain
public org.eclipse.emf.edit.domain.EditingDomain getEditingDomain()
- Specified by:
getEditingDomain
in interfaceorg.eclipse.emf.edit.domain.IEditingDomainProvider
-
getAdapter
public java.lang.Object getAdapter(java.lang.Class adapterType)
Returns an object which is an instance of the given class associated with this object. Returnsnull
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; roughlyPlatform.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).- Parameters:
adapterType
- the class to adapt to- Returns:
- the adapted object or
null
- See Also:
IAdaptable#getAdapter(Class)
-
canDelete
public boolean canDelete()
Whether this instance can be deleted or not.- Specified by:
canDelete
in interfaceECPContainer
- Returns:
- true if this instance can be deleted, false otherwise.
-
delete
public void delete()
Deletes the current instance.- Specified by:
delete
in interfaceECPContainer
-
isOpen
public boolean isOpen()
Whether an object is open or not.- Specified by:
isOpen
in interfaceECPProject
- Returns:
- true if it is open, false otherwise
-
open
public void open()
This opens a closed object. If the object was already opened, nothing happens.- Specified by:
open
in interfaceECPProject
-
close
public void close()
This closes an opened object. If the object was already closed, nothing happens.- Specified by:
close
in interfaceECPProject
-
notifyProvider
public void notifyProvider(InternalProvider.LifecycleEvent event)
This method is used to notify the provider about aInternalProvider.LifecycleEvent
of this project.- Specified by:
notifyProvider
in interfaceInternalProject
- Parameters:
event
- to pass to the provider
-
undispose
public void undispose(InternalRepository repository)
This method undisposes the project based on a repository.- Specified by:
undispose
in interfaceInternalProject
- Parameters:
repository
- the repository
-
getContents
public org.eclipse.emf.common.util.EList<java.lang.Object> getContents()
Returns the list of the direct content objects; each is of type Object. The contents may be directly modified. Adding an object will remove it from the previous container;- Specified by:
getContents
in interfaceECPProject
- Returns:
- A list of
Object
-
getUnsupportedEPackages
public java.util.Set<org.eclipse.emf.ecore.EPackage> getUnsupportedEPackages()
Returns a collection ofEPackage
s which are not supported by the provider. EObjects from these packages cannot be created within the project.- Specified by:
getUnsupportedEPackages
in interfaceInternalProject
- Returns:
Collection
of unsupportedEPackage
s
-
setVisiblePackages
public void setVisiblePackages(java.util.Set<org.eclipse.emf.ecore.EPackage> filteredPackages)
Set the visibleEPackage
s. New model elements can only be created fromEPackage
s contained in the visiblePackages and theInternalProject.setVisibleEClasses(Set)
.- Specified by:
setVisiblePackages
in interfaceInternalProject
- Parameters:
filteredPackages
- theEPackage
s to be visible
-
getVisiblePackages
public java.util.Set<org.eclipse.emf.ecore.EPackage> getVisiblePackages()
Get the currently visibleEPackage
s. If no filter is set, then allEPackage
s supported by the provider are returned.- Specified by:
getVisiblePackages
in interfaceInternalProject
- Returns:
Set
ofEPackage
s that should be available, or all supported EPackages
-
getVisibleEClasses
public java.util.Set<org.eclipse.emf.ecore.EClass> getVisibleEClasses()
Get the currently visibleEClass
es. If no visibleEClass
es are set, then an emptySet
is returned.- Specified by:
getVisibleEClasses
in interfaceInternalProject
- Returns:
Set
ofEClass
es that should be available, or empty.
-
setVisibleEClasses
public void setVisibleEClasses(java.util.Set<org.eclipse.emf.ecore.EClass> filteredEClasses)
Set the visibleEClass
es.- Specified by:
setVisibleEClasses
in interfaceInternalProject
- Parameters:
filteredEClasses
- the classes that should be available
-
getReferenceCandidates
public java.util.Iterator<org.eclipse.emf.ecore.EObject> getReferenceCandidates(org.eclipse.emf.ecore.EObject modelElement, org.eclipse.emf.ecore.EReference eReference)
Get all possibleEObject
s from the provider to which a reference can be added from a certainEObject
based on the type of theEReference
.- Specified by:
getReferenceCandidates
in interfaceInternalProject
- Parameters:
modelElement
- - theEObject
for which the reference should be set.eReference
- - theEReference
to be set.- Returns:
Iterator
over allEObject
that can be added as a reference
-
saveContents
public void saveContents()
Saves the currently pending changes of the model. This method delegates to the provider.- Specified by:
saveContents
in interfaceECPProject
-
hasDirtyContents
public boolean hasDirtyContents()
Checks whether the model, associated with this project is dirty.- Specified by:
hasDirtyContents
in interfaceECPProject
- Returns:
- true if model is dirty, false otherwise
-
deleteElements
public void deleteElements(java.util.Collection<java.lang.Object> objects)
Deletes a collection ofObject
s by delegating the task to the provider.- Specified by:
deleteElements
in interfaceECPProject
- Parameters:
objects
- the collection ofObject
s to delete
-
clone
public InternalProject clone(java.lang.String name)
This method clones a project.- Specified by:
clone
in interfaceInternalProject
- Parameters:
name
- the name of the project to create- Returns:
- the cloned project
-
propertiesChanged
protected void propertiesChanged(java.util.Collection<java.util.Map.Entry<java.lang.String,java.lang.String>> oldProperties, java.util.Collection<java.util.Map.Entry<java.lang.String,java.lang.String>> newProperties)
Description copied from class:PropertiesElement
Called if the properties of the element change. Can be implemented by subclasses- Overrides:
propertiesChanged
in classPropertiesElement
- Parameters:
oldProperties
- the old propertiesnewProperties
- the new properties
-
saveProperties
@Deprecated public void saveProperties()
Deprecated.You must not call this anymore as properties are save automatically now.- Specified by:
saveProperties
in interfaceInternalProject
-
isModelRoot
public boolean isModelRoot(java.lang.Object object)
This method checks whether the provided object is the model root of the project.- Specified by:
isModelRoot
in interfaceInternalProject
- Parameters:
object
- the object to check- Returns:
- true if the object is the root of the model of this project, false otherwise
-
contains
public boolean contains(java.lang.Object object)
Check whether a project contains an Object.- Specified by:
contains
in interfaceInternalProject
- Parameters:
object
- the object to check for containment- Returns:
- true if the object is in the project, false otherwise
-
-