org.eclipse.emf.ecp.internal.core
Class ECPProjectImpl

java.lang.Object
  extended by org.eclipse.emf.ecp.internal.core.util.Element
      extended by org.eclipse.emf.ecp.internal.core.util.PropertiesElement
          extended by org.eclipse.emf.ecp.internal.core.ECPProjectImpl
All Implemented Interfaces:
Cloneable, 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
ECPProjectImpl(ECPRepository repository, String name, ECPProperties properties)
          Constructor used when an online project is created.
ECPProjectImpl(InternalProvider provider, String name, ECPProperties properties)
          Constructor used when an offline project is created.
ECPProjectImpl(ObjectInput in)
          Constructor used to load persisted projects on startup.
 
Method Summary
 boolean canDelete()
          Whether this instance can be deleted or not.
 InternalProject clone(String name)
          This method clones a project.
 void close()
          This closes an opened object.
 boolean contains(Object object)
          Check whether a project contains an Object.
 void delete()
          Deletes the current instance.
 void deleteElements(Collection<Object> objects)
          Deletes a collection of Objects by delegating the task to the provider.
 void disposed(ECPDisposable disposable)
          Callback method being used to notify listeners about a dispose.
 Object getAdapter(Class adapterType)
          Returns an object which is an instance of the given class associated with this object.
 org.eclipse.emf.common.util.EList<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.
 Object getProviderSpecificData()
          This method returns the provider specific data of this project.
 Iterator<org.eclipse.emf.ecore.EObject> getReferenceCandidates(org.eclipse.emf.ecore.EObject modelElement, org.eclipse.emf.ecore.EReference eReference)
          Get all possible EObjects from the provider to which a reference can be added from a certain EObject based on the type of the EReference.
 InternalRepository getRepository()
          This method returns the repository this project is shared on.
 String getType()
          This return the type of the object.
 Set<org.eclipse.emf.ecore.EPackage> getUnsupportedEPackages()
          Returns a collection of EPackages which are not supported by the provider.
 Set<org.eclipse.emf.ecore.EClass> getVisibleEClasses()
          Get the currently visible EClasses.
 Set<org.eclipse.emf.ecore.EPackage> getVisiblePackages()
          Get the currently visible EPackages.
 boolean hasDirtyContents()
          Checks whether the model, associated with this project is dirty.
 boolean isModelRoot(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(Collection<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 a InternalProvider.LifecycleEvent of this project.
 void open()
          This opens a closed object.
 void saveContents()
          Saves the currently pending changes of the model.
 void saveProperties()
          Deprecated. 
 void setProviderSpecificData(Object providerSpecificData)
          This method sets the provider specific data of this project.
 void setVisibleEClasses(Set<org.eclipse.emf.ecore.EClass> filteredEClasses)
          Set the visible EClasses.
 void setVisiblePackages(Set<org.eclipse.emf.ecore.EPackage> filteredPackages)
          Set the visible EPackages.
 void undispose(InternalRepository repository)
          This method undisposes the project based on a repository.
 void write(ObjectOutput out)
          
 
Methods inherited from class org.eclipse.emf.ecp.internal.core.util.PropertiesElement
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
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eclipse.emf.ecp.core.util.ECPElement
getName
 
Methods inherited from interface java.lang.Comparable
compareTo
 
Methods inherited from interface org.eclipse.emf.ecp.core.util.ECPPropertiesAware
getProperties
 

Constructor Detail

ECPProjectImpl

public ECPProjectImpl(InternalProvider provider,
                      String name,
                      ECPProperties properties)
Constructor used when an offline project is created.

Parameters:
provider - the InternalProvider of this project
name - the name of the project
properties - the properties of the project

ECPProjectImpl

public ECPProjectImpl(ECPRepository repository,
                      String name,
                      ECPProperties properties)
Constructor used when an online project is created.

Parameters:
repository - the ECPRepository of this project
name - the name of the project
properties - the properties of the project

ECPProjectImpl

public ECPProjectImpl(ObjectInput in)
               throws IOException
Constructor used to load persisted projects on startup.

Parameters:
in - the ObjectInput to parse
Throws:
IOException - is thrown when file can't be read.
Method Detail

write

public void write(ObjectOutput out)
           throws IOException
Description copied from class: PropertiesElement

Specified by:
write in interface PropertiesStore.StorableElement
Overrides:
write in class PropertiesElement
Throws:
IOException

getType

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

Specified by:
getType in class Element
Returns:
the type

disposed

public void disposed(ECPDisposable disposable)
Callback method being used to notify listeners about a dispose.

Specified by:
disposed in interface ECPDisposable.DisposeListener
Parameters:
disposable - the object being disposed

isStorable

public boolean isStorable()

Specified by:
isStorable in interface PropertiesStore.StorableElement

getProject

public InternalProject getProject()
This returns the project this object belongs to or references in any way.

Specified by:
getProject in interface ECPProjectAware
Returns:
the known ECPProject

getRepository

public InternalRepository getRepository()
This method returns the repository this project is shared on.

Specified by:
getRepository in interface ECPRepositoryAware
Specified by:
getRepository in interface InternalProject
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 interface ECPProviderAware
Specified by:
getProvider in interface InternalProject
Returns:
the provider of this project

getProviderSpecificData

public Object getProviderSpecificData()
This method returns the provider specific data of this project.

Specified by:
getProviderSpecificData in interface InternalProject
Returns:
the provider specific data of this project

setProviderSpecificData

public void setProviderSpecificData(Object providerSpecificData)
This method sets the provider specific data of this project.

Specified by:
setProviderSpecificData in interface InternalProject
Parameters:
providerSpecificData - the provider specific data of this project

notifyObjectsChanged

public void notifyObjectsChanged(Collection<Object> objects,
                                 boolean structural)
This method is a callback for the provider to notify the project about changes.

Specified by:
notifyObjectsChanged in interface InternalProject
Parameters:
objects - the objects that have changed
structural - if the changes where structural (e.g. delete)

getEditingDomain

public org.eclipse.emf.edit.domain.EditingDomain getEditingDomain()

Specified by:
getEditingDomain in interface org.eclipse.emf.edit.domain.IEditingDomainProvider

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).

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 interface ECPContainer
Returns:
true if this instance can be deleted, false otherwise.

delete

public void delete()
Deletes the current instance.

Specified by:
delete in interface ECPContainer

isOpen

public boolean isOpen()
Whether an object is open or not.

Specified by:
isOpen in interface ECPProject
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 interface ECPProject

close

public void close()
This closes an opened object. If the object was already closed, nothing happens.

Specified by:
close in interface ECPProject

notifyProvider

public void notifyProvider(InternalProvider.LifecycleEvent event)
This method is used to notify the provider about a InternalProvider.LifecycleEvent of this project.

Specified by:
notifyProvider in interface InternalProject
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 interface InternalProject
Parameters:
repository - the repository

getContents

public org.eclipse.emf.common.util.EList<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 interface ECPProject
Returns:
A list of Object

getUnsupportedEPackages

public Set<org.eclipse.emf.ecore.EPackage> getUnsupportedEPackages()
Returns a collection of EPackages which are not supported by the provider. EObjects from these packages cannot be created within the project.

Specified by:
getUnsupportedEPackages in interface InternalProject
Returns:
Collection of unsupported EPackages

setVisiblePackages

public void setVisiblePackages(Set<org.eclipse.emf.ecore.EPackage> filteredPackages)
Set the visible EPackages. New model elements can only be created from EPackages contained in the visiblePackages and the InternalProject.setVisibleEClasses(Set).

Specified by:
setVisiblePackages in interface InternalProject
Parameters:
filteredPackages - the EPackages to be visible

getVisiblePackages

public Set<org.eclipse.emf.ecore.EPackage> getVisiblePackages()
Get the currently visible EPackages. If no filter is set, then all EPackages supported by the provider are returned.

Specified by:
getVisiblePackages in interface InternalProject
Returns:
Set of EPackages that should be available, or all supported EPackages

getVisibleEClasses

public Set<org.eclipse.emf.ecore.EClass> getVisibleEClasses()
Get the currently visible EClasses. If no visible EClasses are set, then an empty Set is returned.

Specified by:
getVisibleEClasses in interface InternalProject
Returns:
Set of EClasses that should be available, or empty.

setVisibleEClasses

public void setVisibleEClasses(Set<org.eclipse.emf.ecore.EClass> filteredEClasses)
Set the visible EClasses.

Specified by:
setVisibleEClasses in interface InternalProject
Parameters:
filteredEClasses - the classes that should be available

getReferenceCandidates

public Iterator<org.eclipse.emf.ecore.EObject> getReferenceCandidates(org.eclipse.emf.ecore.EObject modelElement,
                                                                      org.eclipse.emf.ecore.EReference eReference)
Get all possible EObjects from the provider to which a reference can be added from a certain EObject based on the type of the EReference.

Specified by:
getReferenceCandidates in interface InternalProject
Parameters:
modelElement - - the EObject for which the reference should be set.
eReference - - the EReference to be set.
Returns:
Iterator over all EObject 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 interface ECPProject

hasDirtyContents

public boolean hasDirtyContents()
Checks whether the model, associated with this project is dirty.

Specified by:
hasDirtyContents in interface ECPProject
Returns:
true if model is dirty, false otherwise

deleteElements

public void deleteElements(Collection<Object> objects)
Deletes a collection of Objects by delegating the task to the provider.

Specified by:
deleteElements in interface ECPProject
Parameters:
objects - the collection of Objects to delete

clone

public InternalProject clone(String name)
This method clones a project.

Specified by:
clone in interface InternalProject
Parameters:
name - the name of the project to create
Returns:
the cloned project

saveProperties

@Deprecated
public void saveProperties()
Deprecated. 

You must not call this anymore as properties are save automatically now.

Specified by:
saveProperties in interface InternalProject

isModelRoot

public boolean isModelRoot(Object object)
This method checks whether the provided object is the model root of the project.

Specified by:
isModelRoot in interface InternalProject
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(Object object)
Check whether a project contains an Object.

Specified by:
contains in interface InternalProject
Parameters:
object - the object to check for containment
Returns:
true if the object is in the project, false otherwise


Copyright © 2015. All Rights Reserved.