64

Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier
Page 2: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

Many of the designations used by manufacturers and sellers to distinguish theirproducts are claimed as trademarks. Where those designations appear in thisbook, and the publisher was aware of a trademark claim, the designations havebeen printed with initial capital letters or in all capitals.

The author and publisher have taken care in the preparation of this book butmake no expressed or implied warranty of any kind and assume no responsibilityfor errors or omissions. No liability is assumed for incidental or consequentialdamages in connection with or arising out of the use of the information orprograms contained herein.

The publisher offers excellent discounts on this book when ordered in quantity forbulk purchases or special sales, which may include electronic versions and/orcustom covers and content particular to your business, training goals, marketingfocus, and branding interests. For more information, please contact:

U.S. Corporate and Government Sales(800) [email protected]

For sales outside the United States, please contact:

International [email protected]

Visit us on the Web: informit.com/aw

Library of Congress Cataloging-in-Publication Data:

Gronback, Richard C.Eclipse modeling project : a domain-specific language (DSL) toolkit / Richard C.

Gronback.p. cm.

ISBN 0-321-53407-7 (pbk. : alk. paper) 1. Computer software—Development.2. Eclipse (Electronic resource) 3. Programming languages (Electronic computers)I. Title.

QA76.76.D47G785 2009005.1—dc22

2008050813

Copyright © 2009 Pearson Education, Inc.

All rights reserved. Printed in the United States of America. This publication isprotected by copyright, and permission must be obtained from the publisher priorto any prohibited reproduction, storage in a retrieval system, or transmission inany form or by any means, electronic, mechanical, photocopying, recording, orlikewise. For information regarding permissions, write to:

Pearson Education, Inc.Rights and Contracts Department501 Boylston Street, Suite 900Boston, MA 02116Fax (617) 671 3447

ISBN-13: 978-0-321-53407-1ISBN-10: 0-321-53407-7Text printed in the United States on recycled paper at Courier in Stoughton,Massachusetts.First printing March 2009

Associate PublisherMark Taub

Acquisitions EditorGreg Doench

Managing EditorKristy Hart

Project EditorJovana San Nicolas-Shirley

Copy EditorKrista Hansing EditorialServices, Inc.

IndexerErika Millen

Technical ReviewerSimon Archer

David OrmeDaniel Holt

Publishing CoordinatorMichelle Housley

Cover DesignerSandra Schroeder

CompositorNonie Ratcliff

Page 3: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

xix

Foreword

Just like a pearl, the Eclipse Modeling Project has grown organically as layersaround a central core. From the humble beginnings of the Eclipse ModelingFramework (EMF) (initially part of the Eclipse Tools Project) along with theGraphical Modeling Framework (GMF) and the Generative Modeling Tools(GMT) (both initially part of the Eclipse Technology Project), the ModelingProject coalesced to become one of Eclipse’s most exciting and diverse projects.The depth and breadth of its technology is vast and even its rate of growth con-tinues to increase. The Eclipse Modeling Project has truly become a Swiss Armyknife for state-of-the-art model-driven software development.

The sheer volume of useful modeling technologies that the Eclipse ModelingProject includes makes mastering a significant portion of it a daunting task. Evendetermining which specific available technologies are useful for solving any par-ticular problem is a challenge exacerbated by the fact that, as a rule, the docu-mentation tends to lag far behind the development work. As such, this book fillsa fundamentally important need in the modeling community: a coherent visionof how all this powerful technology can be best exploited to build domain spe-cific languages (DSLs). In other words, the focus of this book is on pragmaticapplications illustrated by way of concrete examples rather than on abstractmodeling concepts and theories. This pragmatic focus reflects that of theModeling Project overall—that is, a focus on building powerful frameworks thatreal programmers use every day. I’m sure this influential book—with its inter-esting examples and its excellent reference material—will become a key part ofevery toolsmith’s technical arsenal.

EMF provides a sound basis for abstract syntax development and evenincludes a crude but effective XML-based concrete syntax. But, that is only thestart of the journey, and the second edition of the Eclipse Modeling Frameworkbook covers this basic material well. This book effectively picks up where EMFleaves off with an in-depth exploration of alternative forms of concrete syntax,particularly graphical syntax, model-to-model transformation (such as Query

Page 4: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

View Transformation Operational Mapping Language), and model-to-text trans-formation (such as Xpand). It rounds out the DSL picture with a holistic view ofeverything it takes to build a complete model-based product line.

It has been my great pleasure and honor to work closely with Richard C.Gronback as the Modeling Project coleader for the past few years. He has a keenmind and a sharp wit. This book reflects it well. I’ve learned a great deal fromhim, and I’m sure readers of this book will as well.

—Ed Merks, Ph.D.President, Macro Modeling

xx Foreword

Page 5: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

xxi

Preface

About This Book

This book covers a relatively new collection of technologies that focus on devel-oping domain-specific languages (DSLs) using the Eclipse Modeling Project,offering a first look at a range of Eclipse projects that have not yet been coveredin detail within this context. Although the core of these technologies has beenavailable for several years in the Eclipse Modeling Framework (EMF), diagramdefinition and model transformation are emerging technologies at Eclipse. Theseare complemented by upcoming textual syntax development frameworks, whichlikely will be covered in detail in subsequent editions of this book.

This book delivers a pragmatic introduction to developing a product lineusing a collection of DSLs. A model-based, largely generative approach isdesigned to accommodate future adjustments to the source models, templates,and model transformation definitions, to provide customized solutions withinthe context of the product line. To illustrate this approach, this book presents aset of sample projects used to define a requirements product line.

Audience

This book targets developers and architects who want to learn about developingDSLs using Eclipse Modeling Project technologies. It assumes a basic under-standing of the Java programming language, Eclipse plug-in development, andfamiliarity with EMF. This book’s target audience are those interested in learn-ing about the Eclipse Graphical Modeling Framework (GMF), Model-to-ModelTransformation (M2M) Query/View/Transformation Operational MappingLanguage (QVT OML), and Model-to-Text Transformation (M2T) Xpand proj-ect components.

The book is divided into introductory, hands on, and reference sections.Readers who want an overview of the Eclipse Modeling Project and developmentof DSLs in the context of an Eclipse-based product line should read Part I,“Introduction.” Readers who want to follow along in a tutorial fashion to learn

Page 6: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

how to use the projects listed earlier should read Part II, “Developing Domain-Specific Languages.” Readers also can reference the sample project solutions inthis section to get an overview of the techniques. Part III, “Reference,” serves asa resource for readers who want a deeper understanding of Graphical EditingFramework (GEF), GMF, Xpand, and QVT OML while they are completing PartII or developing their own DSL-based projects.

Readers who want to experience the benefits of a commercial version of thetechnologies presented here can download the Borland Together product. Therethey will find enhanced domain modeling, refactoring, diagram development,transformation authoring and debugging, workflow, and generation capabilitiesin a well-integrated DSL Toolkit.

Sample Code

The Modeling Amalgamation Project (Amalgam) at Eclipse holds the samplecode from this book and is available as sample projects in the DSL Toolkit down-load. This package also includes all the prerequisites required for developing thesample applications.

Visit the Amalgam project Web site for more information on obtaining theDSL Toolkit: www.eclipse.org/modeling/amalgam.

Feedback

The examples in this book are maintained within the Modeling AmalgamationProject at Eclipse. Feedback on their content—and, therefore, this book’scontent—is welcome on the project newsgroup, http://news.eclipse.modeling.amalgam. Alternatively, feel free to contact the author directly at [email protected].

xxii Preface

Page 7: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

CHAPTER 3

Developing a DSL AbstractSyntax

In this chapter, we walk through the development of a domain-specific language (DSL)using the Eclipse Modeling Framework (EMF) and supporting components. Specifically,we develop the DSL’s abstract syntax using the Ecore metamodel. But first we cover somebasics on what to consider when creating a DSL and the different implementation strate-gies you might want to employ when using EMF. Next, we provide an overview of EMF,leaving detailed information to the book [38] dedicated to this purpose. We cover someadditional components of EMF and Model Development Tools (MDT) that enable you tofurther refine DSLs, and we develop a series of domain models for use in the sampleprojects.

DISCLAIMER

The domain models developed as samples are constructed to illustratecertain features of the associated tooling and, as such, should not neces-sarily be considered “best practices” in some cases.

3.1 DSL Considerations

Many considerations are involved in creating a DSL. Does a model already existthat is close enough? If so, can an existing model be extended, or is it fixed? Doesthe model need to be based on a standard? Does the DSL lend itself to graphicaldisplay and editing? Does the DSL require a textual syntax and editor? Will a

29

Page 8: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

product line be built on the DSL, and perhaps others? Is the Ecore metamodelexpressive enough to suit your needs for a DSL? How can you model dynamicbehavior?

BEST PRACTICE

Leverage existing models, when appropriate. XML Schema Definition (XSD)and EMF are very popular technologies, and EMF can import just about anyXSD, so search for existing domain models before you reinvent the wheel.Also consider publishing your domain model if you think that others mightfind it useful, if only as part of your application’s API to aid in integration.

A key consideration is the amount of flexibility you need or will tolerate inthe DSL. As you can see in the examples, sometimes a change in the domainmodel makes your transformation definitions much easier to write. Also, frame-works such as GMF have certain limitations—or, rather, were designed with par-ticular use cases in mind. Your particular style of modeling might not lend itselfwell to graphical representation, but a few changes might allow mapping to dia-gram elements much easier. For example, certain mappings in Query/View/Transformation (QVT) and template expressions can be facilitated by addingderived features or methods to the domain model. Complex queries using ObjectConstraint Language (OCL) (and, therefore, useful ones in QVT and Xtend) canbe added to the domain model with code generated for their implementation atruntime. Having a feature available in the model will greatly simplify transfor-mations and templates that access them.

TIP

Don’t be afraid of modifying your domain model to make working withtemplates, transformations, and diagram definitions easier. Unless you’reusing a model that cannot be altered, the Toolsmith will appreciate beingable to make certain design decisions in the domain model to suit the tool-ing, instead of having to create workarounds or write custom code to usethe tooling with a domain model.

This is not to say that you should let the tooling influence your DSL to anextent you are not comfortable with. The question is, how do you maintain asatisfactory level of “purity” in your DSL when considering the additional

30 CHAPTER 3 • Developing a DSL Abstract Syntax

Page 9: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

complexity associated with developing and maintaining the other Model-DrivenSoftware Development (MDSD) artifacts? In general, the more complex themetamodel (DSL) is, the more complex the transformation definitions, templates,and diagram definitions are.

A set of conventions and best practices for the definition of DSLs, transfor-mations, and templates likely will arise, as it has for Java and other popular pro-gramming languages. With conventions and best practices comes tooling tosupport refactorings, static analysis, and cleanup. At this stage of the Modelingproject’s evolution, operations are still quite manual and even error prone. As anopen source project that forms the basis for commercial products, Eclipse even-tually will see more advanced features pushed down into it, thereby improvingthe Toolsmith experience.

3.2 Eclipse Modeling Framework

From the project description, EMF is “a modeling framework and code genera-tion facility for building tools and other applications based on a structured datamodel.” This pretty much sums it up, but there’s a lot to know about EMF. Ihighly recommend that you first read, or at least have available, the book onEMF [38] to better understand its use in the context of this book. Alternatively,reading through the online documentation and tutorials on EMF should make itsuse in this book easy to follow. In other words, the examples in this book onlyscratch the surface of what is possible using EMF.

You can create models using EMF in many ways. You can use the providededitor (a tree with properties view) or import a set of annotated Java classes. AnEcore diagram is available from the EMFT project. If you have the XSD compo-nent installed, you can import an XSD file. If you have the Unified ModelingLanguage (UML) version 2 (UML2) component installed, you can import aUML2 model. If you have Graphical Modeling Framework (GMF) installed, youcan use its example Ecore diagram editor. If you download and install Emfatic[42], you can work in a textual syntax and synchronize with your Ecore model.In the future, you will be able to design your own concrete textual syntax forEcore, or any model, using the Textual Modeling Framework (TMF) project.

Regardless of the method you choose for importing or working with yourdomain model, you will find an .ecore file in your workspace—that is, unlessyou take a purely programmatic approach. If you open this file in a text editor,you will see that it is an XML Metadata Interchange (XMI) serialization of yourEcore-based model. By default, EMF enables you to edit models in a basic (gen-erated) tree editor with a Properties view. You can easily generate a similar edi-tor for your own model.

Before getting into more detail, let’s take a look at the Ecore metamodel.

3.2 Eclipse Modeling Framework 31

Page 10: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

3.2.1 Ecore Metamodel

The EMF book describes the Ecore metamodel in detail, but here you find a sim-plified diagram for reference (Figure 3-1), along with some discussion of themore relevant aspects used as we develop our DSL abstract syntax. It’s a fairlysimple model, which is part of its strength. In most cases, you can compensatefor the lack of features in Ecore by using some of the more advanced modelingtechniques, which are discussed in the EMF book. A longstanding topic of debateamong EMF users is the lack of an EAssociation class, but we don’t get into thathere.

32 CHAPTER 3 • Developing a DSL Abstract Syntax

Figure 3-1 Ecore model

Page 11: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

Annotations

Sometimes it’s important to add information to a model element for documenta-tion purposes, or to provide parameters to be considered during transformationor generation. EAnnotations provide these for all model elements in EMF. AnEAnnotation has a Source field, which serves as a key, and a list of References.An EAnnotation may have zero or more Details Entry children, which have Keyand Value properties. This simple capability of annotating models is quite flexi-ble and turns out to be useful for many purposes, including XSD support.

Another particularly useful application of annotations is to declare OCLconstraints, method bodies, and derived feature implementation, as discussed inSection 3.2.4, “Applying OCL.”

3.2.2 Runtime Features

The EMF runtime includes facilities for working with instances of your models.No strict dependencies exist on the Eclipse platform for the runtime and gener-ated model and edit code, so these bundles can be used outside of the Eclipseworkbench. As bundles, they can be deployed in any Equinox OSGi container,even within a server environment.

The generated code for your model has a dependency on the underlying EMFruntime components. A significant benefit is gained from the generated Appli-cation Programming Interface (API) and model implementation working withthe provided runtime features. An efficient observer pattern implementation isprovided to alert listeners to model change events. A generated reflective APIprovides an efficient means of working with models dynamically. In fact, EMFcan be used in a purely dynamic fashion, requiring neither an .ecore model norcode generation. Finally, it’s possible to have static registration of a dynamicpackage, but that’s an advanced use case left to the EMF documentation.

When working with model instances, changes can be recorded in a changemodel that provides a reverse delta and allows for transaction support. A vali-dation framework provides for invariant and constraint support with batch pro-cessing. The Model Transaction and Validation Framework components provideenhanced transaction and validation support, respectively.

For persistence of models, the EMF runtime provides a default XML seriali-zation. The persistence layer is flexible, allowing for XMI, Universally UniqueIdentifiers (UUIDs), and even a zip option. A resource set consists of one or moreresources, making it possible to persist objects in multiple files, including cross-containment references. Proxy resolution and demand loading improve perform-ance when working with large models across resources. Additionally, use of EMFTechnology (EMFT) components Teneo and CDO allow for the persistence ofmodels to a relational database.

3.2 Eclipse Modeling Framework 33

Page 12: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

The generated editor for EMF models includes a multipage editor and prop-erties view. Drag-and-drop support is provided, as is copy/paste support. A num-ber of menu actions are available in the generated editor, including validationinvocation and dynamic instance model creation. Each generated editor comeswith a default creation wizard. Figure 3-2 shows an example of the editor,including a context menu showing options to create new elements, cut, copy,paste, delete, validate, and so on.

34 CHAPTER 3 • Developing a DSL Abstract Syntax

Figure 3-2 EMF-generated editor

3.2.3 Code Generation

From an *.ecore (Ecore) model, you need to produce a generator model andsupply additional information required for code generation. An EMF generatormodel has a *.genmodel file extension and is essentially a decorator model fora corresponding *.ecore model. This generator model is fed to Java EmitterTemplates (JETs) that are used to write Java and other files. JET is the Java ServerPages (JSP)-like technology used by default when generating text from Ecoremodels. This book does not cover it in detail, but a tutorial is available online[51] if you want to know more.

You can customize the existing generation output using custom templates.Furthermore, you can extract constraint, pre-/post-condition, and body imple-mentations from OCL annotations for use in generation and invocation at run-time. This is not a native EMF capability, but you can add it using the MDT OCLcomponent. You will use this technique in the context of the sample projects.

Page 13: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

When regenerating code, the JMerge component is used to prevent overwrit-ing user modifications. Generated Java code is annotated with @generatedjavadoc style tags to identify it and distinguish it from user code. Removing thetag or adding NOT after the tag ensures that JMerge will not overwrite the mod-ified code. Typically, using @generated NOT is preferred because it allows theToolsmith to identify code that was generated and modified, as opposed to newlyadded code. Note that not all code benefits from merging. Specifically,plugin.xml and MANIFEST.MF files need to be deleted before an update canoccur.

3.2.4 Applying OCL

Many opportunities arise for using OCL in EMF models. Class constraints,method bodies, and derived feature implementations can all be provided usingMDT OCL and EMF dynamic templates. The approach of using OCL and cus-tom templates in this book comes from an Eclipse Corner article [44] and hasbeen modified only slightly to conform to a similar approach taken to leverageOCL added to models in QVT, as discussed in Section 6.5.6, “Leveraging OCLin EMF Models.” The templates are generic and can easily be added to any proj-ect that needs to provide OCL-based implementations in its generated modelcode. It is also worth noting that GMF uses OCL extensively in its models,employing an EMF Validator to maintain the integrity of its models.

To add an OCL expression to a model element, we begin by adding a nor-mal EAnnotation. For the Source property, enter http://www.eclipse.org/2007/OCL. This URI allows our custom templates and QVT engine to recognizethis annotation as OCL, where it can expect to find Details Entry children oftype constraint, derive, or body. Note that the original article [44] usedhttp://www.eclipse.org/ocl/examples/OCL as the URI.

Depending on the context, add the appropriate Key (EMF constraint key,derive, or body) to a child Details Entry of the EAnnotation and specifythe OCL in the Value property. For invariant constraints, the OCL annotationscomplement the normal EMF constraint annotations by providing implementa-tion for the validation framework to enforce constraints.

TIP

To test your OCL, it’s helpful to use the Interactive OCL Console with adynamic instance of your model, as discussed in Section 1.5.4, “ObjectConstraint Language.” Be sure to select the proper model element for theexpression, as well as the proper metalevel in the console.

3.2 Eclipse Modeling Framework 35

Page 14: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

To invoke the provided OCL at runtime, you must use custom JET templatesfor your domain model. The generated code retrieves the OCL statement fromthe model element and invokes it, evaluating the result. An alternative to this isto generate a Java implementation of the OCL during generation and avoidinvoking the OCL interpreter at runtime.

The referenced article covers the details of the custom templates, so they arenot covered here. Also, the templates are included in the book’s sample projectsand are touched upon during the development of the sample projects. For now,we take a look at just the derived feature implementation, both before and afterusing the OCL with a custom template approach. First, consider the default gen-erated code for a derived reference—in this case, the rootTopics reference fromthe MapImpl class in our mindmap example.

/*** <!-- begin-user-doc -->* <!-- end-user-doc -->* @generated*/public EList<Topic> getRootTopics() {// TODO: implement this method to return the 'Root Topics' // reference list// Ensure that you remove @generated or mark it @generated NOT// The list is expected to implement // org.eclipse.emf.ecore.util.InternalEList and // org.eclipse.emf.ecore.EStructuralFeature.Setting// so it's likely that an appropriate subclass of// org.eclipse.emf.ecore.util.EcoreEList should be used.

throw new UnsupportedOperationException();}

Let’s add the following OCL statement to the derived feature using the pre-vious convention. Here we see the annotation within the mindmap.ecore modelin its native XMI serialization. Note that this OCL statement could be simplifiedby using the parent eOpposite relationship on our Topic’s subtopics reference,which was added to facilitate the diagram definition of Section 4.3.5, “SubtopicFigure.”

<eStructuralFeatures xsi:type="ecore:EReference" name="rootTopics" upperBound="-1" eType="#//Topic" volatile="true" transient="true" derived="true"><eAnnotations source="http://www.eclipse.org/2007/OCL"><details key="derive" value="let topics : Set(mindmap::Topic) = self.elements->

select(oclIsKindOf(mindmap::Topic))->collect(oclAsType(mindmap::Topic))->asSet() in

36 CHAPTER 3 • Developing a DSL Abstract Syntax

Page 15: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

topics->symmetricDifference(topics.subtopics->asSet())"/>

</eAnnotations></eStructuralFeatures>

Before regeneration, we need to make some changes in the genmodel. Toallow the OCL plug-in to be added to our generated manifest dependencies, weneed to add OCL_ECORE=org.eclipse.ocl.ecore to the Model Plug-inVariables property of the genmodel root. Also, we need to set the DynamicTemplates property to true and enter the templates path (such as /org.eclipse.dsl.mindmap/templates/domain) to the Template Directoryproperty. After we generate, we can see the following implementation in ourMapImpl class.

private static OCLExpression<EClassifier> rootTopicsDeriveOCL;

private static final String OCL_ANNOTATION_SOURCE ="http://www.eclipse.org/2007/OCL";

/*** <!-- begin-user-doc -->* <!-- end-user-doc -->* @generated*/public EList<Topic> getRootTopics() {EStructuralFeature eFeature =MindmapPackage.Literals.MAP__ROOT_TOPICS;

if (rootTopicsDeriveOCL == null) { Helper helper = OCL_ENV.createOCLHelper();helper.setAttributeContext(MindmapPackage.Literals.MAP, eFeature);

EAnnotation ocl = eFeature.getEAnnotation(OCL_ANNOTATION_SOURCE);String derive = (String) ocl.getDetails().get("derive");

try {rootTopicsDeriveOCL = helper.createQuery(derive);

} catch (ParserException e) {throw new UnsupportedOperationException(e.getLocalizedMessage());

}}

Query<EClassifier, ?, ?> query = OCL_ENV.createQuery(rootTopicsDeriveOCL);

@SuppressWarnings("unchecked")Collection<Topic> result = (Collection<Topic>) query.evaluate(this);

return new EcoreEList.UnmodifiableEList<Topic>(this, eFeature, result.size(), result.toArray());

}

3.2 Eclipse Modeling Framework 37

Page 16: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

The generated code checks to see if the OCLExpression for this derivationhas been created already; if not, it initializes it by retrieving the statement fromthe EAnnotation and its detail with key derive. Then the expression is evalu-ated and the list of Topic elements is returned.

As mentioned in the article, some improvements could be made to thisapproach, but it illustrates the usefulness of adding OCL statements to your EMFmodels. It’s not hard to imagine how a significant portion of an application couldbe generated from a model adorned with OCL for invariant constraints, methodbodies, and derived features. In GMF, we can see how OCL is used to augmentthe diagram-mapping model to provide for constraints, feature initialization,audit definition, and model metric definition.

BEST PRACTICE

Adding constraints and validation is essential in model-driven softwaredevelopment. Although you can place validation code within QVT, Xpandtemplates, and so on, it’s most useful to ensure that your model instance iswell formed when created, or before moving to a model transformation.

3.2.5 Dynamic Instances

A powerful feature of EMF, and one that is useful to a Toolsmith developing anew DSL, is the capability to create dynamic instances of a model. The reflectiveframework of EMF is leveraged to allow instantiation of a model element with-out generating code beforehand. This can be done from within the default Ecoreeditor by selecting an element and choosing the Create Dynamic Instancecontext menu item. The instance is stored in an XMI file within the developmentworkspace, so the generation or launch of plug-ins is not required to test a modelor, more importantly, to test Xpand templates and QVT transformations underdevelopment. This is one important distinction when comparing JET to Xpand.Dynamic instances are used in the context of our sample projects.

BEST PRACTICE

Use dynamic instance models for development as much as possible. Xpandtemplates, QVT transformations, and the OCL console can all work withdynamic instance models and avoid making Toolsmiths generate code and

38 CHAPTER 3 • Developing a DSL Abstract Syntax

Page 17: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

invoke a runtime instance to test their work. GMF diagrams still requirecode generation to develop effectively, although generated diagrams arecapable of working with dynamic instances.

Figure 3-3 is an example of a dynamic instance model for our mindmapdomain model, along with the Properties view. It’s similar in functionality to thegenerated EMF editor, although it requires the metamodel to be loaded andreflected upon, as you can see from the loaded mindmap.ecore resource file.

3.3 Developing the Mindmap Domain Model 39

Figure 3-3 Mindmap dynamic instance model

TIP

You can view any Ecore model using the Sample Reflective EcoreModel Editor, so there’s little need to generate the EMF .editor plug-in.This applies to XMI dynamic instances, such as GMF-based diagrams fileswhere both the domain and notation models are persisted in a single file.Simply right-click the file and select Open With → Other → InternalEditors → Sample Reflective Ecore Model Editor.

3.3 Developing the Mindmap Domain Model

We develop a simple mindmap DSL and use it throughout the book to providean example of how to use components of the Modeling project as a DSL Toolkit.This model forms the base of our fictitious Requirements Elicitation Project(REP).

Page 18: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

This is the beginning of those sections in the book that you can follow in atutorial fashion. Solution projects are available to save time, although you shouldbe able to begin from scratch and produce these solutions on your own. It’s upto you to follow along or simply review the solutions as we proceed.

Figure 3-4 is a diagram of the basic mindmap DSL we create in this section.Not much explanation should be required here because you can easily see that aMap class serves as the container for Topics and Relationships, which bothextend from MapElement. The following sections provide details on setting upa DSL project and creating this model, along with the other DSL artifacts asso-ciated with the project.

40 CHAPTER 3 • Developing a DSL Abstract Syntax

Figure 3-4 Mindmap domain model

3.3.1 Project Setup

Before getting started defining our mindmap domain model, we need a new proj-ect. Although EMF and GMF provide their own project wizards, we use the DSLProject Wizard provided by the Amalgam project to hold our DSL artifacts. Youcan create an equivalent project by starting with a plug-in project and adding therequired dependencies, natures, and builders. The DSL project is also a plug-inproject, as we’ll eventually want to deploy the project to facilitate revisioning andextension. Furthermore, Xpand and workflow files currently need to be locatedin source paths to be developed, so we need a Java project anyway. In the future,this should not be required.

Page 19: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

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 foreach DSL project, but we use them for our mindmap. The wizard also addsnatures 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. Ifwe had an existing XML Schema for our domain, we could import it and EMFwould take care of serializing documents conforming to the schema. If we usedthe UML2 project and associated the UML2 Tools class diagram to model ourdomain, 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 ModelingFramework → Ecore Model (Ctrl+3 → Ecore Model). However, the DSL Toolkitfrom Amalgam provides some wizard redefinitions to facilitate DSL developmentand defines capability definitions to hide the original UI contributions from var-ious Modeling projects. To create our model, we select the /model folder anduse the File → New → Domain Model (Ctrl+3 → Domain Model) wizard, whichis really just the GMF Ecore diagram wizard. Name the model and diagram filesmindmap.ecore and mindmap.ecore_diagram, respectively. Optionally, youcan 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 ourmindmap Ecore model. First, right-click on the blank diagram surface and selectShow Properties View. This shows the properties for the root package in our newEcore model. Each Ecore model has a single root package, under which we cancreate a number of additional subpackages. In our case, we set the propertiesaccordingly: name and Ns Prefix should be set to mindmap; Ns URI should beset to http://www.eclipse.org/2008/mindmap.

Using Figure 3-4, model the mindmap domain using the palette andProperties view. It’s a straightforward model to implement, with only a couplenoteworthy items: First, the MapElement class is abstract; second, therootTopics relationship is derived, transient, and volatile. We implement thisderived reference using OCL in Section 3.3.5, “Adding OCL.”

The diagram surface has many features to explore, as discussed in Section10.1, “Overview.” You should note a few things, however, when using the Ecorediagram to create the mindmap domain model:

3.3 Developing the Mindmap Domain Model 41

Page 20: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

Aggregation links create a reference with the Containment property setto true, in contrast with Association links, which are noncontainmentreferences.

Setting the upper bound property of a link to –1 creates a many relation-ship and causes the link to be displayed with the familiar 0..* notation.

References with eOpposites are shown in Figure 3-4 as a single connec-tion, whereas the Ecore diagram shows two separate links.

3.3.3 Creating the Mindmap Generator Model

With our mindmap.ecore model complete, we can validate it and create a gen-erator model. To validate it, open the model in the Sample Ecore Model Editorand right-click on the root package. Select Validate and confirm that no errorsexist. If there are errors, correct them and continue. We look into adding valida-tion for our mindmap model later, which leverages a similar validation frame-work provided for all Ecore models.

To create mindmap.genmodel, right-click the mindmap.ecore file inExplorer view and select New → Other → Domain-Specific Language → DomainGenerator Model (Ctrl+3 → Domain Gen). Note that the original EMF wizardis found in New → Other → Eclipse Modeling Framework → EMF Model(Ctrl+3 → EMF Model). We started by selecting our mindmap.ecore model,so the wizard defaults to the same folder and provides the name we want. It alsorecognizes that we are importing an Ecore model, but we have to load it our-selves, curiously. We have only one root package, so we can finish the wizard andtake a look at the generator model properties.

EMF generator models include several properties to consider. For ourmindmap, we need to change only a couple from their default settings. In theroot, change the Compliance Level from 1.4 to 5.0 (if it’s not already set to5.0) and change the Model Directory to be /org.eclipse.mindmap/src.(Note that this changes the edit, editor, and tests properties as well.) We need tomanually change the Model Plug-in ID property to org.eclipse.mindmap,however. In the properties for the Mindmap root package, we need to set theBase Package property to org.eclipse to match our new plug-in namespace.

This gets us started, so we can move on to code generation. Later, we returnto our mindmap model and add constraints, validation, and other enhancements.

42 CHAPTER 3 • Developing a DSL Abstract Syntax

Page 21: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

3.3.4 Generate and Run

The last thing to do is generate our mindmap plug-ins and code. Technically, wedon’t need to generate code at this time because we plan to leverage dynamicinstances as long as we can in the development of our DSLs. However, for thosenew to EMF, it’s worthwhile to continue with generation at this point to see howthings work. This is accomplished by right-clicking the root of the mindmap.genmodel in the editor tree and selecting Generate All. This generates our modelcode, edit code, editor code, and test skeletons, each in their own plug-in proj-ects. We don’t need the generated editor code because a diagram provides ourprimary means of working with mindmap instance models. For now, we can con-tinue by running the generated editor to verify our model and configuration.

To run our plug-ins and test the functionality of our editor, we need to be inthe Plug-in Development Environment perspective to gain access to the appro-priate Run option. Select Run → Open Run Dialog (Ctrl+3 → Run C) and cre-ate a new Eclipse Application run configuration named requirements in adirectory named runtime-requirements. Figure 3-5 is an image of this dia-log. Figure 3-6 shows the Arguments page with some arguments for launchingon Mac OS X. We use this launch configuration throughout our development ofthe sample projects, hence the general requirements name.

TIP

If you get tired of adding arguments to your launch configurations eachtime you create one, navigate in the Preferences dialog to Plug-InDevelopment → Target Platform → Launching Arguments andenter them in the field provided.These values will be copied into any newlaunch configuration you create.

Run this configuration to launch a new instance of Eclipse with the newplug-ins installed. We could trim the plug-in list to launch only those plug-ins weneed for our application. This makes launching faster and keeps us aware of ourunderlying plug-in dependencies. In Chapter 8, “DSL Packaging andDeployment,” we fine-tune our launch settings before creating our product con-figuration.

3.3 Developing the Mindmap Domain Model 43

Page 22: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

In the runtime workbench, create a new project and follow New → ExampleEMF Model Creation Wizards → Mindmap Model, giving it whatever name youwant and selecting Map as the Model Object. The default EMF-generated editorappears upon finish, ready for you to create new Topic and Relationshipinstances within the map.

You again need to open the Properties view to set model element propertiesand establish subtopics and relationship links. Notice that validation is availablefor our model instances and enforces the basic structural features defined in ourmodel. For example, we declared 1 for the upper and lower bounds onsource and target references of our Relationship class. Creating a newRelationship instance in our model and invoking the Validate menu optionbrings up a dialog that points out that these required features were not set. Aswe enhance our model further, EMF and the Validation Framework will provideadditional validation, as used by GMF for diagram validation.

44 CHAPTER 3 • Developing a DSL Abstract Syntax

Figure 3-5 Requirements launch configuration

Page 23: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

Figure 3-6 Requirements launch configuration arguments

3.3.5 Adding OCL

As you should recall, we added a derived, transient, volatile rootTopics refer-ence in our Map class. Section 3.2.4, “Applying OCL,” described the basics ofadding OCL and using dynamic templates to generate implementations forinvariant constraints, method bodies, and derived features. The example in thatsection covered the rootTopics implementation using OCL and used a set ofdynamic templates that we use in this context as well. At this time, rename thedefault templates folder to be a templates-domain source folder in the mindmapproject, and copy the templates provided in the solution into this folder. We’llhave additional templates later for deployment, so we can separate them into dif-ferent root folders. Each DSL project that uses OCL to refine its domain model

3.3 Developing the Mindmap Domain Model 45

Page 24: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

will reuse this set of templates. Then return to Section 3.2.4 and configure themindmap.ecore model to use OCL to implement the rootTopics feature.

We can leverage OCL in our model in additional places to provide an imple-mentation and avoid having to modify our generated code. Let’s begin by addinga method that returns the full set of subtopics for a given Topic.

Finding All Subtopics

Currently, our model has a subtopics reference on each Topic, along with amethod, allSubtopics(), that is intended to return a list of all of a Topic’ssubtopics—that is, its subtopics, all of their subtopics, and so on. All methodsdeclared in an Ecore model require an implementation to be provided, so we turnto OCL, where the implementation of this method is trivial, thanks to the non-standard closure iterator in MDT OCL:

self->closure(subtopics)

We need to add an EAnnotation to the method in our model with Sourceequal to http://www.eclipse.org/2007/OCL. A child Details Entry isadded to the annotation with the previous expression as its Value property andwith a Key value of body. When we regenerate our model code, we can see thatour implementation is provided:

/*** The parsed OCL expression for the body of the * '{@link #allSubtopics <em>All Subtopics</em>}' operation.* <!-- begin-user-doc -->* <!-- end-user-doc -->* @see #allSubtopics* @generated*/private static OCLExpression<EClassifier> allSubtopicsBodyOCL;

private static final String OCL_ANNOTATION_SOURCE ="http://www.eclipse.org/2007/OCL";

/*** <!-- begin-user-doc -->* <!-- end-user-doc -->* @generated*/public EList<Topic> allSubtopics() {if (allSubtopicsBodyOCL == null) {EOperation eOperation = MindmapPackage.Literals.TOPIC.getEOperations().get(0);

OCL.Helper helper = OCL_ENV.createOCLHelper();

46 CHAPTER 3 • Developing a DSL Abstract Syntax

Page 25: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

helper.setOperationContext(MindmapPackage.Literals.TOPIC,eOperation);

EAnnotation ocl = eOperation.getEAnnotation(OCL_ANNOTATION_SOURCE);String body = ocl.getDetails().get("body");

try {allSubtopicsBodyOCL = helper.createQuery(body);

} catch (ParserException e) {throw new UnsupportedOperationException(e.getLocalizedMessage());

}}

Query<EClassifier, ?, ?> query = OCL_ENV.createQuery(allSubtopicsBodyOCL);

@SuppressWarnings("unchecked")Collection<Topic> result = (Collection<Topic>) query.evaluate(this);

return new BasicEList.UnmodifiableEList<Topic>(result.size(),result.toArray());

}

Again, here we see the boilerplate OCL code that configures anOCLExpression if it’s the first invocation, and then it invokes the expressionobtained from the annotation. We leave the mindmap model at this point andmove on to develop the second domain model in our product line.

3.4 Developing the Requirements Domain Model

In a similar fashion to our mindmap model, we create a new org.eclipse.dsl.requirements DSL project here to hold our requirements model. Thisforms the base of our fictitious Requirements Management Project (RMP). Wecreate the new requirements.ecore model using the Domain Model Wizardand GMF Ecore diagram, and we complete it to match the diagram and descrip-tion of Figure 3-7.

Basically, a model contains a collection of RequirementGroups, which con-tain a number of children groups and Requirements. Requirements havechild references and contain Version and optional Comment elements. A numberof enumerations for Priority, State, Type, and Resolution are also in themodel. A Requirement can also have a number of dependent requirements,which become the basis for our dependency diagram. Note that the author attrib-utes are simple strings. We could create a Team model and reference these ele-ments to assign to our requirements and comments. We also could have aseparate Discussion model to use here and in our mindmap, as a topic might havean associated discussion thread. Many possibilities exist, but for the purposes ofour sample application, we keep it simple.

3.4 Developing the Requirements Domain Model 47

Page 26: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

Figure 3-7 Requirements domain model

3.4.1 Requirements Generator Model

We create a requirements.genmodel in the usual manner, using the newDomain Generator Model (Ctrl+3 → Domain Gen) wizard and selecting ourrequirements.ecore model as the input. We’ll make some adjustments to thisgenmodel and to the generated Edit code because we intend to use the generatedEMF editor as part of our solution.

For the display string of a requirement in the editor selection tree, we wantto have it be id (major.minor.service):title, where major, minor, andservice are from the contained Version element. We’ll be using the Propertiesview to edit the details of the requirement, so we’ll have plenty of horizontalspace to use in the editor, allowing even longer requirement titles to fit. Anotheroption is to navigate using the Project Explorer view, but this is narrow and doesnot allow for much information display. Furthermore, we’ll have a second tab inthe editor to display a requirements dependency diagram, which will also requirea bit of editor space. To accomplish the task, we’ll select the requirement elementin the genmodel and change its Edit Label Feature to be our id:EStringattribute. Unfortunately, we cannot set two attributes to display for the label, aswe can for GMF diagrams. This means we have to modify the generated code.

48 CHAPTER 3 • Developing a DSL Abstract Syntax

Page 27: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

Before generation, we need to check the other properties and make changesaccordingly. As with the mindmap and other models, we want to generate ourmodel, edit, and editor code to their own projects, so we can change the ModelPlug-in ID and Model Directory properties to be org.eclipse.require-ments.model. We generate the three plug-ins and open the org.eclipse.requirements.provider.RequirementItemProvider class from our Editplug-in. Modify the getText() method as seen next. Note that if we wanted topreserve the generated method to allow the label feature of the generator modelto have an effect, we could use the getTextGen() method approach, as describedin the EMF documentation.

/*** This returns the label text for the adapted class.* Modified to show id (major.minor.service) : title** @generated NOT*/@Overridepublic String getText(Object object) {StringBuilder sb = new StringBuilder();sb.append(((Requirement)object).getId());sb.append(" (");Version version = ((Requirement)object).getVersion();if (version != null) {sb.append(((Requirement)object).getVersion().getMajor());sb.append(".");sb.append(((Requirement)object).getVersion().getMinor());sb.append(".");sb.append(((Requirement)object).getVersion().getService());

} else {sb.append("0.0.0");

}sb.append(") : ");sb.append(((Requirement)object).getTitle());String label = sb.toString();return label == null || label.length() == 0 ?getString("_UI_Requirement_type") : label;

}

We’ve eliminated the redundant Requirement prefix from our label becausewe’re using a custom icon to distinguish Requirements from RequirementGroups, Comments, and so on. For our RequirementGroup element, we cansimilarly modify the getText() method to display only the name attribute; wecan modify the Comment element to display created, author, and subject.

3.4 Developing the Requirements Domain Model 49

Page 28: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

3.5 Developing the Scenario Domain Model

Because we’re basing the notation for our Scenario diagram on the BusinessProcess Modeling Notation (BPMN) standard, we could simply use its descrip-tion of the underlying domain model and semantics to develop our DSL. A bet-ter approach would have been to find an XSD for BPMN and simply import itinto EMF. Unfortunately, no such schema is published with the specification—even worse, a new specification from the OMG, the Business Process DefinitionMetamodel (BPDM), is slated to provide a domain model for BPMN2. Alsounfortunate is that this specification has no serialized format that we can use andis overly complicated for our Scenario DSL. This leaves us to create our own sce-nario model.

In a new org.eclipse.dsl.scenario project, we can create our sce-nario.ecore model as the base of our fictitious Requirements Scenario Project(RSP) project. Figure 3-8 is the model to create using our Ecore diagram.

50 CHAPTER 3 • Developing a DSL Abstract Syntax

Figure 3-8 Scenario domain model

Elements of a scenario model are maintained in the Process class, whichitself extends Element. A Connection maintains target and source referencesfor Elements that are connected in Sequence or Message flows. AnAssociation also connects elements. Elements come in a variety of types,including Tasks, Events, DataObjects, and Gateways. These elements allmap in a straightforward manner to notation elements because the model is

Page 29: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

inherently graphical in nature. The model is actually similar to the descriptionprovided in the BPMN specification, although it is a subset.

3.6 Developing the Business Domain Model

Plenty of options exist for developing the domain model that will form the baseof our fictitious Business Domain Modeling (BDM) project. We want somethingless complicated than the Unified Modeling Language (UML) model for struc-tural class modeling, but something expressive enough to generate code eitherdirectly or through an intermediate model. Also, the model should constrain theuser to the supported methodology and domain of business models. For the pur-poses of this book, the four archetypes described for business domain modelingin Java Modeling in Color with UML [46] seem like a good option. Figure 3-9 isa partial image of the Domain-Neutral Component (DNC) model, created withthe editor we develop in Section 4.6, “Developing the Color ModelingDiagram.” Of course, a black-and-white rendering of a color modeling diagramin the printed form of this book is not very compelling.

3.6 Developing the Business Domain Model 51

«role»

PartyRole

«moment–interval»

MomentInterval

«description»

PartyDescription

«mi–detail»

MIDetail

«party»

Party

0..1

0..1

0..1 0..–1

Figure 3-9 Color archetypes

Basically, a set of archetypes is used to model moment-interval, role, party,place, thing, and description elements and their relationships. The relationshipsand several described patterns of interaction are provided in the book, which wewant to facilitate in our modeling environment. First, however, we need anunderlying model (a DSL).

This DSL is strongly rooted in a general object-oriented DSL, so we beginwith just that. Figure 3-10 is an oocore.ecore model that we extend to add our

Page 30: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

archetypes and other DNC elements. Why begin with a general object-orientedDSL? Well, we might decide to use this model as the basis for another DSL in thefuture. Why not simply extend Ecore itself, you might ask? Well, it contains ele-ments that we really don’t need or want, leaving us with all those E-prefixed ele-ments and their properties. Besides, it’s straightforward to develop our ownobject-oriented DSL. We can use the Java EMF Model (JEM) as a transforma-tion target, giving us a chance to see what a model that extends Ecore is like.

Adventurous types can create a new org.eclipse.dsl.oocore DSL proj-ect and create the oocore.ecore model, as we have done previously. Completethe model using Figure 3-10 as a reference. Otherwise, simply copy theoocore.ecore domain model from the solutions into your project. Finally, cre-ate a new org.eclipse.dsl.dnc DSL project to hold our dnc.ecore modelthat will extend our core model.

52 CHAPTER 3 • Developing a DSL Abstract Syntax

Figure 3-10 Object-oriented core domain model

Page 31: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

With our base model complete, we can create our dnc.ecore model. To ref-erence our oocore.ecore model in our newly created dnc.ecore model, weneed to use the EMF Load Resource context menu in the default EMF editor.Fortunately, the dialog that appears now contains options to Browse RegisteredPackages, Browse File System, and Browse Workspace. At one time, you neededto enter platform:/ URIs into the field to load a registered package. In ourcase, the oocore.ecore model is easily found in our workspace.

In creating our DNC model (Figure 3-11), several options exist, as always.You’ve seen that using an enumeration to define the type is one solution, as wasused in the Mindmap domain model’s Relationship class and Type enum.This approach has some drawbacks, including the loss of polymorphic behaviorin our templates and transformation scripts. To illustrate the differences, let’s goahead and create an Archetype abstract class that extends our oocore::Classclass. Each of our archetypes will extend the Archetype class. We also add anAssociation class that extends oocore::Reference and add a property tosignify aggregation. Although it is not a true Association class in the UMLsense, it aids us in developing our diagram and hiding some complexities of theunderlying model to the Practitioner. As we develop the diagram and other DSLartifacts, we’ll revisit this model and refine it as necessary, potentially pulling upsome functionality into the domain model to aid in our color modeling andmodel transformations.

3.6 Developing the Business Domain Model 53

Figure 3-11 Domain-neutral component domain model

Page 32: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

3.7 Summary

This chapter explored the capabilities of EMF as the means of describing ourDSL abstract syntax. Although we leave the details of EMF to its own book, wecovered enough to get started developing our sample projects. The benefits ofleveraging a common underlying metamodel and generation capabilities shouldbecome clear as we continue to develop the DSL projects.

At this point, we have starter domain models for our fictitious ERP, plus areference to a fifth oocore DSL. We now move on to describing how to creategraphical concrete syntax for those we want to provide diagrams for, under-standing that we will most likely revisit and enhance the EMF models we createdin this chapter.

54 CHAPTER 3 • Developing a DSL Abstract Syntax

Page 33: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

Index

Symbols:= (assignment operator), 568« » (guillemets), 606+= (assignment operator), 568

Aabsolute coordinates (Draw2d), 323-324abstract syntax

definition of, 4developing with EMF (Eclipse Modeling

Framework)Model Compare, 11Model Query, 11Model Search, 11Model Transaction, 10Model Validation, 10persistence alternatives, 11

AbstractCommand class, 463AbstractEditPart (GEF), 325AbstractProviderConfiguration class, 378AbstractTransactionalCommand, 464access keyword, 553accessorCall() function, 219ActionFilterProvider extension-point, 424-426ActionFilterService, 423-426actions. See also specific actions

selection actions, 342subtopic actions, 90-93for user interface plug-ins, 307-310

activate() method, 336add() operation, 582

addChild() method, 334-335addChildVisual() method, 335addFields() method, 206addFixedChild() method, 166addNotationalListeners() method, 211, 546addNotify() method, 335addSuffixNumber() operation, 593AdviceContent operations, 627AdviceContent properties, 626Aggregation Link Mapping (color modeling

diagram), 198-200aliases. See shortcutsAlign Bottom toolbar element, 356Align Center toolbar element, 355Align Left toolbar element, 355Align Middle toolbar element, 356Align Right toolbar element, 355Align Top toolbar element, 355AlignmentAction, 349All Compartments toolbar element, 356allSubobjects() operation, 579allSubobjectsOfKind() operation, 579allSubobjectsOfType() operation, 579Amalgam, 15Amalgamation project, 20anchors, 94-96, 323annotations

annotation figure definition (color modeling diagram), 188-189

Annotation Mapping (color modeling diagram), 195

in Ecore metamodel, 33

675

Page 34: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

676 Index

Ant, 649Ant tasks, OML and, 243-244Appearance properties (diagrams), 358-359AppearancePreferencePage class, 206AppearancePreferencePage.xpt template,

216-217Apply Appearance Property toolbar

element, 355archetype figure definition (color modeling

diagram), 182-184AROUND statement (Xpand), 617-619Arrange All toolbar element, 355Arrange Selected toolbar element, 355artifacts (DSL Toolkit)

abstract elements, 17Practitioner, 18-19Toolsmith artifacts, 17-18

artwork, adding to products, 304-305asBoolean() operation, 591asFloat() operation, 592asInteger() operation, 592asList() operation, 583asOrderedTuple() operation, 578aspects (Xpand), 647-648assert expression, 576-577assignment operator (:=), 568assignment operator (+=), 568asTransformation() operation, 582ATL (Atlas Transformation Language), 231AttributeParserProvider class, 221-224audits

audits and metrics model, 532-533for mindmap diagram, 97-103

Auto Size toolbar element, 356

BBackground Color property (figures), 508BDM (Business Domain Modeling), 22bending connections (GEF), 351-352Boolean operations, 622Border Layout, 513Border property (figures), 508

bordersBorder Layout, 513Compound Border, 510Custom Border, 510Line Border, 510Margin Border, 510

Both command (Diagram menu), 361BPDM (Business Process Definition

Metamodel), 50, 665BPEL, mapping with BPMN, 231BPMN (Business Process Modeling

Notation), 50, 665BPMN2, 14mapping with BPEL, 231

Bring Forward command (Order menu), 361Bring to Front command (Order menu), 361business domain model, 51-53Business Domain Modeling (BDM), 22Business Process Modeling Notation. See BPMN

Ccached extensions (Xtend), 639canExecute() method, 483canonical containers, 547Canvas, 505-506Canvas Mapping, 520

mindmap diagram, 71requirements diagram, 108

casting, 635chain expression, 634-635Checks language, 228ChopboxAnchor (Draw2d), 323class2columns() query, 600classes. See specific classesclipboardSupport extension-point, 457-458clipping in Draw2d, 321clone() operation, 579Coad, Peter, 57code generation

in EMF, 34-35for mindmap domain model, 43-45

code modification, GMF customization options, 65

collapsible compartments, 518collect() operation, 564, 631-632

Page 35: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

Index 677

collections, 630operations, 623-624properties, 623

collectselect imperative iterate expression, 567color in graphical notations, 57color modeling diagram, 22, 181-182

annotation figure definition, 188-189archetype figure definition, 182-184color preferences, 205-220

addNotationalListeners() method, 211DiagramAppearancePreferencePage

class, 207-208getPreferenceColor() method, 211initializeDefaultPreferences()

method, 209initPreferenceStoreListener()

method, 211Messages class, 209messages.properties file, 210NodeEditPart.xpt template file, 212,

215-216preference page templates, 216-220PreferencePropertyChangeListener

class, 211, 214setForegroundColor() method, 211setForegroundColor() method,

overriding, 205toPreferenceConstant() function, 213updateArchetypeColor() method, 211

custom parsers, 220AttributeParserProvider class, 221-224OperationParserProvider class,

224-225generalization link definition, 186-187generation, 201gradient figures, 201-205mapping definition

Aggregation Link Mapping, 198-200Annotation Mapping, 195DNC Association Mapping, 195-197DNC Canvas Mapping, 190Generalization Mapping, 200-201Moment-Interval Archetype Mapping,

191-192Package Mapping, 194Role Archetype Mapping, 193

package figure definition, 185-186tooling definition, 189

CombinedTemplateCreationEntry, 344combining layouts, 515comma-separated values (CSV) files, generating,

281-282command infrastructure (GMF runtime),

462-464commands. See specific commandscomments

OML, 593Xtend, 637

Compartments, 518compliance, specification compliance, 668COMPONENT_ROLE key, 343Compound Border, 510concrete syntax development, 4, 12

GMF (Graphical Modeling Framework).See GMF runtime; GMF Tooling

TMF (Textual Modeling Framework), 12configuration properties (transformations), 555configureGraphicalViewer() method, 327connection bend interactions (GEF), 351-352connection creation interactions (GEF), 349-350connection edit interactions (GEF), 350-351connection EditParts, 330-331Connection figures, creating for scenario

diagram, 155-158connection handles (diagrams), 364-365connection navigation, 657-658ConnectionBendpointTracker, 352ConnectionCreationTool (GEF), 349ConnectionEndpointEditPolicy, 351ConnectionRouter (Draw2d), 322Connections, 517

bending, 351-352creating, 349-350, 479-484in Draw2d, 322-323editing, 350-351

constraints, node constraints, 526ContainerEditPolicy, 348containers, canonical, 547Contains Shortcuts To property (Gen

Diagram), 536context menus, 363-364

Page 36: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

678 Index

contributing to GMF (Graphical ModelingFramework), 546

contributionItemProvider extension-point, 409-418

ContributionItemServicecontributionItemProvider extension-point,

409-418overview, 408

coordinate systems in Draw2d, 323-324copy() operation, 582Copyright Text property (Gen Editor

Generator), 534Core language (QVT), 231, 549Core properties (diagrams), 358create expression, 635createDecorators() method, 498createDefaultEditPolicies() method, 385, 474createEditPart() method, 334createEditPolicies() method, 333-335, 385, 481createEmptyDocument() method, 126createEmptyModel() operation, 582createFigure() method, 328createGraphicEditPart() method, 382createMainFigure() method, 114createNodePlate() method, 516createPages() method, 129-130createPartControl() method, 139creation interactions (GEF)

CreateRequestsconsuming, 345producing, 344

creation sequence, 345-347Creation Wizard, 137-138Creation Wizard Category ID property (Gen

Diagram), 538CSV (comma-separated values) files, generating,

281-282Custom Behavior element, 539Custom Border, 510custom EditPolicy, 493-497custom figures, 89-90custom layout, 82-84custom parsers (color modeling diagram), 220

AttributeParserProvider class, 221-224OperationParserProvider class, 224-225

Custom Property Tab (requirements diagram), 140

custom style, 490-493customization options (GMF)

code modification, 65decorators, 66, 497-500dynamic templates, 65-66extension-points, 65model extensions, 66

Ddashboard view (GMF), 66-67Data Object figure, creating for scenario

diagram, 158-159Data Object Mapping (scenario diagram), 165database persistence, 177-181dataType2columns() query, 600dataType2primaryKeyColumns() mapping,

603-604deactivate() method, 336-337deactivating EditParts, 336-337declaring extension-points, 373-375decorateView() method, 488DecorationService

decoratorProvider extension-point, 392-396

overview, 392decoratorProvider extension-point, 392-396decorators, custom, 66, 497-500deepclone() operation, 580Default Size (diagram elements), 516DEFINE statement (Xpand), 607-608definition operations, 627definition properties, 627DelegatingLayout (Draw2d), 323delete interactions (GEF), 342-343DeleteAction, 342dependencies (GEF), 318deploying DSLs, 303

artwork, 304-305generation models, 310-311requirements.product, 312source deployment, 312-313user interface plug-ins, 305-310

Page 37: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

Index 679

designing graphical notations, 56-57developing DSLs, 6development workflow (DSL Toolkit), 18-20DI (Diagram Interchange), 664diagram editor, 467-468

cycling between diagram editor andpalette, 653-654

Diagram File Extension property (Gen EditorGenerator), 534

Diagram Interchange (DI), 664Diagram Label, 517Diagram menu commands, 361DiagramAppearancePreferencePage class,

207-208DiagramDecoratorProvider, 396diagramEventBrokerProvider extension-point,

441-443DiagramEventBrokerService extension-point,

441-443DiagramRootEditPart (GEF), 326diagrams. See also specific diagrams

adding EditParts to, 334-336connection handles, 364-365constructing from scratch

compared to generated diagrams, 485-486

connections, 479-484diagram editor, 467-468domain model, 468-469EditPart definition, 473-475New Diagram Wizard, 475-476palette definition, 470-471properties view, configuring, 476-479view definition, 471-473

context menus, 363-364diagram elements

Compartment, 518Connection, 517Diagram Label, 517Node, 516-517overview, 516

Diagram menu, 361extending

custom decorator, 497-500custom EditPolicy, 493-497custom style, 490-493

scenario diagram custom view andedit providers, 486-489

figureschanging appearance based on prefer-

ence changes, 546changing dynamically, 546changing properties of, 547making nonresizable, 547viewing elements on diagrams, 547

including in multipage editors, 548navigation, 655Order menu, 361Outline view, 366Palette view, 360partitioning, 171, 522

Requirements diagram partition, 172-177

subprocess partitions, 171-172pop-up bars, 365preferences, 367-368properties

Appearance properties, 358-359Core properties, 358Rulers & Grid properties, 356-358

toolbar elements, 354-356View menu, 361-363

dialogs. See specific dialogsdisjunction in mapping operations, 562disjuncts keyword, 562DNC Association Mapping (color modeling

diagram), 195-197DNC Canvas Mapping (color modeling

diagram), 190documentProviders extension-point, 453-455doExecuteWithResult() method, 483Domain File Extension property (Gen Editor

Generator), 535Domain Gen Model property (Gen Editor

Generator), 535domain models, 108, 468-469. See

also metamodelsbest practices, 30business domain models, 264-276business DSL, 51-53creating DSLs, 29-31dynamic instance models, 262

Page 38: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

680 Index

dynamic instances, 38-39Ecore models, 39importing, 31mindmap DSL, 39-40

code generation, 43-45creating, 41-42generator model, creating, 42OCL, adding, 45-47project setup, 40-41running, 43-45transformation to requirements

domain model, 244-251transformation to XHTML, 251-258

OCL in, 35-38requirements DSL, 47-49scenario DSL, 50-51synchronizing, 59, 76

doRun() method, 495downloading DSL Toolkit, 20DragDropListenerProvider extension-point,

436-438DragDropListenerService, 436-438DragTracker, 341Draw2d, 318

connections and routing, 322-323coordinate systems, 323-324figures, 318-319interaction sequence, 320layout, 322LightweightSystem, 318-319painting, 320-321text, 319UpdateManager, 318

DSL InstancesJava DSL Instances, 24-25mindmap and requirements DSL

Instances, 23-24scenario DSL Instances, 24-25

DSL Project Wizard, 40DSL Toolkit

abstract elements, 17BDM (Business Domain Modeling), 22development workflow, 18-20downloading, 20Java DSL Instances, 24-25

mindmap and requirements DSLInstances, 23-24

Practitioner, 18-19Practitioner’s view of sample projects, 25REP (Requirements Elicitation Project), 21RMP (Requirements Management

Project), 21RSP (Requirement Scenario Project), 22scenario DSL Instances, 24-25Toolsmith artifacts, 17-18

DSLsbusiness DSL, 51-53creating, 29-31definition of, 5developing, 6graphical notation. See graphical notationmindmap DSL, 39-40

code generation, 43-45creating, 41-42generator model, creating, 42OCL, adding, 45-47project setup, 40-41running, 43-45transformation to requirements

domain model, 244-251transformation to XHTML, 251-258

object-oriented, 51packaging and deployment, 303

artwork, 304-305generation models, 310-311requirements.product, 312source deployment, 312-313user interface plug-ins, 305-310

requirements DSL, 47-49scenario DSL, 50-51textual syntaxes

overview, 227-228TCS (Textual Concrete Syntax), 229Xtext, 228-229

dynamic instance models, 38-39, 262dynamic templates, 65-66Dynamic Templates property (Gen Editor

Generator), 535

Page 39: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

Index 681

EEAnnotations, 33Eclipse Packaging Project (EPP), 20Eclipse Requirements Project (ERP)

BDM (Business Domain Modeling), 22REP (Requirements Elicitation Project), 21RMP (Requirements Management

Project), 21RSP (Requirement Scenario Project), 22

Ecore metamodel, 32-33, 39edit providers, 486-489Edit Source Folder dialog, 298editing. See GEF (Graphical Editing Framework)Editing Domain ID property (Gen

Diagram), 538EditingDomain, sharing, 123-126EditorProvider extension-point, 427-428editors, QVT OML editor, 240EditorService, 427-428EditPartFactory, 326-327, 372editpartProvider extension-point, 382-385EditParts (GEF), 325-326

AbstractEditPart, 325adding to diagram, 334-336connection EditParts, 330-331creating, 326-329deactivating, 336-337definition, 473-475DiagramRootEditPart, 326EditPartFactory, 326-327, 372GraphicalEditParts, 325lifecycle, 334-337ScalableFreeformRootEditPart, 326TreeEditParts, 325

EditPartService, 382-385EditPolicies, 333-334, 493-497editpolicyProvider extension-point, 386-387EditPolicyService, 385-387element creation (GMF runtime), 459-461element operations (OML)

allSubobjects(), 579allSubobjectsOfKind(), 579allSubobjectsOfType(), 579clone(), 579

deepclone(), 580_globalId(), 578_localId(), 578markedAs(), 580markValue(), 580metaClassName(), 578stereotypedBy(), 580stereotypedStrictlyBy(), 580subobjects(), 578subobjectsOfKind(), 579subobjectsOfType(), 579

elements. See specific elementsElementSelectionProvider extension-point,

429-430ElementSelectionService, 428-430elementTypeBindings extension-point, 449-451elementTypes extension-point, 443-449Ellipse, 509EMF (Eclipse Modeling Framework)

code generation, 34-35domain models, importing, 31dynamic instances, 38-39Ecore metamodel, 32-33editor, integrating with

requirements diagramrefactoring editor, 127-130sharing editing domain, 123-126sharing file extension, 122-123

Model Compare, 11Model Query, 11Model Search, 11Model Transaction, 10Model Validation, 10OCL in, 35-38overview, 10persistence alternatives, 11runtime features, 33-34

EMOF (Essential MOF), 663End Events, 152endsWith() operation, 587entry operations (mapping operations), 559-560enumerationAttributes2columns() query, 602EPP (Eclipse Packaging Project), 20equalsIgnoreCase() operation, 589

Page 40: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

682 Index

ERP (Eclipse Requirements Project)BDM (Business Domain Modeling), 22REP (Requirements Elicitation Project), 21RMP (Requirements Management

Project), 21RSP (Requirement Scenario Project), 22

ERROR statement (Xpand), 616escape sequences, 594Essential MOF (EMOF), 663Event figures, creating for scenario diagram,

152-154Event Mapping (scenario diagram), 164execute() method, 378executing transformations

assert expression, 576-577log expression, 576trace model, 575transform() operation, 577transformation composition, 577

execution semantics (mapping operations), 558-559

ExecutionStrategy, 376exists() operation, 633expand element, 646EXPAND statement (Xpand), 608-612exporting figures, 62expression language (Xpand)

casting, 635chain expression, 634-635collect() operation, 631-632collections, 630create expression, 635exists() operation, 633forAll() operation, 632let expression, 635literals, 628-630reject() operation, 631select() operation, 630sortBy() operation, 633switch expression, 634ternary expression, 634typeSelect() operation, 631

expressions. See specific expressionsextending diagrams

custom decorator, 497-00500custom EditPolicy, 493-497

custom style, 490-493scenario diagram custom view and edit

providers, 486-489extends keyword, 553extensibility mechanisms (GMF), 372-373. See

also extension-pointsExtensible Markup Language (XML), 664extension keyword, 636EXTENSION statement (Xpand), 613-614extension-points

ActionFilterProvider, 424-426clipboardSupport, 457-458contributionItemProvider, 409-418declaring, 373-375decoratorProvider, 392-396diagramEventBrokerProvider, 441-443documentProviders, 453-455DragDropListenerProvider, 436-438EditorProvider, 427-428editpartProvider, 382-385editpolicyProvider, 386-387ElementSelectionProvider, 429-430elementTypeBindings, 449-451elementTypes, 443-449GlobalActionHandlerProvider, 420-423GMF customization options, 65IconProvider, 397-399layoutProvider, 406-408logListeners, 452-453MarkerNavigationProvider, 400-401modelingAssistantProvider, 404-406overview, 373-375paletteProvider, 388-392ParserProvider, 402-403Pathmaps, 459perspectiveExtensions, 306perspectives, 306preferencePages, 306propertiesConfiguration, 453PropertiesProvider, 431-433PropertyModifier, 434-435renderedImageFactory, 456-457TransferAdapterProvider extension-point,

439-441viewProvider, 379-382

ExtensionMap element, 643

Page 41: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

Index 683

extensions (Xtend)cached extensions, 639extension invocation, 637-638Java extensions, 639private extensions, 639

Externalizer.xpt template, 216-218extractor (TCS), 229

Ffactories, 7-8feature initialization, 527-528feature properties, 625Figure Gallery, 61, 504

Border Layout, 513Compound Border, 510Custom Border, 510custom figures, 89-90Ellipse, 509figure properties, 507-508Flow Layout, 511-512Grid Layout, 513-515Label, 510Line Border, 510Margin Border, 510overview, 506-507Polygon, 509Polyline, 509Polyline Connection, 509Rectangle, 509Rounded Rectangle, 509Stack Layout, 512subtopic figures, 84-89TemplatePoint, 509XY Layout, 512

figure plug-ins, 62FigureDescriptor, 503FigureRef, 504figures, 318-319

Border Layout, 513changing appearance based on preference

changes, 546changing dynamically, 546changing properties of, 547

in color modeling diagramannotation figure definition, 188-189archetype figure definition, 182, 184generalization link definition, 186-187package figure definition, 185-186

Compound Border, 510Custom Border, 510Ellipse, 509exporting, 62Flow Layout, 511-512Grid Layout, 513-515Label, 510Line Border, 510making nonresizable, 547Margin Border, 510Polygon, 509Polyline, 509Polyline Connection, 509properties

common properties, 507-508Flow Layout figure properties, 511shape figure properties, 508

Rectangle, 509Rounded Rectangle, 509in scenario diagram, 145-146

Connection figures, 155-158Data Object figure, 158-159Event figures, 152-154Gateway figure, 149-152Subprocess figure, 147-149Task figure, 146-147

Stack Layout, 512TemplatePoint, 509viewing elements on diagrams, 547XY Layout, 512

FigureUtilities class, 501FILE statement (Xpand), 612Fill property (shape figures), 508fillGradient() method, 202fillShape() method, 202filters in graphical notations, 57-58find() operation, 589findFeature() method, 474FIRST service execution strategy, 377firstElementOnly element, 644firstToUpper() operation, 586

Page 42: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

684 Index

fixed anchor locations, 94-96Flow Layout, 511-512Font property (figures), 508Fontoura, Marcus, 56forAll() operation, 632Force Single Line property (Flow Layout

figure), 511forEach loop expression, 565FOREACH statement (Xpand), 612-613Foreground Color property (figures), 508format() operation, 584forOne loop expression, 565FORWARD service execution strategy, 377Frankel, David, 4

GGateway figure, creating for scenario diagram,

149-152Gateway Mapping (scenario diagram), 163-164GEF (Graphical Editing Framework)

Commands, 332connection interactions

connection bend interactions, 351-352connection creation interactions,

349-350connection edit interactions, 350-351

creation interactionsconnection creation interactions,

349-350consuming CreateRequests, 345creation sequence, 345-347producing CreateRequests, 344

delete interactions, 342-343dependencies, 318editing support

Commands, 332EditPolicies, 333-334Requests, 331-332

EditParts, 325-326AbstractEditPart, 325adding to diagrams, 334-336connection EditParts, 330-331creating, 326-329deactivating, 336-337

DiagramRootEditPart, 326EditPartFactory, 326-327GraphicalEditParts, 325lifecycle, 334-337ScalableFreeformRootEditPart, 326TreeEditParts, 325

EditPolicies, 333-334graphical view

ScrollingGraphicalViewer, 326setting up, 327-328

Model-View-Controller (MVC) architecture, 324-325

moving and resizing interactions, 347-349overview, 317palette, 337Requests, 331-332selection interactions

keyboard selection, 342overview, 338-340selection actions, 342selection handles, 340-341selection requests, 342selection targeting and feedback, 341Selection Tool, 339selection with DragTracker, 341

tools, 337Gen Application element, 543Gen Diagram

Contains Shortcuts To property, 536Creation Wizard Category ID property,

538Editing Domain ID property, 538Icon Path ID property, 538Shortcuts Provided For property, 536Synchronized property, 537Units property, 537Updater element, 542Validation Decorators property, 537Validation Enabled property, 537Visual ID property, 538Without Domain property, 538

Gen Editor GeneratorCopyright Text property, 534Diagram File Extension property, 534Domain File Extension property, 535Domain Gen Model property, 535

Page 43: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

Index 685

Dynamic Templates property, 535Model ID property, 535Package Name Prefix property, 535Same File for Diagram and Model

property, 535-536Template Directory property, 535

Gen Editor View element, 540-541Gen Link, 539Gen Navigator element, 541-542Gen Plugin element, 540generalization link definition (color modeling

diagram), 186-187Generalization Mapping (color modeling

diagram), 200-201generalizations2columns() query, 600Generate as Eclipse Editor property (Gen Editor

View), 541Generate Domain Model Navigator property

(Gen Navigator), 541generating

color modeling diagram, 201CSV files, 281-282HTML with templates (M2T project),

297-301Java files

with DNC model with templates, 291-297

with Java model and dedicated template, 283-291

requirements diagram, 113scenario diagram

border item adjustment, 166-167figures plug-in generation, 168-171GMF generator model, 166intermediate event outline, 167-168

generation models, 310-311Generative Modeling Technologies (GMT), 15generator model, 64

Custom Behavior, 539Gen Application, 543Gen Diagram

Contains Shortcuts To property, 536Creation Wizard Category ID

property, 538Editing Domain ID property, 538Icon Path property, 538

Shortcuts Provided For property, 536Synchronized property, 537Units property, 537Validation Decorators property, 537Visual ID property, 538Without Domain property, 538

Gen Diagram Updater, 542Gen Editor Generator

Copyright Text property, 534Diagram File Extension property, 534Domain File Extension property, 535Domain Gen Model property, 535Dynamic Templates property, 535Model ID property, 535Package Name Prefix property, 535Same File for Diagram and Model

property, 535-536Template Directory property, 535

Gen Editor View, 540-541Gen Link, 539Gen Navigator, 541-542Gen Plugin, 540mindmap diagram example, 74-76mindmap generator model, 42Open Diagram Behavior, 539overview, 533-534Property Sheet, 542-543requirements generator model, 48-49

getActionBarContributor() method, 136getCommand() method, 332getContributorId() method, 134getDecoratorTargetNode() method, 498-500getDragSourceListener() method, 435getDropTargetListener() method, 435getModelChildren() method, 326getModelSourceConnections() method, 330getModelTargetConnections() method, 330getNodeEditPartClass() method, 475, 488getNotationView() method, 382getParseCommand() method, 224getParser() method, 224getPreferenceColor() method, 211getPropertySheetPage() method, 134getReferencedElementEClass() method, 475getSemanticCommand() method, 482getSemanticEClass() method, 472

Page 44: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

686 Index

getSourceConnectionAnchor() method, 330getStrCounter() operation, 592getTargetConnectionAnchor() method, 330getTargetEditPart() method, 332GlobalActionHandlerProvider extension-point,

420-423GlobalActionHandlerService, 419-423_globalId() operation, 578GMF (Graphical Modeling Framework)

runtime, 12, 55, 59. See also GMF Toolingadvantages of, 545canonical containers, 547color modeling diagram, 181-182

annotation figure definition, 188-189archetype figure definition, 182-184color preferences, 205-220custom parsers, 220-225generalization link definition, 186-187generation, 201gradient figures, 201-205mapping definition, 190-201package figure definition, 185-186tooling definition, 189

command infrastructure, 462-464contributing to, 546customization options

code modification, 65decorator models, 66dynamic templates, 65-66extension-points, 65model extensions, 66

dashboard view, 66-67diagram creation

compared to generated diagrams, 485-486

connections, 479-484diagram editor, 467-468domain model, 468-469EditPart definition, 473-475New Diagram Wizard, 475-476palette definition, 470-471properties view, configuring, 476-479view definition, 471-473

diagram extensioncustom decorator, 497-500custom EditPolicy, 493-497

custom style, 490-493scenario diagram custom view and

edit providers, 486-489diagram structure

connection handles, 364-365context menus, 363-364Diagram menu, 361Order menu, 361Outline view, 366Palette view, 360pop-up bars, 365preferences, 367-368properties, 356-359toolbar elements, 354-356View menu, 361-363

editor, integrating with requirements diagramrefactoring editor, 127-130sharing editing domain, 123-126sharing file extension, 122-123

element creation, 459-461extension-points

ActionFilterProvider, 424-426clipboardSupport, 457-458contributionItemProvider, 409-418declaring, 373-375decoratorProvider, 392, 394-396diagramEventBrokerProvider, 441-443documentProviders, 453-455DragDropListenerProvider, 436-438EditorProvider, 427-428editpartProvider, 382-385editpolicyProvider, 386-387ElementSelectionProvider, 429-430elementTypeBindings, 449-451elementTypes, 443-447, 449GlobalActionHandlerProvider,

420-423IconProvider, 397-399layoutProvider, 406-408logListeners, 452-453MarkerNavigationProvider, 400-401modelingAssistantProvider, 404-406overview, 373-375paletteProvider, 388-392ParserProvider, 402-403

Page 45: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

Index 687

Pathmaps, 459propertiesConfiguration, 453PropertiesProvider, 431-433PropertyModifier, 434-435renderedImageFactory, 456-457TransferAdapterProvider, 439, 441viewProvider, 379-382

extensibility mechanisms, 372-373figures

changing appearance based on preference changes, 546

changing dynamically, 546changing properties of, 547making nonresizable, 547viewing elements on diagrams, 547

key bindingsconnection navigation, 657-658cycling between diagram editor and

palette, 653-654diagram navigation, 655palette item navigation, 654Properties View navigation, 658-659shape navigation, 655-656

mindmap diagram improvementsaudits and metrics, 97-103custom figures, 89-90custom layout, 82-84fixed anchor locations, 94-96graphical definition model, 76-79mapping definition model, 80-81preferences settings, 97subtopic actions, 90-93subtopic figures, 84-89tooling definition model, 79topic figure layout, 81-82

nodes, sticking to border of parent, 548notation model, 369-372online resources, 545overview, 353-354prerequisites, 546requirements diagram

Creation Wizard, 137-138diagram definition, 104-107domain model, 108EMF and GMF editor integration,

122-130

generation, 113mapping definition, 107-113menus and toolbar, 135-137navigator extension, 139Outline view, 139-140properties, 140-145Properties view, 134-135selection handling, 130-134tooling definition, 107ToolTips, 114-121

runtime component, 60-61scenario diagram

Data Object Mapping, 165database persistence, 177-181diagram partitioning, 171-177Event Mapping, 164figures plug-in generation, 168-171Gateway Mapping, 163-164generation, 166-168graphical definition, 145-159Link Mapping, 165mapping definition, 161Task Mapping, 161-163tooling definition, 159-161

servicesActionFilterService, 423-426ContributionItemService, 408-418DecorationService, 392, 394-396DiagramEventBrokerService, 441-443DragDropListenerService, 435-438EditorService, 427-428EditPartService, 382-385EditPolicyService, 385-387ElementSelectionService, 428-430GlobalActionHandlerService,

419-423IconService, 396-399LayoutService, 406-408MarkerNavigationService, 399-401ModelingAssistantService, 403-406overview, 375-376PaletteService, 387-392ParserService, 401-403PropertiesModifierService, 433-435PropertiesService, 430-433Service class, 376

Page 46: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

688 Index

service execution strategies, 376-377TransferAdapterService, 438-441ViewService, 378-382

templates, modifying output of, 547tooling component, 61-62

FAQs, 547-548generator model, 64, 74-76graphical definition model, 61-63,

68-69, 76-79mapping model, 63-64, 70-74, 80-81tooling definition model, 63, 69, 79

Xpand, 548GMF (Graphical Modeling Framework) Tooling.

See also GMF runtimegenerator model

Custom Behavior, 539Gen Application, 543Gen Diagram, 536-538Gen Diagram Updater, 542Gen Editor Generator, 534-536Gen Editor View, 540-541Gen Link, 539Gen Navigator, 541-542Gen Plugin, 540Open Diagram Behavior, 539overview, 533-534Property Sheet, 542-543

graphical definition modelCanvas, 505-506diagram elements, 516-518Figure Gallery. See Figure Galleryfigures, 504overview, 503

mapping modelaudits and metrics, 532-533Canvas Mapping, 520feature initialization, 527-528Link Mapping, 529-532Node Mapping, 522-526overview, 519-520side-affixed nodes (pins and

ports), 528-529Top Node Reference, 521-522

tooling definition model, 518-519GMT (Generative Modeling Technologies), 15

gotoMarker() method, 399Grab Excess Horizontal Space property (Grid

Layout figure), 514Grab Excess Vertical Space property (Grid

Layout figure), 514Gradient (diagram elements), 516gradient figures, 201-205graphical concrete syntax, 4graphical definition model, 61-63

Canvas, 505-506diagram elements

Compartment, 518Connection, 517Diagram Label, 517Node, 516-517overview, 516

Figure Gallery, 504Border Layout, 513Compound Border, 510Custom Border, 510Ellipse, 509figure properties, 507-508Flow Layout, 511-512Grid Layout, 513-515Label, 510Line Border, 510Margin Border, 510overview, 506-507Polygon, 509Polyline, 509Polyline Connection, 509Rectangle, 509Rounded Rectangle, 509Stack Layout, 512TemplatePoint, 509XY Layout, 512

figures, 504mindmap diagram example, 68-69, 76-79overview, 503of scenario diagram, 145-146

Connection figure, 155-158Data Object figure, 158-159Event figures, 152-154Gateway figure, 149-152Subprocess figure, 147-149Task figure, 146-147

Page 47: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

Index 689

Graphical Editing Framework. See GEFGraphical Modeling Framework. See GMF

runtime; GMF Toolinggraphical notations. See also GMF (Graphical

Modeling Framework)design recommendations, 56-57filters/layers, 57-58layout, 58links in, 58selecting, 55shortcuts in, 59synchronization with domain models, 59

graphical view (GEF)ScrollingGraphicalViewer, 326setting up, 327-328

GraphicalEditParts (GEF), 325GraphicalNodeEditPolicy, 350-351GraphicalViewerKeyHandler, 342gratuitous graphics, avoiding, 56Grid Layout, 513-515Group Icon property (Gen Navigator Child

Reference), 542Group Name property (Gen Navigator Child

Reference), 542guillemets (« »), 606

HhandleActivate() method, 131handleContentOutlineSelection() method,

132-133handleNotificationEvent() method, 547hasPersistentClasses() query, 599Height command (Diagram menu), 361helper operations (OML), 562-563Hide Connector Labels toolbar element, 356Hide If Empty property (Gen Navigator Child

Reference), 542Horizontal Alignment property (Grid Layout

figure), 514Horizontal Indent property (Grid Layout

figure), 514Horizontal Span property (Grid Layout

figure), 514

HTML, generating with templates (M2T project), 297-301

HUNT (Human-Usable Textual Notation), 665

IIcon Path property

Gen Diagram, 538Gen Editor View, 540

IconProvider extension-point, 397-399IconService, 396-399ID property

Gen Editor View, 541Gen Plugin, 540

IDiagramWorkbenchPart interface, 137IDragDropListenerProvider interface, 435IF statement (Xpand), 614-615IGlobalActionHandler interface, 419IGlobalActionHandlerContext interface, 419IGraphicEditPart interface, 382IIconProvider interface, 396IMM (Information Management

Metamodel), 14imperative iterate expressions (OML), 566-567imperative operations (OML), 565-566

forEach loop expression, 565forOne loop expression, 565switch expression, 566while loop expression, 565-566

import keyword, 606, 636importing

domain models, 31XSD, 252-253

in-place transformations, 553incrStrCounter() operation, 593indexOf() operation, 586Information Management Metamodel

(IMM), 14inheritance in mapping operations, 560-561inherits keyword, 560-561initArchetypeDefaults() method, 209, 219initializeDataStore() method, 179initializeDefaultPreferences() method, 209initializeEditingDomain() method, 123initPreferenceStoreListener() method, 211

Page 48: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

690 Index

injector (TCS), 229inline graphics, 57insertAt() operation, 583Insets property (figures), 508installEditPolicy() method, 335instance models, 4instances, 4integer operations, 621-622interactions (GEF)

connection bend interactions, 351-352connection creation interactions, 349-350connection edit interactions, 350-351creation interactions, 344

consuming CreateRequests, 345creation sequence, 345-347producing CreateRequests, 344

delete interactions, 342-343moving and resizing interactions, 347-349overview, 338selection interactions

keyboard selection, 342overview, 338-340selection actions, 342selection handles, 340-341selection requests, 342selection targeting and feedback, 341Selection Tool, 339selection with DragTracker, 341

interfacesIDiagramWorkbenchPart, 137IDragDropListenerProvider, 435IGlobalActionHandler, 419IGlobalActionHandlerContext, 419IGraphicEditPart, 382IIconProvider, 396IOperation, 378IParser, 401IPropertiesProvider, 430IProvider, 376ISemanticParser, 224

intermediate elements, 554Intermediate Events, 152inv prefix, 573invoking

extensions, 637-638Java, 648mappings, 570-571

IOperation interface, 378IParser interface, 401IPropertiesProvider interface, 430IProvider interface, 376ISemanticParser interface, 224isPrimitive() query, 601isQuoted() operation, 590iterator properties, 627

JJava

business domain model transformationsto, 264-276

DSL Instances, 24-25extensions (Xtend), 639files, generating

with DNC model with templates, 291-297

with Java model and dedicated template, 283-291

JEM (Java EMF Model), 265JETs (Java Emitter Templates), 34, 665invocation, 648

Java Modeling in Color with UML (Coad, et al),22, 57

JavaBeautifier, 296JEM (Java EMF Model), 265jemUtil.ext file, 283-286JETs (Java Emitter Templates), 34, 665joinfields() operation, 583

Kkey bindings (GMF)

connection navigation, 657-658cycling between diagram editor and

palette, 653-654diagram navigation, 655palette item navigation, 654Properties View navigation, 658-659shape navigation, 655-656

keyboard selection (GEF), 342keyboard shortcuts, adding to elements, 90-93keywords. See specific keywords

Page 49: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

Index 691

LLabel Offset (diagram elements), 516labels, 510

Diagram Label, 517Label Offset (diagram elements), 516

Lanza, Michele, 57LAST service execution strategy, 377lastToUpper() operation, 586late operator, 574-575launch configurations

arguments, 43in OML, 240-242

layers in graphical notations, 57-58LayoutEditPolicy, 345layoutProvider extension-point, 406-408layouts

Border Layout, 513combining, 515custom layout, 82-84with Draw2d, 322Flow Layout, 511-512of graphical notations, 58Grid Layout, 513-515Stack Layout, 512of topic figures, 81-82XY Layout, 512

LayoutService, 406-408LET statement, 615-616, 635libraries. See Stdliblifecycle of EditParts, 334-337LightweightSystem (Draw2d), 318-319Line Border, 510Line Kind property (shape figures), 508Line Width property (shape figures), 508Link Mapping, 529-532Link Mapping (scenario diagram), 165links in graphical notations, 58lists, 624lite runtime (GMF), 60-61Literal Strings, 594literals (Xpand), 628-630Load Resource dialog, 188_localId() operation, 578Location property (figures), 508log expression, 576logListeners extension-point, 452-453

loopsforEach loop expression, 565forOne loop expression, 565while loop expression, 565-566

MM2M (Model-to-Model Transformation), 12-13M2T (Model-to-Text Transformation) project

CSV files, generating, 281-282HTML, generating, 297-301Java files, generating with DNC model

with templates, 291-297dncUtil.ext file, 295Entity bean template, 291-294workflow file, 296

Java files, generating with Java model anddedicated template, 283-291Address type output, 287-288jemUtil.ext file, 283-286Person class, 289-290Phone class, 290-291workflow, 286-287

overview, 277Xpand, 278-281Xtend, 278-281

main keyword, 559Major Alignment property (Flow Layout

figure), 511Major Spacing property (Flow Layout

figure), 511map keyword, 570mapping definition

Aggregation Link Mapping, 198-200Annotation Mapping, 195DNC Association Mapping, 195-197DNC Canvas Mapping, 190Generalization Mapping, 200-201Moment-Interval Archetype Mapping,

191-192Package Mapping, 194requirements diagram mapping

definition, 107-113Canvas mapping, 108Requirement link mappings, 112

Page 50: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

692 Index

Requirement node mapping, 111-112RequirementGroup link mapping, 110RequirementGroup node mapping,

109-110Requirements Dependency link

mappings, 113Role Archetype Mapping, 193of scenario diagram

Data Object Mapping, 165Event Mapping, 164Gateway Mapping, 163-164Link Mapping, 165Task Mapping, 161-163

mapping model, 63-64audits and metrics, 532-533Canvas Mapping, 520feature initialization, 527-528Link Mapping, 529-532mindmap diagram example, 70-74, 80-81Node Mapping, 522-524

containment, 524node constraints, 526phantom nodes, 524-526references, 524

overview, 519-520side-affixed nodes (pins and ports),

528-529Top Node Reference, 521-522

mapping operations (OML). Seealso transformations

BPMN and BPEL, 231disjunction, 562entry operations, 559-560execution semantics, 558-559inheritance, 560-561invoking mappings, 570-571mapping body, 558merger, 561return statement, 559syntax, 556-558

Margin Border, 510Marinescu, Radu, 57markedAs() operation, 580MarkerNavigationProvider extension-point,

400-401MarkerNavigationService, 399-401

markValue() operation, 580Match Minor Size property (Flow Layout

figure), 511match() operation, 589matchBoolean() operation, 590matchFloat() operation, 591matchIdentifier() operation, 591matchInteger() operation, 591MatchSizeAction, 349Maximum Size property (figures), 508MDA (Model-Driven Architecture)

implemented standardsBusiness Process Modeling

Notation, 665Diagram Interchange, 664Extensible Markup Language, 664Human-Usable Textual Notation, 665Meta-Object Facility, 662-663MOF Models to Text Transformation

Language, 664Object Constraint Language, 663overview, 662Query/View/Transformation, 664Software Process Engineering

Metamodel, 666Unified Modeling Language, 663

overview, 661-662working relationship

implementations influencing specifications, 668

membership, 666-667open and transparent nature, 668-669specification compliance, 668specification delivery, 667-668

MDSD (Model-Driven Software Development)metamodels, 3-4overview, 7

MDTs. See Model Development ToolsmenuAboutToShow() method, 136menus

adding to elements, 90-93requirements diagram, 135-137

merges keyword, 561merging

in mapping operations, 561models, 237

Page 51: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

Index 693

Messages class, 209messages.properties file, 210Meta-Object Facility (MOF), 662-663metaClassName() operation, 578metaModel element, 646Metamodel Explorer view, 240-241metamodels, 3-4, 32-33. See also domain modelsmethods. See specific methodsmetrics for mindmap diagram, 97-103migration of models, 233-237mindmap and requirements DSL Instances,

23-24mindmap domain model, 39-40

code generation, 43-45creating, 41-42generator model for, 74-76generator model, creating, 42graphical definition model for, 68-69,

76-79improvements to

audits and metrics, 97-103custom figures, 89-90custom layout, 82-84fixed anchor locations, 94-96graphical definition model, 76-79mapping definition model, 80-81preferences settings, 97subtopic actions, 90-93subtopic figures, 84-89tooling definition model, 79topic figure layout, 81-82

mapping model for, 70-74, 80-81OCL, adding, 45-47project setup, 40-41running, 43-45tooling definition model for, 69, 79transformations

to requirements domain model, 244-251

to XHTML, 251-258mindmap2csv.mwe file, 282mindmap2csv.xpt template, 281mindmap2requirements transformation,

308-309Minimum Size property (figures), 508

Minor Alignment property (Flow Layout figure), 511

Minor Spacing property (Flow Layout figure), 511

Model Compare (EMF), 11Model Development Tools (MDT), 662

BPMN2, 14IMM (Information Management

Metamodel), 14OCL (Object Constraint Language), 14UML2, 13UML2 Tools, 14XSD (XML Schema), 13

Model Driven Architecture: Applying MDA toEnterprise Computing (Frankel), 4

Model-Driven Architecture. See MDAModel-Driven Software Development.

See MDSDmodel extensions, 66Model ID property (Gen Editor Generator), 535model merge, 237model migration, 233-237model operations (OML)

add(), 582asList(), 583asTransformation(), 582copy(), 582createEmptyModel(), 582insertAt(), 583joinfields(), 583objects(), 581objectsOfType(), 581prepend(), 582removeElement(), 581rootObjects(), 581

Model Query (EMF), 11model refactoring, 232-233Model Search (EMF), 11Model Transaction (EMF), 10model transformations. See transformationsModel Validation (EMF), 10Model-to-Model Transformation (M2M), 12-13Model-to-Text Transformation project. See

M2T projectModel-View-Controller (MVC) architecture,

324-325

Page 52: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

694 Index

model2RDBModel() mapping, 598Modeling Amalgamation Project, 15modeling, overview of, 3-5modelingAssistantProvider extension-point,

404-406ModelingAssistantService, 403-406models. See specific modelsmodelSlot element, 644modeltype declaration, 550-553MOF (Meta-Object Facility), 662-663MOF2Text, 664Moment-Interval Archetype Mapping (color

modeling diagram), 191-192monitor size for graphical notations, 56moving and resizing interactions (GEF), 347-349MultiPageSelectionProvider, 130-131MVC (Model-View-Controller) architecture,

324-325

NName Compartment Onl toolbar element, 356Name property (figures), 508navigation

connection navigation, 657-658diagram navigation, 655palette item navigation, 654Properties View navigation, 658-659shape navigation, 655-656

Navigator Child Reference property (GenNavigator), 541-542

navigator extension (requirements diagram), 139New Diagram Wizard, 475-476NodeEditPart.xpt template file, 212, 215-216Nodes, 516-517

node constraints, 526Node Mapping, 86, 522-524

containment, 524node constraints, 526phantom nodes, 524-526references, 524

sticking to border of parent, 548nonresizable figures, creating, 547NonResizeableEditPolicy, 547normalizeSpace() operation, 588

notation model, 369-372notations. See graphical notationsnull in transformation declarations, 556number type operations (OML), 583

OObject Constraint Language (OCL), 14, 663object keyword, 568object operations (OML), 578object-oriented DSLs, 51Object-Oriented Metrics in Practice (Lanza and

Marinescu), 57objects. See also specific objects

creating, 568-570operations, 620populating, 568-570

objects() operation, 581objectsOfType() operation, 581Oblique Style Routing toolbar element, 355OCL (Object Constraint Language), 14, 663

adding to mindmap domain model, 45-47in EMF, 35-38OML and, 243testing, 35

OMGMDA (Model-Driven Architecture).

See MDAworking relationship

implementations influencing specifications, 668

membership, 666-667open and transparent nature, 668-669specification compliance, 668specification delivery, 667-668

OML (Operational Mapping Language)Ant tasks and, 243-244comments, 593described, 238element operations, 580helper operations, 562-563imperative iterate expressions, 566-567imperative operations, 565-566

forEach loop expression, 565forOne loop expression, 565

Page 53: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

Index 695

switch expression, 566while loop expression, 565-566

launch configurations, 240-242libraries, 556mapping invocation, 570-571mapping operations

disjunction, 562entry operations, 559-560execution semantics, 558-559inheritance, 560-561mapping body, 558merger, 561return statement, 559syntax, 556-558

Metamodel Explorer view, 240-241model operations, 580object creation and population, 568-570OCL statements and, 243OCL synonyms, 596operations and iterators

collect() operation, 564select() operation, 563

overview, 550QVT OML editor, 240QVT Operational Project wizard, 238-239resolution operators

inv prefix, 573late, 574-575resolve, 571-572resolveIn, 573resolveone, 573resolveoneIn, 573

shorthand, 594-595Std library

add() operation, 582addSuffixNumber() operation, 593allSubobjects() operation, 579allSubobjectsOfKind() operation, 579allSubobjectsOfType() operation, 579asBoolean() operation, 591asFloat() operation, 592asInteger() operation, 592asList() operation, 583asOrderedTuple() operation, 578asTransformation() operation, 582clone() operation, 579

copy() operation, 582createEmptyModel() operation, 582deepclone() operation, 580endsWith() operation, 587equalsIgnoreCase() operation, 589find() operation, 589firstToUpper() operation, 586format() operation, 584getStrCounter() operation, 592_globalId() operation, 578incrStrCounter() operation, 593indexOf() operation, 586insertAt() operation, 583isQuoted() operation, 590joinfields() operation, 583lastToUpper() operation, 586_localId() operation, 578markedAs() operation, 580markValue() operation, 580match() operation, 589matchBoolean() operation, 590matchFloat() operation, 591matchIdentifier() operation, 591matchInteger() operation, 591metaClassName() operation, 578normalizeSpace() operation, 588objects() operation, 581objectsOfType() operation, 581prepend() operation, 582quotify() operation, 590range() operation, 583removeElement() operation, 581replace() operation, 588repr() operation, 578restartAllStrCounter() operation, 593rfind() operation, 589rootObjects() operation, 581size() operation, 584startStrCounter() operation, 592startsWith() operation, 587stereotypedBy() operation, 580stereotypedStrictlyBy() operation, 580subobjects() operation, 578subobjectsOfKind() operation, 579subobjectsOfType() operation, 579substringAfter() operation, 585

Page 54: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

696 Index

substringBefore() operation, 584toLower() operation, 585toString() operation, 583toUpper() operation, 585trim() operation, 587unquotify() operation, 590

strings, 594trace model, 242-243transformation declarations

access keyword, 553configuration properties, 555extends keyword, 553in-place transformations, 553intermediate elements, 554modeltype declaration, 550-553null, 556predefined variables, 555renaming elements, 555

transformation executionassert expression, 576-577log expression, 576trace model, 575transform() operation, 577transformation composition, 577

UML to RDB Transformation Project,596-603associationAttributes2columns()

mapping, 604class2columns() query, 600dataType2columns() query, 600dataType2primaryKeyColumns()

mapping, 603enumerationAttributes2columns()

query, 602generalizations2columns() query, 600hasPersistentClasses() query, 599isPrimitive() query, 601model2RDBModel() mapping, 598package2schema() query, 599package2schemas() mapping, 598persistentClass2table() query, 599primitiveAttributes2columns()

query, 601relationshipAttribute2foreignKey()

mapping, 603

relationshipAttributes2columns()query, 602

transformation declaration, 597open and transparent nature, 668-669Open Diagram Behavior element, 539Operational Mapping Language. See OMLOperationParserProvider class, 224-225operations (OML). See specific operationsoperators

inv prefix, 573late, 574-575resolve, 571-572resolveIn, 573resolveone, 573resolveoneIn, 573

Order menu commands, 361org.eclipse.gmf.runtime.draw2d.render

plug-ins, 501org.eclipse.gmf.runtime.gef.ui plug-in, 502outlet element, 646Outline property (shape figures), 508Outline view (diagrams), 139-140, 366outlineShape() method, 167overwriting user code modifications,

avoiding, 35

Ppackage figure definition (color modeling

diagram), 185-186Package Mapping (color modeling

diagram), 194Package Name Prefix property (Gen Editor

Generator), 535Package Selection dialog, 116package2schema() query, 599package2schemas() query, 598packaging DSLs, 303

artwork, 304-305generation models, 310-311requirements.product, 312source deployment, 312-313user interface plug-ins, 305

actions, 307-310preferences, 306-307wizard and perspective, 305-306

Page 55: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

Index 697

paint() method, 320paintBorder() method, 321paintChildren() method, 321paintClientArea() method, 320paintFigure() method, 320painting with Draw2d, 320-321palette

cycling between diagram editor andpalette, 653-654

definition, 470-471GEF (Graphical Editing Framework)

palette, 337palette item navigation, 654Palette view (diagrams), 360

paletteProvider extension-point, 388-392PaletteService, 387-392ParserProvider extension-point, 402-403ParserService, 401-403partitioning. See diagram partitioningPasteTemplateAction, 345Pathmaps extension-point, 459performFinish() method, 137-138performRequest() method, 333persistence

database persistence, 177-181persistence alternatives (EMF), 11

persistentClass2table() query, 599Person class, 289-290perspectiveExtensions extension-point, 306perspectives extension-point, 306phantom nodes, 524-526Phone class, 290-291platformUri element, 642Plug-in Project wizard, 305-306plug-ins, developing

actions, 307-310preferences, 306-307wizard and perspective, 305-306

policies. See specific policiesPolygon, 509Polyline, 509Polyline Connection, 322, 509polymorphism, Xpand support for, 610-612pop-up bars (diagrams), 365populating objects, 568-570

postprocessor element, 646-647Practitioner (DSL Toolkit), 18-19predefined variables, 555preference page templates (color modeling

diagram), 216-220PreferenceInitializer.xpt template, 219preferencePages extension-point, 306PreferencePropertyChangeListener class,

211, 214preferences

diagrams, 367-368mindmap diagram improvements, 97user interface plug-ins, 306-307

Preferred Size property (figures), 508prepend() operation, 582primitiveAttributes2columns() query, 601Printing Enabled property (Gen Plugin), 540private extensions (Xtend), 639product line engineering, 7-8project interaction, 15-16project setup, mindmap DSL, 40-41properties

of diagramsAppearance properties, 358-359Core properties, 358Rulers & Grid properties, 356-358

of figurescommon properties, 507-508Flow Layout figure properties, 511shape figure properties, 508

of Gen DiagramContains Shortcuts To property, 536Creation Wizard Category ID

property, 538Editing Domain ID property, 538Icon Path property, 538Shortcuts Provided For property, 536Synchronized property, 537Units property, 537Validation Decorators property, 537Validation Enabled property, 537Visual ID property, 538Without Domain property, 538

of Gen Editor GeneratorCopyright Text, 534Diagram File Extension, 534

Page 56: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

698 Index

Domain File Extension, 535Domain Gen Model, 535Dynamic Templates, 535Model ID, 535Package Name Prefix, 535Same File for Diagram and Model,

535-536Template Directory, 535

of Gen Editor ViewGenerate as Eclipse Editor, 541Icon Path, 540ID, 541

of Gen NavigatorGenerate Domain Model

Navigator, 541Navigator Child Reference, 541-542

of Gen PluginID, 540Printing Enabled, 540Provider, 540Required Plugin Identifiers, 540Version, 540

of requirements diagram, 140-145Custom Property Tab, 140Property tab, 144RequirementDescriptionProperty

Section class, 142-143of workflow configuration files, 641transformation configuration

properties, 555Properties View, 134-135, 476-479, 658-659propertiesConfiguration extension-point, 453PropertiesModifierService, 433-435PropertiesProvider extension-point, 431-433PropertiesService, 430-433property operations, 626Property Sheet element, 542-543Property tab (requirements diagram), 144PropertyModifier extension-point, 434-435PROTECT statement (Xpand), 615Provider property (Gen Plugin), 540ProviderPriority, 376provides() method, 224, 376, 498

QQuery/View/Transformation. See QVTquotify() operation, 590QVT (Query/View/Transformation), 664.

See also transformationsCore language, 549OML (Operational Mapping Language).

See OMLOperational Project wizard, 238-239Relations language, 549

QVTO scripts, 307

Rrange() operation, 583RDBMS, UML to RDB Transformation Project,

596-603associationAttributes2columns()

mapping, 604class2columns() query, 600dataType2columns() query, 600dataType2primaryKeyColumns()

mapping, 603enumerationAttributes2columns()

query, 602generalizations2columns() query, 600hasPersistentClasses() query, 599isPrimitive() query, 601model2RDBModel() mapping, 598package2schema() query, 599package2schemas() mapping, 598persistentClass2table() query, 599primitiveAttributes2columns() query, 601relationshipAttribute2foreignKey()

mapping, 603relationshipAttributes2columns()

query, 602transformation declaration, 597

Reader (Xpand), 644real operations, 622Rectangle, 509Rectilinear Style Routing toolbar element, 355recursion (Xtend), 638-639refactoring editors, 127-130refactoring models, 232-233

Page 57: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

Index 699

Reference Type property (Gen Navigator ChildReference), 542

refines keyword, 554refresh() method, 335, 500refreshChildren() method, 335refreshVisuals() method, 329-331, 335RegisterEcoreFile element, 643RegisterGeneratedEPackage element, 642-643reject() operation, 631Relations language (QVT), 231, 549relationship link mapping (mindmap diagram),

73-74, 77-80relationshipAttribute2foreignKey()

mapping, 603relationshipAttributes2columns() query, 602relative coordinates (Draw2d), 323-324REM statement (Xpand), 616removeChild() method, 335-336removeElement() operation, 581renaming elements, 555*.render.awt plug-ins, 501renderedImageFactory extension-point, 456-457REP (Requirements Elicitation Project), 21replace() operation, 588repr() operation, 578Requests (GEF), 331-332

CreateRequestsconsuming, 345producing, 344

selection requests, 342Required Plugin Identifiers property (Gen

Plugin), 540Requirement link mappings (requirements

diagram), 112Requirement node mapping (requirements

diagram), 111-112Requirement Scenario Project (RSP), 22RequirementDescriptionPropertySection class,

142-143RequirementGroup link mapping (requirements

diagram), 110RequirementGroup node mapping (requirements

diagram), 109-110Requirements Dependency link mappings

(requirements diagram), 113

requirements diagramCreation Wizard, 137-138diagram definition, 104-107domain model, 108EMF and GMF editor integration

refactoring editor, 127-130sharing editing domain, 123-126sharing file extension, 122-123

generation, 113mapping definition, 107-113

Canvas mapping, 108Requirement link mappings, 112Requirement node mapping, 111-112RequirementGroup link mapping,

110RequirementGroup node mapping,

109-110Requirements Dependency link

mappings, 113menus and toolbar, 135-137navigator extension, 139Outline view, 139-140partition, 172-177properties, 140-145

Custom Property Tab, 140Property tab, 144RequirementDescriptionProperty

Section class, 142-143Properties view, 134-135selection handling, 130-134tooling definition, 107ToolTips, 114-121

requirements domain model, 47-48generator model, creating, 48-49transformations from mindmap domain

model, 244-251Requirements Elicitation Project (REP), 21Requirements Management Project (RMP), 21requirements.product, configuring, 312RequirementsEditorPart class, 127-128RequirementsGeneralPreferencePage class, 307ResizableEditPolicy, 348resizing interactions (GEF), 347-349resolution operators (OML)

inv prefix, 573late, 574-575

Page 58: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

700 Index

resolve, 571-572resolveIn, 573resolveone, 573resolveoneIn, 573

resolve operator, 571-572resolveIn operator, 573resolveone operator, 573resolveoneIn operator, 573resolveSemanticElement() method, 382resources, GMF (Graphical Modeling

Framework) resources, 545restartAllStrCounter() operation, 593result keyword, 569return statement, 559revalidate() method, 322REVERSE service execution strategy, 377rfind() operation, 589RMP (Requirements Management Project), 21Role Archetype Mapping (color modeling

diagram), 193roles of EditPolicies, 333rootObjects() method, 560, 581Rounded Rectangle, 509routing in Draw2d, 322-323RSP (Requirement Scenario Project), 22Rulers & Grid properties (diagrams), 356-358run() method, 309-310, 648running mindmap domain model, 43-45runtime, EMF, 33-34runtime, GMF. See GMF runtime

SSame File for Diagram and Model property

(Gen Editor Generator), 535-536Sample Reflective Ecore Model Editor, 39ScalableFreeformRootEditPart (GEF), 326scenario diagram, 145

custom view, 486-489Data Object Mapping, 165database persistence, 177-181diagram partitioning

Requirements diagram partition, 172-177

subprocess partitions, 171-172

Event Mapping, 164Gateway Mapping, 163-164generation

border item adjustment, 166-167figures plug-in generation, 168-171GMF generator model, 166intermediate event outline, 167-168

graphical definition, 145-146Connection figures, 155-158Data Object figure, 158-159Event figures, 152-154Gateway figure, 149-152Subprocess figure, 147-149Task figure, 146-147

Link Mapping, 165mapping definition, 161Task Mapping, 161-163tooling definition, 159-161transformations to test cases, 258-264

scenario domain model, 50-51scenario DSL Instances, 24-25ScenarioEditPartProvider class, 488scripts, QVTO scripts, 307ScrollingGraphicalViewer (GEF), 326Select All Links toolbar element, 355Select All Shapes toolbar element, 355Select All toolbar element, 355select() operation, 563, 630SelectAllAction, 342selecting graphical notations, 55selection handling (requirements diagram),

130-134selection interactions (GEF)

keyboard selection, 342overview, 338-340selection actions, 342selection handles, 340-341selection requests, 342selection targeting and feedback, 341Selection Tool, 339selection with DragTracker, 341

Selection Tool (GEF), 339selectionProvider attribute

(MultiPageSelectionProvider), 130-131SelectionTreeEditorPart class, 128Send Backward command (Order menu), 361

Page 59: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

Index 701

Send to Back command (Order menu), 361serialization syntax, 4Service class, 376services

ActionFilterService, 423-426ContributionItemService, 408-418DecorationService, 392-396DiagramEventBrokerService, 441-443DragDropListenerService, 435-438EditorService, 427-428EditPartService, 382-385EditPolicyService, 385-387ElementSelectionService, 428-430GlobalActionHandlerService, 419-423IconService, 396-399LayoutService, 406-408MarkerNavigationService, 399-401ModelingAssistantService, 403-406overview, 375-376PaletteService, 387-392ParserService, 401-403PropertiesModifierService, 433-435PropertiesService, 430-433Service class, 376service execution strategies, 376-377TransferAdapterService, 438-441ViewService, 378-382

setContents() method, 327, 334setCurrentViewer() method, 131setForegroundColor() method, 205, 211setModel() method, 334setParent() method, 334setupContentPane() method, 517shape figures

Ellipse, 509Polygon, 509Polyline, 509Polyline Connection, 509properties, 508Rectangle, 509Rounded Rectangle, 509TemplatePoint, 509

shape navigation, 655-656SharedImages class, 396sharing EditingDomain, 123-126shortcuts in graphical notations, 59

Shortcuts Provided For property (Gen Diagram), 536

shorthand (QVT), 594-595Show Connector Labels toolbar element, 356side-affixed nodes (pins and ports), 528-529simplicity in graphical notations, 56Size property (figures), 508size() operation, 584software factories, 7-8Software Process Engineering Metamodel

(SPEM), 666software product lines, 7-8sortBy() operation, 633source, deploying, 312-313specifications

compliance, 668implementations influencing

specifications, 668specification delivery, 667-668

SPEM (Software Process EngineeringMetamodel), 666

Stack Layout, 512StandaloneSetup class

ExtensionMap element, 643platformUri element, 642RegisterEcoreFile element, 643RegisterGeneratedEPackage element,

642-643uriMap element, 642

Start Events, 152startStrCounter() operation, 592startsWith() operation, 587startup() method, 378statements. See specific statementsStaticProperty operations, 626StdLib library, 556

add() operation, 582addSuffixNumber() operation, 593allSubobjects() operation, 579allSubobjectsOfKind() operation, 579allSubobjectsOfType() operation, 579asBoolean() operation, 591asFloat() operation, 592asInteger() operation, 592asList() operation, 583asOrderedTuple() operation, 578

Page 60: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

702 Index

asTransformation() operation, 582clone() operation, 579copy() operation, 582createEmptyModel() operation, 582deepclone() operation, 580element operations, 580endsWith() operation, 587equalsIgnoreCase() operation, 589find() operation, 589firstToUpper() operation, 586format() operation, 584getStrCounter() operation, 592_globalId() operation, 578incrStrCounter() operation, 593indexOf() operation, 586insertAt() operation, 583isQuoted() operation, 590joinfields() operation, 583lastToUpper() operation, 586_localId() operation, 578markedAs() operation, 580markValue() operation, 580match() operation, 589matchBoolean() operation, 590matchFloat() operation, 591matchIdentifier() operation, 591matchInteger() operation, 591metaClassName() operation, 578normalizeSpace() operation, 588objects() operation, 581objectsOfType() operation, 581prepend() operation, 582quotify() operation, 590range() operation, 583removeElement() operation, 581replace() operation, 588repr() operation, 578restartAllStrCounter() operation, 593rfind() operation, 589rootObjects() operation, 581size() operation, 584startStrCounter() operation, 592startsWith() operation, 587stereotypedBy() operation, 580stereotypedStrictlyBy() operation, 580subobjects() operation, 578

subobjectsOfKind() operation, 579subobjectsOfType() operation, 579substringAfter() operation, 585substringBefore() operation, 584toLower() operation, 585toString() operation, 583toUpper() operation, 585trim() operation, 587unquotify() operation, 590

stereotypedBy() operation, 580stereotypedStrictlyBy() operation, 580StoreController class, 179string operations (OML), 594, 620

addSuffixNumber(), 593asBoolean(), 591asFloat(), 592asInteger(), 592endsWith(), 587equalsIgnoreCase(), 589find(), 589firstToUpper(), 586format(), 584getStrCounter(), 592incrStrCounter(), 593indexOf(), 586isQuoted(), 590lastToUpper(), 586match(), 589matchBoolean(), 590matchFloat(), 591matchIdentifier(), 591matchInteger(), 591normalizeSpace(), 588quotify(), 590replace(), 588restartAllStrCounter(), 593rfind(), 589size(), 584startStrCounter(), 592startsWith(), 587substringAfter(), 585substringBefore(), 584toLower(), 585toUpper(), 585trim(), 587unquotify(), 590

Page 61: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

Index 703

styles, custom, 490-493subobjects() operation, 578subobjectsOfKind() operation, 579subobjectsOfType() operation, 579Subprocess figure, creating for scenario

diagram, 147-149subprocess partitions, 171-172substringAfter() operation, 585subtopic actions, mindmap diagram

improvements, 90-93subtopic figures, mindmap diagram

improvements, 84-89subtopic link mapping (mindmap diagram), 73switch expression, 566, 634Synchronized property (Gen Diagram), 537synchronizing domain models, 59, 76synonyms (OCL), 596

TTask figure, creating for scenario diagram,

146-147Task Mapping (scenario diagram), 161-163TCS (Textual Concrete Syntax), 4, 229Template Directory property (Gen Editor

Generator), 535TemplatePoint, 509templates

dynamic templates, 65-66mindmap2csv.xpt, 281modifying output of, 547

TemplateTransferDragSourceListener, 344Teneo, 177-180ternary expression, 634Test and Performance Tools Project (TPTP),

258-264test cases, transforming scenarios to, 258-264testing OCL, 35text

Draw2d support for, 319with inline graphics, 57

Textual Concrete Syntax (TCS), 4, 229Textual Generic Editor (TGE), 229Textual Modeling Framework (TMF), 12, 665

textual syntaxes for DSLsoverview, 227-228TCS (Textual Concrete Syntax), 4, 229Xtext, 228-229

TGE (Textual Generic Editor), 229Tiger project, 233TMF (Textual Modeling Framework), 12, 665toLower() operation, 585toolbars

elements, 354-356requirements diagram, 135-137

tooling component (GMF), 61-62FAQs, 547-548generator model, 64, 74-76graphical definition model, 61-63,

68-69, 76-79mapping model, 63-64, 70-74, 80-81tooling definition model, 63, 69, 79

tooling definition, 63, 518-519of color modeling diagram, 189of mindmap diagram example, 69, 79of scenario diagram, 159-161of requirements diagram, 107

tools, GEF (Graphical Editing Framework)tools, 337

Toolsmith artifacts (DSL Toolkit), 17-18ToolTips, 114-121Top Node Reference, 521-522topic figure layout, 81-82topic mapping (mindmap diagram), 72TopicEditPart class., 475toPreferenceConstant() function, 213-214toRequirementsModel() method, 559toStateful() method, 561toString() operation, 583toUpper() operation, 585TPTP (Test and Performance Tools Project),

258-264trace model, 242-243, 575TransactionalEditingDomain, 123-130TransferAdapterProvider extension-point,

439-441TransferAdapterService, 438-441transform() operation, 577

Page 62: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

704 Index

transformationsbusiness domain models to Java, 264-276executing

assert expression, 576-577log expression, 576trace model, 575transform() operation, 577transformation composition, 577

implementation techniques, 231-232M2M (Model-to-Model

Transformation), 12-13M2T (Model-to-Text

Transformation) projectCSV fies, generating, 281-282HTML, generating, 297-301Java files, generating with DNC model

with templates, 291-297Java files, generating with Java model

and dedicated template, 283-291overview, 277Xpand, 278-281Xtend, 278-281

mindmap domain modelto requirements domain model,

244-251to XHTML, 251-258

mindmap2requirements, 308-309for model merge, 237for model migration, 233-237for model refactoring, 232-233OML transformation declarations

access keyword, 553configuration properties, 555extends keyword, 553in-place transformations, 553intermediate elements, 554modeltype declaration, 550-553null, 556predefined variables, 555renaming elements, 555

scenario diagrams to test cases, 258-264transformation composition, 577

transparent nature, 668-669Tree Style Routing toolbar element, 355TreeContainerEditPolicy, 345TreeEditParts (GEF), 325

trim() operation, 587Tufte, Edward, 56types

API documentationAdviceContent operations, 627AdviceContent properties, 626Boolean operations, 622collection operations, 623-624collection properties, 623definition operations, 627definition properties, 627feature properties, 625integer operations, 621-622iterator properties, 627list operations, 624object operations, 620object properties, 619operation operations, 626property operations, 626real operations, 622StaticProperty operations, 626string operations, 620string properties, 620type operations, 625type properties, 624

type inference (Xtend), 638type operations, 625type properties, 624

typeSelect() operation, 631

UUML (Unified Modeling Language), 663

UML to RDB Transformation Project,596-603associationAttributes2columns()

mapping, 604class2columns() query, 600dataType2columns() query, 600dataType2primaryKeyColumns()

mapping, 603enumerationAttributes2columns()

query, 602generalizations2columns() query, 600hasPersistentClasses() query, 599

Page 63: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

Index 705

isPrimitive() query, 601model2RDBModel() mapping, 598package2schema() query, 599package2schemas() mapping, 598persistentClass2table() query, 599primitiveAttributes2columns()

query, 601relationshipAttribute2foreignKey()

mapping, 603relationshipAttributes2columns()

query, 602transformation declaration, 597

UML2, 13UML2 Tools, 14

The UML Profile for Framework Architectures(Fontoura, et al), 56

umlPrimitive2rdbPrimitive() method, 568UmlRdbUtil library, 556UmlUtil library, 556Unified Modeling Language (UML), 663Units property (Gen Diagram), 537unquotify() operation, 590updateArchetypeColor() method, 211UpdateManager (Draw2d), 318updating model versions, 233-237uri element, 644uriMap element, 642user code modifications, avoiding

overwriting, 35user interaction sequence (Draw2d), 320user interface plug-ins, developing

actions, 307-310preferences, 306-307wizard and perspective, 305-306

Vvalidate() method, 322validation, 38Validation Decorators property (Gen

Diagram), 537Validation Enabled property (Gen

Diagram), 537variables, predefined, 555Version property (Gen Plugin), 540

versions of models, updating, 233-237Vertical Alignment property (Grid Layout

figure), 514Vertical property (Flow Layout figure), 511Vertical Span property (Grid Layout figure), 514View menu commands, 361-363viewing Ecore models, 39viewProvider extension-point, 379-382views

definition, 471-473scenario diagram custom view, 486-489

ViewService, 378-382Visual Facets (diagram elements), 516Visual ID property (Gen Diagram), 538

Wwhile loop expression, 565-566Width command (Diagram menu), 361Without Domain property (Gen Diagram), 538wizards

Creation Wizard, 137-138New Diagram Wizard, 475-476Plug-in Project wizard, 305-306

workflow engine (Xpand), 641Ant, 649aspects, 647-648EMF setup

ExtensionMap element, 643platformUri element, 642RegisterEcoreFile element, 643RegisterGeneratedEPackage

element, 642-643uriMap element, 642

Java invocation, 648properties, 641Reader, 644Xpand component, 644-647

expand element, 646metaModel element, 646outlet element, 646postprocessor element, 646-647

Page 64: Associate Publisher Indexer - pearsoncmg.comptgmedia.pearsoncmg.com/images/9780321534071/samplepages/... · 2009. 6. 9. · model makes your transformation definitions much easier

706 Index

X-Y-Zxcollect imperative iterate expression, 566XHTML, transforming mindmap domain

model to, 251-258xmap keyword, 570XML (Extensible Markup Language), 664XML Schema (XSD), 13XOR Fill property (shape figures), 509XOR Outline property (shape figures), 509Xpand, 665

AROUND statement, 617-619DEFINE statement, 607-608ERROR statement, 616EXPAND statement, 608-612expression language, 628

casting, 635chain expression, 634-635collect() operation, 631-632collections, 630create expression, 635exists() operation, 633forAll() operation, 632let expression, 635literals, 628-630reject() operation, 631select() operation, 630sortBy() operation, 633switch expression, 634ternary expression, 634typeSelect() operation, 631

EXTENSION statement, 613-614FILE statement, 612FOREACH statement, 612-613in GMF (Graphical Modeling

Framework), 548IF statement, 614-615IMPORT statement, 606LET statement, 615-616M2T (Model-to-Text Transformation)

project, 278-281overview, 605-606polymorphism support, 610-612PROTECT statement, 615REM statement, 616type system, 619-627

workflow engineAnt, 649aspects, 647-648EMF setup, 642-643Java invocation, 648properties, 641Reader, 644Xpand component, 644-647

Xtendcached extensions, 639comments, 637examples, 640-641extension invocation, 637-638extension keyword, 636extensions, 637import keyword, 636Java extensions, 639overview, 636private extensions, 639recursion, 638-639type inference, 638

Xpand component, 644-647expand element, 646metaModel element, 646outlet element, 646postprocessor element, 646-647

XSD (XML Schema), 13, 252-253Xtend

cached extensions, 639comments, 637examples, 640-641extension invocation, 637-638extension keyword, 636extensions, 637import keyword, 636Java extensions, 639M2T (Model-to-Text Transformation)

project, 278-281overview, 636private extensions, 639recursion, 638-639type inference, 638

Xtext, 228-229XY Layout, 512

Zoom toolbar element, 356