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