org.eclipse.stp.core.infrastructure.emf
Interface IEditModel


public interface IEditModel

IEditModel manages a set of Resources as an atomic unit, with context established through the use of one or more IScribblerDomains which declare interesting resources.

IEditModels create IEditModelScribbler s, which can be used by editors to manage IUndoContexts within the IEditModel command stack, to be notified of changes in interesting resources, and to save, revert or close the resources as an atomic unit.

A project may have one or more IEditModels associated with it. Each IEditModel will track resources that its IEditModelScribblers are interested in; including resources that are in use by multiple IEditModelScribblers concurrently. The set of resources that the IEditModelScribbler is interested in is specified when the IEditModelScribbler is created. createScribbler(IScribblerDomain[], boolean).

The intended guidance for IEditModels is that each IEditModel will track a set of resources associated with a particular editor or set of editors. For instance, an editor for modifying an Enterprise Java Bean Deployment Descriptor and an editor for modifying mapping data from the EJBs to the database schema could share the same IEditModel (within the same project), but each editor would have its own IEditModelScribbler. The IEditingDomains of each IEditModelScribbler would be different, but would reference some of the same resources (e.g. ejb-jar.xml). The single IEditModel would then notify each IEditModelScribbler (one for the EJB DD editor, one for the EJB Mapping Editor) whenever one of the resources for either IEditModelScribbler had been modified (again, the resources are indicated by the IEditingDomains contained by the IEditModelScribblers). The same project could then define another IEditModel to track resources associated with "Technology XYZ" for one or more (other) editors.

The IEditModel manages a single command stack (IOperationHistory) for all of the IEditModelScribblers that are created from it. Each of the IEditModelScribblers define an IUndoContext which is used when executing operations. One or more IEditModelScribblers may share the same or equivalent sets of IEditingDomains, in which case operations may be undone or redone across the matching IEditModelScribblers.

See Also:
IEditModelScribbler, IScribblerDomain

Method Summary
 void addListener(IEditModelListener aListener)
          Track changes to the IEditModel including the addition or removal of Resources and the loading or unloading of Resources.
 IEditModelScribbler createScribbler(IScribblerDomain[] theDomains, boolean makeReadOnly)
          The IEditModel creates IEditModelScribblers which then exposes artifact lifecylce methods like save(), close(), or revert().
 java.lang.String getEditModelLabel()
          The editModelLabel functions as a label so that clients can coordinate access to a specific Edit Model across editors, operations, and views.
 IOperationHistory getOperationHistory()
          Return the command stack in use by this IEditModel.
 boolean isDisposed()
          Once an IEditModel has been disposed, it may no longer be used; a new IEditModel must be loaded.
 boolean isInterrestedInResource(Resource aResource)
          Expected to use the IEditingDomain.isContained() API underneath;
 void removeListener(IEditModelListener aListener)
          Remove an existing IEditModelListener.
 void setErrorHandler(IEditModelErrorHandler errorHandler)
          Respond to an errors that may occur during the IEditModelLifecycle.
 

Method Detail

addListener

void addListener(IEditModelListener aListener)
                 throws EditModelException
Track changes to the IEditModel including the addition or removal of Resources and the loading or unloading of Resources.

Parameters:
aListener -
Throws:
EditModelException
See Also:
EditModelEvent

removeListener

void removeListener(IEditModelListener aListener)
Remove an existing IEditModelListener.

Parameters:
aListener -

setErrorHandler

void setErrorHandler(IEditModelErrorHandler errorHandler)
Respond to an errors that may occur during the IEditModelLifecycle.

Parameters:
errorHandler -

createScribbler

IEditModelScribbler createScribbler(IScribblerDomain[] theDomains,
                                    boolean makeReadOnly)
                                    throws EditModelException
The IEditModel creates IEditModelScribblers which then exposes artifact lifecylce methods like save(), close(), or revert().

Several IEditModelScribblers may be created at the same time with either mutually exclusive or intersecting IScribblerDomains. The IEditModel will track changes to all resources announced by the IScribblerDomains, and notify the IEditModelScribblers when changes occur to resources they are interested in.

Should the IEditModelScribbler be able to contain a set of Resources that have mixed read-only status? Where some are readonly and others are not?

Parameters:
theDomains -
makeReadOnly - Indicates that the IEditModelScribbler will not be able to save or persist changes.
Returns:
Throws:
EditModelException
See Also:
IEditModelScribbler, For more information on creating these objects.

isDisposed

boolean isDisposed()
Once an IEditModel has been disposed, it may no longer be used; a new IEditModel must be loaded.

Returns:
true if the Edit Model has been disposed

isInterrestedInResource

boolean isInterrestedInResource(Resource aResource)
Expected to use the IEditingDomain.isContained() API underneath;

Parameters:
aResource -
Returns:

getOperationHistory

IOperationHistory getOperationHistory()
                                      throws EditModelException
Return the command stack in use by this IEditModel. The current operation history is shared by all existing IEditModelScribblers. Each IEditModelScribbler becomes its own IUndoContext, so the history will remember all commands executed, but the undo/redo of these operations can be coordinated from equivalent IUndoContexts. The IUndoContext is determined by the IEditModelScribbler, where the IEditingDomain(s) is(are) the basis for matching IUndoContexts.

Returns:
an IOperationHistory which is shared among all IEditModelScribblers created by this IEditModel
Throws:
EditModelException
See Also:
org.eclipse.core.commands.operations.IUndoContext, IScribblerDomain, IEditModelScribbler

getEditModelLabel

java.lang.String getEditModelLabel()
The editModelLabel functions as a label so that clients can coordinate access to a specific Edit Model across editors, operations, and views.

The editModelLabel does not imply any varied function, but merely serves as a unique identifier for a specific Edit Model. In general, these ids are meant to be coordinate across a particular set of related resources. For instance, an EJB DD Editor might share the same underlying editModelLabel that an EJB Mapping Editor would use.

Returns:
The editModelLabel used to create or locate this Edit Model