Debian Codegraph @

doc/org.eclipse.emf.cheatsheets/cheatsheets/GenerateEMFFromJava.xml

raw
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: &quot;library.java&quot;, &quot;library.java.edit&quot;, &quot;library.java.editor&quot;.
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 &quot;library.java&quot; empty EMF project to house the annotated Java.
25 </description>
26
27 <subitem label="Select &quot;File &gt;New &gt;Project...&quot;. Expand &quot;Eclipse Modeling Framework&quot;, select &quot;Empty EMF Project&quot; and click &quot;Next&quot;." 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 &quot;library.java&quot; as the &quot;Project name&quot;, then click &quot;Finish&quot;." 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 &quot;library.java&quot; project that describe the model.
44 The model consists of three interfaces (&quot;Library&quot;, &quot;Writer&quot;, and &quot;Book&quot;) and
45 a class (&quot;BookCategory&quot;), all in the &quot;org.eclipse.example.library&quot; 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 &quot;library.java/model&quot; folder and select &quot;New &gt; Other...&quot; from the pop-up menu. Then, expand &quot;Eclipse Modeling Framework&quot;, select &quot;EMF Model&quot; and click &quot;Next&quot;." 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 &quot;library.genmodel&quot; as the file name, then click &quot;Next&quot;." skip="false" />
103 <subitem label="Select &quot;Annotated Java&quot;, then click &quot;Next&quot;." skip="false" />
104 <subitem label="Select the &quot;org.eclipse.example.library&quot; package, then click &quot;Finish&quot;." 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 &quot;Library&quot; and select &quot;Generate ${this} Code&quot;." />
118 </repeated-subitem>
119 <subitem label="If automatic building has been disabled, select &quot;Project &gt; Build All&quot; 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 &quot;library.java&quot; project in the package explorer and invoke &quot;Source &gt; Organize Imports&quot; 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 &quot;library.java&quot; project in the package explorer and invoke the &quot;Run &gt; Run As &gt; Eclipse Application&quot; 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 &quot;librarytest&quot;." />
141 <subitem label="Right click &quot;librarytest&quot; and select &quot;New &gt; Other...&quot;." />
142 <subitem label="Expand &quot;Example EMF Model Creation Wizards&quot; and select &quot;Library Model&quot;. Then, click &quot;Next&quot;." />
143 <subitem label="Enter &quot;My.library&quot; as the file name, then click &quot;Next&quot;." />
144 <subitem label="Select &quot;Library&quot;; as the model object, then click &quot;Finish&quot;." />
145 <subitem label="The generated library editor is opened. Expand &quot;platform:/resource/librarytest/My.library&quot;. Right click &quot;Library&quot; and select &quot;New Child &gt; Writer&quot; 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 &quot;File > Save&quot; to save the instance." />
148 </item>
149 </cheatsheet>