org.eclipse.emf.edit.domain
Class AdapterFactoryEditingDomain

java.lang.Object
  extended byorg.eclipse.emf.edit.domain.AdapterFactoryEditingDomain
All Implemented Interfaces:
EditingDomain
Direct Known Subclasses:
AdapterFactoryMappingDomain

public class AdapterFactoryEditingDomain
extends Object
implements EditingDomain

This class implements an editing domain by delegating to adapters that implement IEditingDomainItemProvider.


Nested Class Summary
protected  class AdapterFactoryEditingDomain.AdapterFactoryEditingDomainResourceSet
          This is an implementation of a context that knows about this editing domain.
static class AdapterFactoryEditingDomain.DomainTreeIterator
          This implements an tree iterator that iterates over an object, it's domain children, their domain children, and so on.
static class AdapterFactoryEditingDomain.EditingDomainProvider
          This class is an adapter than implements IEditingDomainProvider.
 
Field Summary
protected  AdapterFactory adapterFactory
          This is the adapter factory used to create the adapter to which calls are delegated.
protected  Collection clipboard
          This is the current clipboard.
protected  CommandStack commandStack
          This is the command stack that was passed into the constructor.
protected  boolean optimizeCopy
          This controls whether or not copy command optimizations are safe in this domain.
protected  ResourceSet resourceSet
          This is the resource set used to contain all created and loaded resources.
protected  Map resourceToReadOnlyMap
          This controls whether the domain is read only.
 
Constructor Summary
AdapterFactoryEditingDomain(AdapterFactory adapterFactory, CommandStack commandStack)
          Create an instance from the adapter factory, and the specialized command stack.
AdapterFactoryEditingDomain(AdapterFactory adapterFactory, CommandStack commandStack, Map resourceToReadOnlyMap)
          Create an instance from the adapter factory, the specialized command stack, and the map used to maintain read only state.
AdapterFactoryEditingDomain(AdapterFactory adapterFactory, CommandStack commandStack, ResourceSet resourceSet)
          Create an instance from the adapter factory, the specialized command stack, and the specialized resource set.
 
Method Summary
 Command createCommand(Class commandClass, CommandParameter commandParameter)
          This delegates to IEditingDomainItemProvider.createCommand.
 Command createOverrideCommand(OverrideableCommand command)
          This just returns null, since this is an optional feature that we don't support here.
 Resource createResource(String fileNameURI)
          This is a convenience method to create a resource, you could use the resource set returned by getResourceSet() directly.
 AdapterFactory getAdapterFactory()
          This returns the adapter factory used by this domain.
 Collection getChildren(Object object)
          This delegates to IEditingDomainItemProvider.getChildren.
 Collection getClipboard()
          This returns the clipboard of the editing domain.
 CommandStack getCommandStack()
          This returns the command stack provided in the constructor.
static EditingDomain getEditingDomainFor(EObject object)
          This returns the editing domain of the given EMF object, or null, if it can't be determined.
static EditingDomain getEditingDomainFor(Object object)
          This returns the editing domain for the given aribtrary object, or null, if it can't be determined.
static IEditingDomainItemProvider getEditingDomainItemProviderFor(Object object)
          This is a convenient way to determine the adapter to which editing domain methods are delegated for a given object, by providing nothing more than the object itself.
 Collection getNewChildDescriptors(Object object, Object sibling)
          This delegates to IEditingDomainItemProvider.getNewChildDescriptors.
 boolean getOptimizeCopy()
          This returns whether or not copy command optimizations are safe in this domain.
 Object getParent(Object object)
          This delegates to IEditingDomainItemProvider.getParent.
 ResourceSet getResourceSet()
          This returns the resource set used to contain all created and loaded resources.
 Map getResourceToReadOnlyMap()
          Returns the map of resource to a Boolean value indicating whether the resource is read only.
 Object getRoot(Object object)
          This returns the root of the object, i.e., .
 List getTreePath(Object object)
          This returns a path list from the root object to the given object in the tree.
 Object getWrapper(Object object)
           
 boolean isControllable(Object object)
          This returns whether or not the domain allows the given object to be moved to a different resource from its container.
static boolean isControlled(Object object)
          This returns whether or not an object has been moved to a different resource from its container.
 boolean isReadOnly(Resource resource)
          This returns whether the resource is read only.
protected  boolean isReadOnlyURI(URI uri)
          Returns whether to expect that the resource corresponding to the given URI form will be read only.
 Resource loadResource(String fileNameURI)
          This is a convenience method to load a resource, you could use the resource set returned by getResourceSet() directly.
 void setAdapterFactory(AdapterFactory adapterFactory)
          This sets the adapter factory after the domain is already created.
 void setClipboard(Collection clipboard)
          This sets the clipboard of the editing domain.
 void setOptimizeCopy(boolean optimizeCopy)
          This sets whether or not copy command optimizations are safe in this domain.
 void setResourceToReadOnlyMap(Map resourceToReadOnlyMap)
          Set the map of resource to a Boolean value indicating whether the resource is read only.
 TreeIterator treeIterator(Object object)
          This returns a tree iterator that will yield the object, the children of the object, their children, and so on.
static Object unwrap(Object object)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

adapterFactory

protected AdapterFactory adapterFactory
This is the adapter factory used to create the adapter to which calls are delegated.


commandStack

protected CommandStack commandStack
This is the command stack that was passed into the constructor.


resourceSet

protected ResourceSet resourceSet
This is the resource set used to contain all created and loaded resources.


clipboard

protected Collection clipboard
This is the current clipboard.


optimizeCopy

protected boolean optimizeCopy
This controls whether or not copy command optimizations are safe in this domain.


resourceToReadOnlyMap

protected Map resourceToReadOnlyMap
This controls whether the domain is read only.

Constructor Detail

AdapterFactoryEditingDomain

public AdapterFactoryEditingDomain(AdapterFactory adapterFactory,
                                   CommandStack commandStack)
Create an instance from the adapter factory, and the specialized command stack.


AdapterFactoryEditingDomain

public AdapterFactoryEditingDomain(AdapterFactory adapterFactory,
                                   CommandStack commandStack,
                                   Map resourceToReadOnlyMap)
Create an instance from the adapter factory, the specialized command stack, and the map used to maintain read only state.


AdapterFactoryEditingDomain

public AdapterFactoryEditingDomain(AdapterFactory adapterFactory,
                                   CommandStack commandStack,
                                   ResourceSet resourceSet)
Create an instance from the adapter factory, the specialized command stack, and the specialized resource set. If the resource set's context is null, one will be created here; otherwize, the existing context should implement IEditingDomainProvider.

Method Detail

getEditingDomainFor

public static EditingDomain getEditingDomainFor(EObject object)
This returns the editing domain of the given EMF object, or null, if it can't be determined. This is implemented by checking whether the ResourceSet of the object implements IEditingDomainProvider and returns that result or null.

Just as for getEditingDomainFor(Object), it is recommended that you always keep an editing domain instance available through some other means.


getEditingDomainFor

public static EditingDomain getEditingDomainFor(Object object)
This returns the editing domain for the given aribtrary object, or null, if it can't be determined. It is recommended that you always work directly with an EditingDomain instance whenever possible. This is implemented to checks if the object itself implements IEditingDomainProvider and returns that result. Otherwise it checks if it is valid to call getEditingDomainFor(EObject) and returns that result or null.

It is recommended that you always keep an editing domain instance available through some other means; this should only be used to implement things such as a global popup action for some object; in such a cases such as that the editing domain returned here may well be one that belongs to some editor you know nothing about, which is what you want.


getEditingDomainItemProviderFor

public static IEditingDomainItemProvider getEditingDomainItemProviderFor(Object object)
This is a convenient way to determine the adapter to which editing domain methods are delegated for a given object, by providing nothing more than the object itself. It is recommended that you always work directly with an EditingDomain instance whenever possible. If the object is an EMF object, this is implemented to call getEditingDomainFor(Object) and to return the adapter returned from the domain's adapter factory. If the object itself is an IEditingDomainItemProvider, it returns the object. Otherwise, it returns null.


getAdapterFactory

public AdapterFactory getAdapterFactory()
This returns the adapter factory used by this domain.


setAdapterFactory

public void setAdapterFactory(AdapterFactory adapterFactory)
This sets the adapter factory after the domain is already created.


createResource

public Resource createResource(String fileNameURI)
This is a convenience method to create a resource, you could use the resource set returned by getResourceSet() directly.

Specified by:
createResource in interface EditingDomain

loadResource

public Resource loadResource(String fileNameURI)
This is a convenience method to load a resource, you could use the resource set returned by getResourceSet() directly.

Specified by:
loadResource in interface EditingDomain

getResourceSet

public ResourceSet getResourceSet()
This returns the resource set used to contain all created and loaded resources.

Specified by:
getResourceSet in interface EditingDomain

createCommand

public Command createCommand(Class commandClass,
                             CommandParameter commandParameter)
This delegates to IEditingDomainItemProvider.createCommand.

Specified by:
createCommand in interface EditingDomain

createOverrideCommand

public Command createOverrideCommand(OverrideableCommand command)
This just returns null, since this is an optional feature that we don't support here.

Specified by:
createOverrideCommand in interface EditingDomain

getCommandStack

public CommandStack getCommandStack()
This returns the command stack provided in the constructor.

Specified by:
getCommandStack in interface EditingDomain

getChildren

public Collection getChildren(Object object)
This delegates to IEditingDomainItemProvider.getChildren.

Specified by:
getChildren in interface EditingDomain

getParent

public Object getParent(Object object)
This delegates to IEditingDomainItemProvider.getParent.

Specified by:
getParent in interface EditingDomain

getRoot

public Object getRoot(Object object)
Description copied from interface: EditingDomain
This returns the root of the object, i.e., .

Specified by:
getRoot in interface EditingDomain

getWrapper

public Object getWrapper(Object object)

unwrap

public static Object unwrap(Object object)

getNewChildDescriptors

public Collection getNewChildDescriptors(Object object,
                                         Object sibling)
This delegates to IEditingDomainItemProvider.getNewChildDescriptors.

Specified by:
getNewChildDescriptors in interface EditingDomain

getClipboard

public Collection getClipboard()
This returns the clipboard of the editing domain.

Specified by:
getClipboard in interface EditingDomain

setClipboard

public void setClipboard(Collection clipboard)
This sets the clipboard of the editing domain.

Specified by:
setClipboard in interface EditingDomain

getOptimizeCopy

public boolean getOptimizeCopy()
This returns whether or not copy command optimizations are safe in this domain.

Specified by:
getOptimizeCopy in interface EditingDomain

setOptimizeCopy

public void setOptimizeCopy(boolean optimizeCopy)
This sets whether or not copy command optimizations are safe in this domain.


getResourceToReadOnlyMap

public Map getResourceToReadOnlyMap()
Returns the map of resource to a Boolean value indicating whether the resource is read only.


setResourceToReadOnlyMap

public void setResourceToReadOnlyMap(Map resourceToReadOnlyMap)
Set the map of resource to a Boolean value indicating whether the resource is read only.


isReadOnly

public boolean isReadOnly(Resource resource)
This returns whether the resource is read only.

Specified by:
isReadOnly in interface EditingDomain

isReadOnlyURI

protected boolean isReadOnlyURI(URI uri)
Returns whether to expect that the resource corresponding to the given URI form will be read only.


treeIterator

public TreeIterator treeIterator(Object object)
This returns a tree iterator that will yield the object, the children of the object, their children, and so on.

Specified by:
treeIterator in interface EditingDomain

getTreePath

public List getTreePath(Object object)
This returns a path list from the root object to the given object in the tree.

Specified by:
getTreePath in interface EditingDomain

isControllable

public boolean isControllable(Object object)
This returns whether or not the domain allows the given object to be moved to a different resource from its container. In this implementation, an EObject is controllable if it has a container, it is contained via a feature that allows proxy resolution, and neither it nor its container is in a read-only resource.

Specified by:
isControllable in interface EditingDomain

isControlled

public static boolean isControlled(Object object)
This returns whether or not an object has been moved to a different resource from its container. It is a simple convenience method that compares the two resource of the two objects.


Copyright 2001-2006 IBM Corporation and others.
All Rights Reserved.