<?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: &quot;library.java&quot;, &quot;library.java.edit&quot;, &quot;library.java.editor&quot;.
  	</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 &quot;library.java&quot; empty EMF project to house the annotated Java.
    </description>

    <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">
      <action
        pluginId="org.eclipse.emf.cheatsheets"
        class="org.eclipse.emf.cheatsheets.actions.OpenEmptyEMFProjectWizardAction"
        param1="library.java" />
    </subitem>

    <subitem label="Enter &quot;library.java&quot; as the &quot;Project name&quot;, then click &quot;Finish&quot;." 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 &quot;library.java&quot; project that describe the model.
      The model consists of three interfaces (&quot;Library&quot;, &quot;Writer&quot;, and &quot;Book&quot;) and
      a class (&quot;BookCategory&quot;), all in the &quot;org.eclipse.example.library&quot; 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" />
    </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" />
    </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" />
    </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" />
    </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 &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">
      <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"/>
    </subitem>
    <subitem label="Enter &quot;library.genmodel&quot; as the file name, then click &quot;Next&quot;." skip="false" />
    <subitem label="Select &quot;Annotated Java&quot;, then click &quot;Next&quot;." skip="false" />
    <subitem label="Select the &quot;org.eclipse.example.library&quot; package, then click &quot;Finish&quot;." 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 &quot;Library&quot; and select &quot;Generate ${this} Code&quot;." />
    </repeated-subitem>
    <subitem label="If automatic building has been disabled, select &quot;Project &gt; Build All&quot; 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 &quot;library.java&quot; project in the package explorer and invoke &quot;Source &gt; Organize Imports&quot; 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 &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." />
    <subitem label="In the runtime instance, create a new general project called &quot;librarytest&quot;." />
    <subitem label="Right click &quot;librarytest&quot; and select &quot;New &gt; Other...&quot;." />
    <subitem label="Expand &quot;Example EMF Model Creation Wizards&quot; and select &quot;Library Model&quot;. Then, click &quot;Next&quot;." />
    <subitem label="Enter &quot;My.library&quot; as the file name, then click &quot;Next&quot;." />
    <subitem label="Select &quot;Library&quot;; as the model object, then click &quot;Finish&quot;." />
    <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." />
    <subitem label="Create additional writers and books in the library, and edit the objects' properties in the properties view." />
    <subitem label="Select &quot;File > Save&quot; to save the instance." />
  </item>
</cheatsheet>
