Debian Codegraph @

doc/org.eclipse.emf.doc/tutorials/clibmod/clibmod.html

raw
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
6 <link rel="stylesheet" href="images/../../../css/book.css" type="text/css"/>
7 <link rel="stylesheet" href="images/../../../css/emf-book.css" type="text/css"/>
8 <title>Generating an EMF Model</title>
9 </head>
10 <body lang="EN-US" xml:lang="EN-US">
11 <h1>Generating an EMF Model</h1>
12
13 <p>Last updated: June 18, 2007</p>
14
15 <p>This tutorial is a step-by-step description of the process of creating an EMF
16 model and generating a simple model editor for it. Following this tutorial will
17 show how easy EMF makes it to go from a simple model definition to a fully
18 functioning editor for that model.</p>
19
20 <p>The model we will generate looks like this in UML (see the
21 <a href="../../references/overview/EMF.html">Eclipse Modeling Framework
22 Overview</a> for a description of this model):</p>
23
24 <img src="images/model.gif" alt="Library UML model"/>
25
26 <p>We will show how an EMF model can be generated from either of two different
27 sources: a Rational Rose model or a set of annotated Java interfaces and
28 classes.</p>
29
30 <p>The screenshots are based on version 3.3.0 RC4 of the Eclipse SDK and version 2.3.0 RC3
31 of EMF.</p>
32
33 <hr/>
34 <h2>Contents</h2>
35
36 <table border="0" cellspacing="2" cellpadding="2" width="100%">
37 <tr>
38 <td valign="top" width="60">Step 0:</td>
39 <td valign="top"><a href="#step0">Prerequisites</a></td>
40 </tr>
41
42 <tr>
43 <td valign="top">Step 1:</td>
44 <td valign="top"><a href="#step1a">Import the Model from Rose</a> or
45 <a href="#step1b">Define the Model Using Annotated Java</a>
46 </td>
47 </tr>
48
49 <tr>
50 <td valign="top">Step 2:</td>
51 <td valign="top"><a href="#step2">Generate the EMF Model Code</a>
52 </td>
53 </tr>
54
55 <tr>
56 <td valign="top">Step 3:</td>
57 <td valign="top"><a href="#step3">Generate an Editor for the
58 Model</a> </td>
59 </tr>
60
61 <tr>
62 <td valign="top">Step 4:</td>
63 <td valign="top"><a href="#step4">Run the Generated Editor</a>
64 </td>
65 </tr>
66 </table>
67 <br/>
68
69 <hr/>
70 <p style="text-align: right"><a id="step0" name="step0">&nbsp;</a><a href="#top">contents</a></p>
71 <h2>Step 0: Prerequisites</h2>
72
73 <p>The EMF Runtime package includes the EMF generator and a number of related
74 plug-ins. After installing the package, verify that they are available in your
75 Eclipse environment:</p>
76
77 <ul>
78 <li>Bring up the "Help/About Eclipse Platform" dialog.<br/>
79 <br /><img src="images/img001.gif" alt="Help/About Eclipse Platform"/><br/>
80 &nbsp;</li>
81
82 <li>Click on "Plug-in Details".<br/>
83 <br /><img src="images/img002.gif" alt="Plug-in Details"/><br/>
84 &nbsp;</li>
85
86 <li>Click the "Plug-in Id" column heading to order the plug-ins by that field.
87 Then, check that the highlighted set of plug-ins are present.<br/>
88 <br /><img src="images/img003.gif" alt="Required EMF plug-ins: org.eclipse.emf, org.eclipse.emf.codegen, org.eclipse.emf.codegen.ecore, org.eclipse.emf.codegen.ecore.ui, org.eclipse.emf.codegen.ui, org.eclipse.emf.common, org.eclipse.emf.common.ui, org.eclipse.emf.converter, org.eclipse.emf.ecore, org.eclipse.emf.ecore.edit, org.eclipse.emf.ecore.editor, org.eclipse.emf.ecore.xmi, org.eclipse.emf.edit, org.eclipse.emf.edit.ui, org.eclipse.emf.importer, org.eclipse.emf.importer.java, org.eclipse.emf.importer.rose"/><br/>
89 &nbsp;</li>
90 </ul>
91
92 <p>Additional EMF plug-ins are not required for this tutorial. They may or may
93 not appear, depending on which EMF packages you installed.</p>
94
95 <hr/>
96 <p style="text-align: right"><a id="step1a" name="step1a">&nbsp;</a><a href="#top">contents</a></p>
97 <h2>Step 1a: Import the Model from Rose</h2>
98
99 <p>The Rose file for the library model can be found here:
100 <a target="_code" href="images/../library.mdl">library.mdl</a>. Save it
101 somewhere on your workstation.</p>
102
103 <p>Create a new EMF project in the workspace:</p>
104
105 <ul>
106 <li>Bring up the "File/New/Project..." dialog.<br/>
107 <br /><img src="images/img101.gif" alt="File/New/Project..."/><br/>
108 &nbsp;</li>
109
110 <li>Expand "Eclipse Modeling Framework" and select "EMF Project". Click the
111 "Next" button.<br/>
112 <br /><img src="images/img102.gif" alt="EMF Project"/><br/>
113 &nbsp;</li>
114
115 <li>Give the project a name, say, "library". Then, click the "Next" button.<br/>
116 <br /><img src="images/img103.gif" alt="Name the project"/><br/>
117 &nbsp;</li>
118
119 <li>Select "Rose class model" and click the "Next" button.<br/>
120 <br /><img src="images/img104.gif" alt="Rose class model"/><br/>
121 &nbsp;</li>
122
123 <li>Click on the "Browse File System..." or "Browse Workspace..." button and locate the Rose model file.<br/>
124 <br /><img src="images/img105.gif" alt="Browse for Rose file"/><br/>
125 &nbsp;</li>
126
127 <li>The Rose model file will be examined, and a default generator model name
128 will be suggested. You can change the name in the entry box if you wish. Then,
129 click the "Next" button.<br/>
130 <br /><img src="images/img106.gif" alt="Generator model name"/><br/>
131 &nbsp;</li>
132
133 <li>In general, a Rose model may contain more than one package. Select the
134 package for which you want to generate an EMF model -- in this case, the only
135 package, "org.eclipse.example.library". Click the "Finish" button.<br/>
136 <br /><img src="images/img107.gif" alt="Select package"/><br/>
137 &nbsp;</li>
138
139 <li>An Ecore model (library.ecore) and a generator model (library.genmodel) will
140 be created. The latter, which controls code generation for the model, is opened
141 in the main view.<br/>
142 <br /><img src="images/img108.gif" alt="Opened generator"/><br/>
143 &nbsp;</li>
144 </ul>
145
146 <hr/>
147 <p style="text-align: right">&nbsp;<a href="#top">contents</a></p>
148 <h2><a id="step1b" name="step1b">Step 1b: Define the Model Using Annotated Java</a></h2>
149
150 <p>Instead of importing the model from a Rose diagram, we can start with a set
151 of Java interfaces and classes that correspond to the classes and enumerated
152 types, respectively, in the library model. This code is the bare minimum
153 required to illustrate the desired features. Based on it, an Ecore model and a
154 generator model will be constructed, which will then drive generation of the
155 remaining code. The code is annotated with "@model" tags in Javadoc comments,
156 in order to specify any non-default values for the attributes and references of
157 the Ecore objects.</p>
158
159 <p>Starting in EMF 2.3, you can define your annotated Java interfaces with
160 Java 5.0 Generics and Enumerations. We will show both approaches when appropriate. In order
161 to use Java 5.0, make sure Eclipse's &quot;Java/Compiler/Compiler Compliance Level&quot; value
162 is set to &quot;5.0&quot; or higher.</p>
163 <br /><img src="images/img100.gif" alt="Java/Compiler/Compiler Compliance Level"/><br/>
164
165 <p><br />Here are the interfaces that describe the library model:</p>
166
167 <blockquote>
168 <table><tr>
169 <td width="45%"><strong><a name="librarysrc" target="_code" href="images/../Library.java">Library.java</a></strong> (Java 1.4)<br/>
170 <table width="100%" border="1" frame="box"><tr><td>
171 <pre>package org.eclipse.example.library;
172 import java.util.List;
173
174 /**
175 * @model
176 */
177 public interface Library
178 {
179 /**
180 * @model
181 */
182 String getName();
183
184 /**
185 * @model type="Writer" containment="true"
186 */
187 List getWriters();
188
189 /**
190 * @model type="Book" containment="true"
191 */
192 List getBooks();
193 }</pre>
194 </td></tr></table></td>
195 <td width="10%"></td>
196 <td width="45%"><strong><a target="_code" href="images/../java5/Library.java">Library.java</a></strong> (Java 5.0)<br/>
197 <table width="100%" border="1" frame="box"><tr><td>
198 <pre>package org.eclipse.example.library;
199 import java.util.List;
200
201 /**
202 * @model
203 */
204 public interface Library
205 {
206 /**
207 * @model
208 */
209 String getName();
210
211 /**
212 * @model containment="true"
213 */
214 List&lt;Writer&gt; getWriters();
215
216 /**
217 * @model containment="true"
218 */
219 List&lt;Book&gt; getBooks();
220 }</pre>
221 </td></tr></table></td>
222 </tr>
223 <tr><td colspan="3">&nbsp;</td></tr>
224 <tr>
225 <td width="45%"><strong><a name="booksrc" target="_code" href="images/../Book.java">Book.java</a></strong><br/>
226 <table width="100%" border="1" frame="box"><tr><td>
227 <pre>package org.eclipse.example.library;
228
229 /**
230 * @model
231 */
232 public interface Book
233 {
234 /**
235 * @model
236 */
237 String getTitle();
238
239 /**
240 * @model default="100"
241 */
242 int getPages();
243
244 /**
245 * @model
246 */
247 BookCategory getCategory();
248
249 /**
250 * @model opposite="books"
251 */
252 Writer getAuthor();
253 }</pre>
254 </td></tr></table>
255 </td>
256 <td colspan="2"/>
257 </tr>
258 <tr><td colspan="3">&nbsp;</td></tr>
259 <tr>
260 <td width="45%"><strong><a name="writersrc" target="_code" href="images/../Writer.java">Writer.java</a></strong> (Java 1.4)<br/>
261 <table width="100%" border="1" frame="box"><tr><td>
262 <pre>package org.eclipse.example.library;
263
264 /**
265 * @model
266 */
267 public interface Writer
268 {
269 /**
270 * @model
271 */
272 String getName();
273
274 /**
275 * @model type="Book" opposite="author"
276 */
277 java.util.List getBooks();
278 }</pre>
279 </td></tr></table></td>
280 <td width="10%"></td>
281 <td width="45%"><strong><a target="_code" href="images/../java5/Writer.java">Writer.java</a></strong> (Java 5.0)<br/>
282 <table width="100%" border="1" frame="box"><tr><td>
283 <pre>package org.eclipse.example.library;
284
285 /**
286 * @model
287 */
288 public interface Writer
289 {
290 /**
291 * @model
292 */
293 String getName();
294
295 /**
296 * @model opposite="author"
297 */
298 java.util.List&lt;Book&gt; getBooks();
299 }</pre>
300 </td></tr></table></td>
301 </tr>
302 <tr><td colspan="3">&nbsp;</td></tr>
303 <tr>
304 <td width="45%"><strong><a name="bookcategorysrc" target="_code" href="images/../BookCategory.java">BookCategory.java</a></strong> (Java 1.4)<br/>
305 <table width="100%" border="1" frame="box"><tr><td>
306 <pre>package org.eclipse.example.library;
307
308 /**
309 * @model
310 */
311 public class BookCategory
312 {
313 /**
314 * @model name="Mystery"
315 */
316 public static final int MYSTERY = 0;
317
318 /**
319 * @model name="ScienceFiction"
320 */
321 public static final int SCIENCE_FICTION = 1;
322
323 /**
324 * @model name="Biography"
325 */
326 public static final int BIOGRAPHY = 2;
327 }</pre>
328 </td></tr></table></td>
329 <td width="10%"></td>
330 <td width="45%"><strong><a target="_code" href="images/../java5/BookCategory.java">BookCategory.java</a></strong> (Java 5.0)<br/>
331 <table width="100%" border="1" frame="box"><tr><td>
332 <pre>package org.eclipse.example.library;
333
334 /**
335 * @model
336 */
337 public enum BookCategory
338 {
339 /**
340 * @model name="Mystery"
341 */
342 MYSTERY,
343
344 /**
345 * @model name="ScienceFiction"
346 */
347 SCIENCE_FICTION,
348
349 /**
350 * @model name="Biography"
351 */
352 BIOGRAPHY;
353 }</pre>
354 </td></tr></table></td>
355 </tr></table>
356 </blockquote>
357
358 <p><a id="step1b_newEmptyEMFProj" name="step1b_newEmptyEMFProj">Create a new empty EMF project in the workspace:</a></p>
359
360 <ul>
361 <li>Bring up the "File/New/Project..." dialog.<br/>
362 <br /><img src="images/img101.gif" alt="File/New/Project..."/><br/>
363 &nbsp;</li>
364
365 <li>Expand "Eclipse Modeling Framework" and select "Empty EMF Project". Click
366 the "Next" button.<br/>
367 <br /><img src="images/img121.gif" alt="Empty EMF Project"/><br/>
368 &nbsp;</li>
369
370 <li>Give the project a name, say, "library", and click the "Finish" button.<br/>
371 <br /><img src="images/img122.gif" alt="Name the project"/><br/>
372 &nbsp;</li>
373
374 <li>The newly created project can be seen in the Package Explorer.<br/>
375 <br /><img src="images/img124.gif" alt="Library project"/><br/>
376 &nbsp;</li>
377 </ul>
378
379 <p><a id="step1b_newJavaInterface" name="step1b_newJavaInterface">Create the first Java interface:</a></p>
380
381 <ul>
382 <li>Right-click the "src" folder and select "New/Interface" from the pop-up
383 menu.<br/>
384 <br /><img src="images/img125.gif" alt="New/Interface"/><br/>
385 &nbsp;</li>
386
387 <li>Fill in the package and interface name. Click the "Finish" button.<br/>
388 <br /><img src="images/img126.gif" alt="Create new interface"/><br/>
389 &nbsp;</li>
390
391 <li>A new Java interface file is created and opened in the main view.<br/>
392 <br /><img src="images/img127.gif" alt="Opened interface"/><br/>
393 &nbsp;</li>
394
395 <li>Type (or paste) in the <a href="#librarysrc">Library.java</a> interface
396 code, as shown above. Pay special attention to the @model tags.<br/>
397 <br /><img src="images/img128.gif" alt="Enter interface code"/><br/>
398 &nbsp;</li>
399
400 <li>Select "Save" from the "File" menu to save the file.<br/>
401 <br /><img src="images/img129.gif" alt="File/Save"/><br/>
402 &nbsp;</li>
403 </ul>
404
405 <p>Create the other two interfaces (<a href="#booksrc">Book.java</a> and
406 <a href="#writersrc">Writer.java</a>) and the class
407 (<a href="#bookcategorysrc">BookCategory.java</a>) in the same way. Of course,
408 to create the class, select "New/Class" from the pop-up menu, instead of
409 "New/Interface".</p>
410
411 <p><a id="step1b_newEMFModJava" name="step1b_newEMFModJava">Create the EMF model:</a></p>
412
413 <ul>
414 <li>In the Package Explorer view, right-click the "model" folder and select
415 "New/Other..." from the pop-up menu.<br/>
416 <br /><img src="images/img130.gif" alt="New/Other..."/><br/>
417 &nbsp;</li>
418
419 <li>Expand "Eclipse Modeling Framework" and select "EMF Model". Click the
420 "Next" button.<br/>
421 <br /><img src="images/img131.gif" alt="EMF Model"/><br/>
422 &nbsp;</li>
423
424 <li>Change the file name to "library.genmodel" and click the "Next" button.<br/>
425 <br /><img src="images/img133.gif" alt="Change the file name"/><br/>
426 &nbsp;</li>
427
428 <li>Select "Annotated Java" and click the "Next" button.<br/>
429 <br /><img src="images/img134.gif" alt="Annotated Java"/><br/>
430 &nbsp;</li>
431
432 <li>Select the "org.eclipse.example.library" package and click the "Finish" button.<br/>
433 <br /><img src="images/img135.gif" alt="Select package"/><br/>
434 &nbsp;</li>
435
436 <li>An Ecore model (library.ecore) and a generator model (library.genmodel) will
437 be created. The latter, which controls code generation for the model, is opened
438 in the main view.<br/>
439 <br /><img src="images/img136.gif" alt="Opened generator"/><br/>
440 &nbsp;</li>
441 </ul>
442
443 <hr/>
444 <p style="text-align: right"><a id="step2" name="step2">&nbsp;</a><a href="#top">contents</a></p>
445 <h2>Step 2: Generate the EMF Model Code</h2>
446
447 <p>The generator model shows a root object, representing the whole model. This
448 model object has children that represent its packages, whose children then
449 represent classifiers (classes and datatypes, including enumerated types). The
450 children of classes are class attributes, references, and operations; the
451 children of enumerated types are enum literals.</p>
452
453 <ul>
454 <li>The model can be expanded to see its various elements.<br/>
455 <br /><img src="images/img201.gif" alt="Expanded generator model"/><br/>
456 &nbsp;</li>
457
458 <li>There are properties associated with each object. If the Properties view
459 isn't already showing, right-click the "Library" model object and select "Show
460 Properties View" from the pop-up menu, or simply double-click the "Library"
461 object.<br/>
462 <br /><img src="images/img202.gif" alt="Show Properties View"/><br/>
463 &nbsp;</li>
464
465 <li>These properties control the behavior of the code generator.<br/>
466 <br /><img src="images/img203.gif" alt="Generator model properties"/><br/>
467 &nbsp;</li>
468 </ul>
469
470 <a name="genmodelComplianceLevel"/>
471 <p>In most cases, the properites need not be changed from their default values,
472 but these options can provide a great deal of control over the code that gets
473 generated. One option worth pointing out is the second one in the image above,
474 "Compliance Level". If you chose to exploit the new constructs introduced by Java 5.0
475 in annotated Java interfaces, or you wish to generate code that makes use of generics, ensure this
476 option is set to "5.0" or higher. Its initial value is based on the compiler compliance level property,
477 which was illustrated above in Step 0.</p>
478
479 <p>The generator model is also the place where you initiate the code generation.
480 By right-clicking on an object in the model, you can generate code for it.</p>
481
482 <ul>
483 <li>Right-click the "Library" model object and select "Generate Model Code" from
484 the pop-up menu.<br/>
485 <br /><img src="images/img204.gif" alt="Generate Model Code"/><br/>
486 &nbsp;</li>
487
488 <li>Observe the generated files.<br/>
489 <br /><img src="images/img205.gif" alt="Generated files"/><br/>
490 </li>
491 </ul>
492
493 <p>After generation, the class interfaces and enum class will have been created
494 (if the model was imported from Rose) or completed (if the model was defined
495 using annotated Java), and a new pair of interfaces will have been created for
496 the package itself and for the factory. There will also be two new packages,
497 with "impl" and "util" suffixes, which contain implementations of the interfaces
498 and additional utility classes, and both types of manifest files for the model
499 plug-in: "plugin.xml" and "MANIFEST.MF".</p>
500
501 <p>If you defined the model by using annotated Java, you may see a warning in
502 the Problems view: "The import java.util.List is never used". This warning is
503 expected, and will not stop you from continuing on to the next step.</p>
504
505 <p>If you change the model, you can regenerate it, and changes will be merged
506 with any hand modifications that may have been made to the code. You can also
507 selectively generate a subset of the model code by right-clicking on a package,
508 class, or enum object and selecting "Generate Model Code" from the pop-up
509 menu.</p>
510
511 <hr/>
512 <p style="text-align: right"><a id="step3" name="step3">&nbsp;</a><a href="#top">contents</a></p>
513 <h2>Step 3: Generate an Editor for the Model</h2>
514
515 <p>A fully functional Eclipse editor can also be generated for any model. By
516 default, it is split between two plug-ins: an "edit" plug-in includes adapters
517 that provide a structured view and perform command-based editing of the model
518 objects; an "editor" plug-in provides the UI for the editor and wizard.</p>
519
520 <ul>
521 <li>In the generator, right-click the "Library" model object and select
522 "Generate Edit Code" from the pop-up menu.<br/>
523 <br /><img src="images/img301.gif" alt="Generate Edit Code"/><br/>
524 &nbsp;</li>
525
526 <li>Right-click the model object again and select "Generate Editor Code" from
527 the pop-up menu.<br/>
528 <br /><img src="images/img302.gif" alt="Generate Editor Code"/><br/>
529 &nbsp;</li>
530
531 <li>Observe the generated projects in the Package Explorer view, with "edit" and
532 "editor" suffixes.<br/>
533 <br /><img src="images/img303.gif" alt="Edit and editor projects"/><br/>
534 &nbsp;</li>
535 </ul>
536
537 <p>In general, if you wish to generate the model, edit, and editor plug-ins in a
538 single step, you can do so by selecting "Generate All" from the pop-up menu. </p>
539
540 <p>This will also create a tests plug-in, containing JUnit test skeletons for exercising any volatile features and operations defined in the model. This model doesn't include any, but In general, you'll need to fill in the bodies of these tests, yourself. The tests plug-in also includes a simple example class, which shows how to load and validate a model in a stand-alone application.</p>
541
542 <p>The code should be compiled automatically as it is generated, and should
543 recompile whenever it is changed. If you have disabled automatic building in the
544 workbench preferences, you can initiate compilation manually:</p>
545
546 <ul>
547 <li>Select "Build All" from the "Project" menu.<br/>
548 <br /><img src="images/img304.gif" alt="Project/Build All"/><br/>
549 &nbsp;</li>
550
551 <li>Observe the Problems view. If you imported the model from Rose, there should
552 be no errors in the library, library.edit, and library.editor projects.<br/>
553 <br /><img src="images/img305.gif" alt="No errors"/><br/>
554 &nbsp;</li>
555
556 <li>If you defined the model using annotated Java, there will be one warning in
557 the library project.<br/>
558 <br /><img src="images/img306.gif" alt="One warning: The import java.util.List is never used"/><br/>
559 &nbsp;</li>
560
561 <li>Double click the warning to see the line of code that is causing it. It
562 occurs because the code generator changed the return type of Library's two
563 multiplicity-many references from "List" to "EList", but did not remove the
564 unused import. You can simply delete it, or have Eclipse do it for you, by
565 selecting "Organize Imports" from the "Source" menu.<br/>
566 <br /><img src="images/img307.gif" alt="Source/Organize Imports"/><br/>
567 &nbsp;</li>
568 </ul>
569
570 <hr/>
571 <p style="text-align: right"><a id="step4" name="step4">&nbsp;</a><a href="#top">contents</a></p>
572 <h2>Step 4: Run the Generated Editor</h2>
573
574 <p>In order to test the new plug-ins, a second instance of Eclipse must be
575 launched. The plug-ins will run in this workbench.</p>
576
577 <ul>
578 <li>Select one of the projects and then choose "Run As/Eclipse Application"
579 from the "Run" menu or toolbar drop-down.<br/>
580 <br /><img src="images/img401.gif" alt="Run/Run As/Eclipse Application"/><br/>
581 &nbsp;</li>
582
583 <li>Wait for a second instance of the Eclipse platform to come up. Bring up the
584 "Help/About Eclipse Platform" dialog, click on the "Plug-in Details" button, and
585 verify that the generated plug-ins are there.<br/>
586 <br /><img src="images/img402.gif" alt="Generated plug-ins: library.editor, library.edit, library"/><br/>
587 &nbsp;</li>
588 </ul>
589
590 <p>The Library Model wizard can now be used to create a new instance of the
591 model.</p>
592
593 <ul>
594 <li>Bring up the "File/New/Project..." dialog.<br/>
595 <br /><img src="images/img101.gif" alt="File/New/Project..."/><br/>
596 &nbsp;</li>
597
598 <li>Expand "General" and select "Project". Click the "Next" button.<br/>
599 <br /><img src="images/img403.gif" alt="General Project"/><br/>
600 &nbsp;</li>
601
602 <li>Give the project a name and click the "Finish" button.<br/>
603 <br /><img src="images/img404.gif" alt="Name the project"/><br/>
604 &nbsp;</li>
605
606 <li>Right-click the project and select "New/Other..." from the pop-up menu.<br/>
607 <br /><img src="images/img405.gif" alt="New/Other..."/><br/>
608 &nbsp;</li>
609
610 <li>Expand "Example EMF Model Creation Wizards" and select "Library Model".
611 Click the "Next" button.<br/>
612 <br /><img src="images/img406.gif" alt="Library Model"/><br/>
613 &nbsp;</li>
614
615 <li>Enter a file name for the library model. Make sure it ends with
616 a ".library" extension. Then, click the "Next" button.<br/>
617 <br /><img src="images/img407.gif" alt="Name the library model file"/><br/>
618 &nbsp;</li>
619
620 <li>Select "Library" as the model object and click the "Finish" button.<br/>
621 <br /><img src="images/img408.gif" alt="Select the model object"/><br/>
622 &nbsp;</li>
623
624 <li>The newly created library model is opened in the main view.<br/>
625 <br /><img src="images/img409.gif" alt="New library model"/><br/>
626 &nbsp;</li>
627 </ul>
628
629 <p>The root object in this editor corresponds to the My.library resource. Under
630 it lies a single library, the object which was selected as the model object in
631 the wizard.</p>
632
633 <ul>
634 <li>Expand the "platform:/resource/librarytest/My.library" resource to see the
635 "Library" object. Select it.<br/>
636 <br /><img src="images/img410.gif" alt="Expanded resource"/><br/>
637 &nbsp;</li>
638
639 <li>If the Properties view isn't already showing, right-click the "Library"
640 object and select "Show Properties View" from the pop-up menu.<br/>
641 <br /><img src="images/img411.gif" alt="Show Properties View"/><br/>
642 &nbsp;</li>
643
644 <li>In the Properties view, click on the "Value" column of the "Name" property,
645 and give a name to the library. The label in the main view will be updated when
646 you hit Enter.<br/>
647 <br /><img src="images/img412.gif" alt="Name the library"/><br/>
648 &nbsp;</li>
649
650 <li>Right-click the library and select "New Child/Writer" from the pop-up menu.
651 A new writer is added to the library.<br/>
652 <br /><img src="images/img413.gif" alt="New Child/Writer"/><br/>
653 &nbsp;</li>
654
655 <li>Enter the name of the writer in the Properties view.<br/>
656 <br /><img src="images/img414.gif" alt="Name the writer"/><br/>
657 &nbsp;</li>
658
659 <li>Similarly, a book can be added to the library.<br/>
660 <br /><img src="images/img415.gif" alt="New Child/Book"/><br/>
661 &nbsp;</li>
662
663 <li>All the book's attributes and references can edited in the Properties
664 view.<br/>
665 <br /><img src="images/img416.gif" alt="Book properties"/><br/>
666 &nbsp;</li>
667
668 <li>You can save, close, and then re-open the model using the text editor if you
669 wish to see the saved model in XMI format.<br/>
670 <br /><img src="images/img417.gif" alt="Open With/Text Editor"/><br/>
671 &nbsp;</li>
672 </ul>
673
674 <hr/>
675 <p style="text-align: right"><a href="#top">contents</a></p>
676 </body>
677 </html>
678