Java Reference
In-Depth Information
After we add the
Custom Behaviour
element to the generation model, the
generated code references the
ToolTip
class. The GMF generator knows noth-
ing of our custom template, and there's no way currently to add new template
definitions to the execution environment. We need to create our own workflow
and run a second-generation step to produce the referenced ToolTip
EditPolicy
class. Section 14.1.16, “Workflow Engine,” covers workflows, but
for now, just use
File
Workflow
Definition
to create a
tooltip.mwe
file in the
/workflows
folder. Next you can
see the workflow used to invoke our template following the normal GMF dia-
gram generation; it includes a number of model references. As such, it's necessary
to add the following plug-ins as dependencies of our project in the
MANIFEST.MF
file:
org.eclipse.gmf.codegen
,
org.eclipse.gmf.runtime.notation
,
and
org.eclipse.gmf.validate
. Curiously, you also need to add
org.
eclipse.core.runtime
,
org.eclipse.jdt.core
, and
→
New
→
Other
→
Model Transformation
→
org.eclipse.
jface.text
.
<?xml version="1.0"?>
<
workflow
>
<
property
name="model"
value="platform:/resource/org.eclipse.dsl.requirements/
diagrams/Tooltip.xmi" />
<
property
name="out"
value="../org.eclipse.requirements.diagram/src" />
<!-- set up EMF for standalone execution -->
<
bean
class="org.eclipse.emf.mwe.utils.StandaloneSetup">
<
platformUri
value="../" />
<
RegisterGeneratedEPackage
value="org.eclipse.gmf.codegen.gmfgen.GMFGenPackage"/>
<
RegisterGeneratedEPackage
value="org.eclipse.gmf.runtime.notation.NotationPackage"/>
</
bean
>
<
component
class="org.eclipse.emf.mwe.utils.Reader">
<
uri
value="${model}" />
<
modelSlot
value="model" />
</
component
>
<!-- generate code -->
<
component
class="org.eclipse.xpand2.Generator">
<
metaModel
id="mm"
class="org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel"/>
<
expand
value="TooltipEditPolicy::Main FOR model" />
<
outlet
path="${out}">
<
postprocessor
class="org.eclipse.xpand2.output.JavaBeautifier" />
Search WWH ::
Custom Search