public abstract class AbstractTransformationProvider
extends org.eclipse.gmf.runtime.common.core.service.AbstractProvider
A transformation is defined by adding a "com.ibm.xtools.transform.core.transformationProviders"
extension where the class
attribute identifes a class derived
from this class. A <Transformation>
element in the XML
defines the descriptor of the transformation which includes various properties
for integrating the transformation into the transformation service. The main
property that must be defined is a unique identifer for the transformation.
Along with the default transformation descriptor properties, the author can
define special properties to configure the transformation or to allow the
user to customize.
When an instace of that transformation is wanted, this provider class is called to create it. A new instance must be created every time since a transformation can be embedded within another transformation. In addition, the provider is responsible for validating a context that will be used to execute the transformation. This context includes the selected source object(s), the target container object and various properties, some of which may have been modified by the user.
Modifier and Type | Field and Description |
---|---|
static int |
CODE_OTHER
Somehting in the environment is invalid.
|
static int |
CODE_PROPERTY
Some other property is invalid.
|
static int |
CODE_SOURCE
Source property is invalid.
|
static int |
CODE_TARGET
Target property is invalid.
|
static int |
CODE_TARGET_CONTAINER
Target Container property is invalid.
|
Constructor and Description |
---|
AbstractTransformationProvider()
Default constructor
|
Modifier and Type | Method and Description |
---|---|
ITransformContext |
createReverseContext(ITransformContext fwdContext)
Creates a transformation context to run the reverse transformation.
|
abstract AbstractTransform |
createTransformation(ITransformationDescriptor descriptor)
Create an instance of the corresponding transformation.
|
protected ITransformationDescriptor |
getReverseTransformationDescriptor(ITransformContext context)
Retrieves the forward transformation descriptor from the given context
and looks up the descriptor of the reverse transformation from it.
|
boolean |
provides(org.eclipse.gmf.runtime.common.core.service.IOperation operation) |
org.eclipse.core.runtime.IStatus |
validateContext(ITransformationDescriptor descriptor,
ITransformContext context)
Validate the context for the corresponding transformation.
|
public static final int CODE_SOURCE
public static final int CODE_TARGET_CONTAINER
public static final int CODE_TARGET
public static final int CODE_PROPERTY
public static final int CODE_OTHER
public AbstractTransformationProvider()
public boolean provides(org.eclipse.gmf.runtime.common.core.service.IOperation operation)
IProvider.provides(org.eclipse.gmf.runtime.common.core.service.IOperation)
public abstract AbstractTransform createTransformation(ITransformationDescriptor descriptor)
Every time this method is called, the provider must create a new instance of the transformation hierarchy and return the root transform of that hierarchy.
descriptor
- the transformation descriptorpublic org.eclipse.core.runtime.IStatus validateContext(ITransformationDescriptor descriptor, ITransformContext context)
This method can return either a single status object or multiple status objects depending upon the validation performed. If multiple warnings/errors are to be returned use a MultiStatus object. If one of its child status objects has a severity of ERROR, the multi-status is assumed to be an error.
A valid context should return a single status object with a severity of OK. A "null" return value indicates a major error (e.g., the service could not locate or load the provider).
descriptor
- the transformation descriptorcontext
- the context to be validatedMultiStatus
,
Status
public ITransformContext createReverseContext(ITransformContext fwdContext)
java.util.List
the first element in the list becomes the target in the reverse context.
The source in the reverse context will be a list that contains the
target from the forward context. If the source of the forward
transformation is not a list, the source and target are simply swapped
in the reverse context.
Subclasses can override this method if the default implementation does
not suit their needs.fwdContext
- The forward context which must not be null;java.lang.IllegalArgumentException
- if the forward context is null.protected ITransformationDescriptor getReverseTransformationDescriptor(ITransformContext context)
context
- The context from the forward transformation.