1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
|
<?xml version="1.0" encoding="UTF-8" ?>
<cheatsheet title="Generating an EMF Model from Annotated Java">
<intro href="/org.eclipse.emf.doc/tutorials/clibmod/clibmod.html">
<description>
This cheat sheet is a step-by-step description of how to generate an EMF
model and editor from a set of annotated Java interfaces.
</description>
</intro>
<item title="Set up the environment">
<description>
Your environment must be set up before you can perform the steps in this cheat sheet.
<br /><br />
Delete or rename the following projects if they exist in your workspace: "library.java", "library.java.edit", "library.java.editor".
</description>
</item>
<item title="Create an empty EMF project"
href="/org.eclipse.emf.doc/tutorials/clibmod/clibmod.html#newEmptyEMFProj"
dialog="true"
skip="true">
<description>
First, you must create a new "library.java" empty EMF project to house the annotated Java.
</description>
<subitem label="Select "File >New >Project...". Expand "Eclipse Modeling Framework", select "Empty EMF Project" and click "Next"." skip="true">
<action
pluginId="org.eclipse.emf.cheatsheets"
class="org.eclipse.emf.cheatsheets.actions.OpenEmptyEMFProjectWizardAction"
param1="library.java"
translate="" />
</subitem>
<subitem label="Enter "library.java" as the "Project name", then click "Finish"." skip="false" />
</item>
<item title="Create Java interfaces and class"
href="/org.eclipse.emf.doc/tutorials/clibmod/clibmod.html#step1b"
dialog="true"
skip="true">
<description>
Create the interfaces and class in the "library.java" project that describe the model.
The model consists of three interfaces ("Library", "Writer", and "Book") and
a class ("BookCategory"), all in the "org.eclipse.example.library" package.
<br /><br />
You can click on (?) to see the contents of the interfaces and class.
</description>
<subitem label="Create the Library interface." skip="true">
<action
pluginId="org.eclipse.emf.cheatsheets"
class="org.eclipse.emf.cheatsheets.actions.CopyFileFromPluginAction"
param1="library.java"
param2="org.eclipse.example.library"
param3="org.eclipse.emf.cheatsheets/archive/java/Library.java"
translate="" />
</subitem>
<subitem label="Create the Writer interface." skip="true">
<action
pluginId="org.eclipse.emf.cheatsheets"
class="org.eclipse.emf.cheatsheets.actions.CopyFileFromPluginAction"
param1="library.java"
param2="org.eclipse.example.library"
param3="org.eclipse.emf.cheatsheets/archive/java/Writer.java"
translate="" />
</subitem>
<subitem label="Create the Book interface." skip="true">
<action
pluginId="org.eclipse.emf.cheatsheets"
class="org.eclipse.emf.cheatsheets.actions.CopyFileFromPluginAction"
param1="library.java"
param2="org.eclipse.example.library"
param3="org.eclipse.emf.cheatsheets/archive/java/Book.java"
translate="" />
</subitem>
<subitem label="Create the BookCategory class." skip="true">
<action
pluginId="org.eclipse.emf.cheatsheets"
class="org.eclipse.emf.cheatsheets.actions.CopyFileFromPluginAction"
param1="library.java"
param2="org.eclipse.example.library"
param3="org.eclipse.emf.cheatsheets/archive/java/BookCategory.java"
translate="" />
</subitem>
</item>
<item title="Create the EMF model"
href="/org.eclipse.emf.doc/tutorials/clibmod/clibmod.html#newEMFModJava"
dialog="true"
skip="true">
<description>
Create an EMF model from the annotated Java.
</description>
<subitem label="In the package explorer, right-click the "library.java/model" folder and select "New > Other..." from the pop-up menu. Then, expand "Eclipse Modeling Framework", select "EMF Model" and click "Next"." skip="true">
<action
pluginId="org.eclipse.emf.cheatsheets"
class="org.eclipse.emf.cheatsheets.actions.OpenEMFModelWizardAction"
param1="library.java/model/library.genmodel"
param2="org.eclipse.emf.importer.java"
translate="" />
</subitem>
<subitem label="Enter "library.genmodel" as the file name, then click "Next"." skip="false" />
<subitem label="Select "Annotated Java", then click "Next"." skip="false" />
<subitem label="Select the "org.eclipse.example.library" package, then click "Finish"." skip="false" />
</item>
<item
title="Generate the code"
href="/org.eclipse.emf.doc/tutorials/clibmod/clibmod.html#step2"
dialog="true"
skip="true">
<description>
Generate the code to implement the model and an editor for it. The generator is automatically opened on completion of the wizard in the previous step.
</description>
<repeated-subitem values="Model,Edit,Editor">
<subitem label="In the generator, right click on "Library" and select "Generate ${this} Code"." />
</repeated-subitem>
<subitem label="If automatic building has been disabled, select "Project > Build All" to compile the generated code." skip="true">
<action
pluginId="org.eclipse.emf.cheatsheets"
class="org.eclipse.emf.cheatsheets.actions.BuildAllProjectsAction" />
</subitem>
<subitem label="Select the "library.java" project in the package explorer and invoke "Source > Organize Imports" to remove unused imports." />
</item>
<item
title="Run the generated editor"
href="/org.eclipse.emf.doc/tutorials/clibmod/clibmod.html#step4"
dialog="true"
skip="true">
<description>
Now, you are set to run the generated editor and create a new library instance.
</description>
<onCompletion>
Congratulations! You have succesfully created an EMF model from annotated Java interfaces, generated the code, and created an instance of the model.
</onCompletion>
<subitem label="Select the "library.java" project in the package explorer and invoke the "Run > Run As > Eclipse Application" menu item. This starts a runtime instance of Eclipse with the newly generated plug-ins available." />
<subitem label="In the runtime instance, create a new general project called "librarytest"." />
<subitem label="Right click "librarytest" and select "New > Other..."." />
<subitem label="Expand "Example EMF Model Creation Wizards" and select "Library Model". Then, click "Next"." />
<subitem label="Enter "My.library" as the file name, then click "Next"." />
<subitem label="Select "Library"; as the model object, then click "Finish"." />
<subitem label="The generated library editor is opened. Expand "platform:/resource/librarytest/My.library". Right click "Library" and select "New Child > Writer" to create a writer object in the library." />
<subitem label="Create additional writers and books in the library, and edit the objects' properties in the properties view." />
<subitem label="Select "File > Save" to save the instance." />
</item>
</cheatsheet>
|