|
||||||||||
| PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES | |||||||||
See:
Description
| Interface Summary | |
|---|---|
| IResourceUndoContextPolicy |
A rule determining the resources for which an IUndoableOperation
should be tagged with ResourceUndoContexts. |
| IWorkspaceCommandStack | A specialized transactional command stack that delegates the execution of
commands to an IOperationHistory. |
| Class Summary | |
|---|---|
| AbstractEMFOperation | An abstract superclass for IUndoableOperations that modify EMF
models. |
| AbstractResourceUndoContextPolicy | The default implementation of the resource undo-context policy, suitable for clients to extend/override as required. |
| CompositeEMFOperation | An implementation of a composite undoable operation for composition of
operations which may include AbstractEMFOperations. |
| EMFCommandOperation | An operation that wraps an EMF Command to execute it in a read/write
transaction on an IOperationHistory. |
| EMFOperationCommand | An implementation of the EMF Command API that wraps an
IUndoableOperation. |
| ResourceUndoContext | An IUndoContext that tags an EMF operation with a resource affected by it. |
| WorkspaceEditingDomainFactory |
Factory for creating transactional editing domains that delegate command
execution, undo, and redo to an IOperationHistory. |
Definition of the API for a transactional editing domain integrated with the Eclipse Workbench's operation history.
The following snippet illustrates the creation of a workbench editing domain:
// can use any operation history instance IOperationHistory myHistory = OperationHistoryFactory.getOperationHistory(); TransactionalEditingDomain domain = WorkspaceEditingDomainFactory.INSTANCE.createEditingDomain(myHistory); ResourceSet rset = domain.getResourceSet(); // could also just let the editing domain get the default history from the history factory TransactionalEditingDomain domain = WorkspaceEditingDomainFactory.INSTANCE.createEditingDomain();
The same editing domain registry and extension point used for sharing
TransactionalEditingDomains can also be used to share workbench editing
domains. Just register an editing domain ID and a factory implementation on the
org.eclipse.emf.transaction.editingDomains extension point and
use the TransactionalEditingDomain.Registry to access
your domain.
The normal procedure for modifying resources in a workbench editing domain is to use undoable operations:
IUndoableOperation operation = new AbstractEMFOperation(
domain, "Create Library") {
protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
Resource res = rset.getResource(
URI.createFileURI("/tmp/my.xmi"),
true);
Library library = LibraryFactory.eINSTANCE.createLibrary();
// these modifications require a write transaction in this
// editing domain. The operation provides this transaction
res.getContents().add(library);
library.setName("Main Branch");
}
};
try {
myHistory.execute(operation, new NullProgressMonitor(), null);
} catch (ExecutionException ee) {
getLog().log(ee);
}
Of course, it is just as easy to re-use existing EMF Commands:
IUndoableOperation operation = new EMFCommandOperation(
domain, new CreateLibraryCommand());
try {
myHistory.execute(operation, new NullProgressMonitor(), null);
} catch (ExecutionException ee) {
getLog().log(ee);
}
// alternatively, the command stack of our editing domain will automatically
// wrap the command in an operation and execute it on the operation history
domain.getCommandStack().execute(new CreateLibraryCommand());
In either case, undoing and redoing operations is as simple as the operation history API makes it:
// undo
try {
myHistory.undo(myEditorContext, new NullProgressMonitor(), null);
} catch (ExecutionException ee) {
getLog().log(ee);
}
// redo
try {
myHistory.redo(myEditorContext, new NullProgressMonitor(), null);
} catch (ExecutionException ee) {
getLog().log(ee);
}
WorkspaceEditingDomainFactory,
AbstractEMFOperation,
CompositeEMFOperation
|
Copyright 2002, 2007 IBM Corporation and others. All Rights Reserved. |
|||||||||
| PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES | |||||||||