Java Reference
In-Depth Information
For our mindmap project, switch to the DSL perspective and use
File
→
New
→
DSL Project
to create a new project named
org.eclipse.dsl.mindmap
.
The wizard creates a set of folders:
/model
,
/diagrams
,
/templates
,
/transformations
, and
/workflows
. Not all of these folders are required for
each DSL project, but we use them for our mindmap. The wizard also adds
natures and builders for QVT and Xpand/Model Workflow Engine (MWE).
3.3.2 Creating the Mindmap Domain Model
As mentioned earlier, creating an Ecore model involves many starting points. If
we had an existing XML Schema for our domain, we could import it and EMF
would take care of serializing documents conforming to the schema. If we used
the UML2 project and associated the UML2 Tools class diagram to model our
domain, we could import it to create an EMF model. We begin using “classic”
EMF to create our mindmap DSL from scratch.
Typically, we'd begin with
File
→
New
→
Other
→
Eclipse Modeling
Framework
Ecore Model). However, the DSL Toolkit
from Amalgam provides some wizard redefinitions to facilitate DSL development
and defines capability definitions to hide the original UI contributions from var-
ious Modeling projects. To create our model, we select the
/model
folder and
use the
File
→
Ecore Model
(Ctrl+3
→
Domain Model) wizard, which
is really just the GMF Ecore diagram wizard. Name the model and diagram files
mindmap.ecore
and
mindmap.ecore_diagram
, respectively. Optionally, you
can use the Ecore Tools component, available from the EMFT project. It pro-
vides some capabilities beyond those that the GMF example editor provides.
Before we begin to model the domain, we need to set some defaults in our
mindmap Ecore model. First, right-click on the blank diagram surface and select
Show Properties View
. This shows the properties for the root package in our new
Ecore model. Each Ecore model has a single root package, under which we can
create a number of additional subpackages. In our case, we set the properties
accordingly:
name
and
Ns Prefix
should be set to
mindmap
;
Ns URI
should be
Using Figure 3-4, model the mindmap domain using the palette and
Properties view. It's a straightforward model to implement, with only a couple
noteworthy items: First, the
MapElement
class is abstract; second, the
rootTopics
relationship is derived, transient, and volatile. We implement this
derived reference using OCL in Section 3.3.5, “Adding OCL.”
The diagram surface has many features to explore, as discussed in Section
10.1, “Overview.” You should note a few things, however, when using the Ecore
diagram to create the mindmap domain model:
→
New
→
Domain Model
(Ctrl+3
→
Search WWH ::
Custom Search