## org.eclipse.emf.edit.domain
Class AdapterFactoryEditingDomain

    java.lang.Object
      org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain

All Implemented Interfaces:
  EditingDomain

Direct Known Subclasses:
  AdapterFactoryMappingDomain

    public class AdapterFactoryEditingDomain

extends java.lang.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<E>` 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 java.util.Collection<java.lang.Object>` `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 java.util.Map<Resource,java.lang.Boolean>` `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, java.util.Map<Resource,java.lang.Boolean> 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(java.lang.Class<? extends Command> 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(java.lang.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.
`java.util.Collection<?>` `getChildren(java.lang.Object object)` This delegates to `IEditingDomainItemProvider.getChildren`.
`java.util.Collection<java.lang.Object>` `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(java.lang.Object object)` This returns the editing domain for the given arbitrary object, or null, if it can't be determined.
`static IEditingDomainItemProvider` `getEditingDomainItemProviderFor(java.lang.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.
`java.util.Collection<?>` `getNewChildDescriptors(java.lang.Object object, java.lang.Object sibling)` This delegates to `IEditingDomainItemProvider.getNewChildDescriptors`.
`boolean` `getOptimizeCopy()` This returns whether or not copy command optimizations are safe in this domain.
`java.lang.Object` `getParent(java.lang.Object object)` This delegates to `IEditingDomainItemProvider.getParent`.
`ResourceSet` `getResourceSet()` This returns the resource set used to contain all created and loaded resources.
`java.util.Map<Resource,java.lang.Boolean>` `getResourceToReadOnlyMap()` Returns the map of resource to a Boolean value indicating whether the resource is read only.
`java.lang.Object` `getRoot(java.lang.Object object)` This returns the root of the object, i.e., .
`java.util.List<?>` `getTreePath(java.lang.Object object)` This returns a path list from the root object to the given object in the tree.
`java.lang.Object` `getWrapper(java.lang.Object object)`
`boolean` `isControllable(java.lang.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(java.lang.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(java.lang.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(java.util.Collection<java.lang.Object> 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(java.util.Map<Resource,java.lang.Boolean> resourceToReadOnlyMap)` Set the map of resource to a Boolean value indicating whether the resource is read only.
`TreeIterator<?>` `treeIterator(java.lang.Object object)` This returns a tree iterator that will yield the object, the children of the object, their children, and so on.
`static java.lang.Object` `unwrap(java.lang.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 java.util.Collection<java.lang.Object> 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 java.util.Map<Resource,java.lang.Boolean> 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,
                                       java.util.Map<Resource,java.lang.Boolean> 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; otherwise, 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(java.lang.Object object)

  This returns the editing domain for the given arbitrary 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(java.lang.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(java.lang.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(java.lang.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(java.lang.Class<? extends Command> 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 java.util.Collection<?> getChildren(java.lang.Object object)

  This delegates to `IEditingDomainItemProvider.getChildren`.

  Specified by:
    `getChildren` in interface `EditingDomain`

### getParent

    public java.lang.Object getParent(java.lang.Object object)

  This delegates to `IEditingDomainItemProvider.getParent`.

  Specified by:
    `getParent` in interface `EditingDomain`

### getRoot

    public java.lang.Object getRoot(java.lang.Object object)

  Description copied from interface: `EditingDomain`
  This returns the root of the object, i.e., .

  Specified by:
    `getRoot` in interface `EditingDomain`

### getWrapper

    public java.lang.Object getWrapper(java.lang.Object object)

### unwrap

    public static java.lang.Object unwrap(java.lang.Object object)

### getNewChildDescriptors

    public java.util.Collection<?> getNewChildDescriptors(java.lang.Object object,
                                                          java.lang.Object sibling)

  This delegates to `IEditingDomainItemProvider.getNewChildDescriptors`.

  Specified by:
    `getNewChildDescriptors` in interface `EditingDomain`

### getClipboard

    public java.util.Collection<java.lang.Object> getClipboard()

  This returns the clipboard of the editing domain.

  Specified by:
    `getClipboard` in interface `EditingDomain`

### setClipboard

    public void setClipboard(java.util.Collection<java.lang.Object> 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 java.util.Map<Resource,java.lang.Boolean> getResourceToReadOnlyMap()

  Returns the map of resource to a Boolean value indicating whether the resource is read only.

### setResourceToReadOnlyMap

    public void setResourceToReadOnlyMap(java.util.Map<Resource,java.lang.Boolean> 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(java.lang.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 java.util.List<?> getTreePath(java.lang.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(java.lang.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(java.lang.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.