Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Dynamic Browsing and Instantiation Capabilites in EMF"

 
(4 intermediate revisions by 2 users not shown)
Line 13: Line 13:
 
         The Ecore editor would open with the package as null.
 
         The Ecore editor would open with the package as null.
 
         Double Click on the package:null to update the Name and NsURI Property.
 
         Double Click on the package:null to update the Name and NsURI Property.
              NsURI should be assigned the resource path where the ecore is found.
 
 
               For e.g. /resource/<Plugin Name>/<Folder Name>/<Ecore Name>.ecore
 
               For e.g. /resource/<Plugin Name>/<Folder Name>/<Ecore Name>.ecore
 
</pre>
 
</pre>
 
Step 3. Update the Ecore to represent your model.<br>
 
Step 3. Update the Ecore to represent your model.<br>
Step 4. Once the ecore is updated, right click on the RootObject of your model that you would want to instantiate and select Create Dynamic Instance...<br>
+
Step 4. Once the ecore is updated, right click on the RootObject (EClass) of your model that you would want to instantiate and select Create Dynamic Instance...<br>
 
Step 5. Selecting this would open a Wizard for creating a Dynamic Instantiation of your created Model. Provide the <filename>.xmi wherein you would like to serialise your instantiated data.<br>
 
Step 5. Selecting this would open a Wizard for creating a Dynamic Instantiation of your created Model. Provide the <filename>.xmi wherein you would like to serialise your instantiated data.<br>
 
Step 6. This would open an instance of the Reflective Editor in Eclipse, loading the created <filename>.xmi that contains the instance of your model's rootObject.<br><br>
 
Step 6. This would open an instance of the Reflective Editor in Eclipse, loading the created <filename>.xmi that contains the instance of your model's rootObject.<br><br>
Line 27: Line 26:
 
       Looking more into detail would make it more evident that this .xmi file is
 
       Looking more into detail would make it more evident that this .xmi file is
 
       a dynamic instantiation of the EMF Model described by the .ecore file.
 
       a dynamic instantiation of the EMF Model described by the .ecore file.
 +
</pre>
 +
Make any ecore change and you would be able to instantiate and browse those changes in the Reflective Editor.
 +
<br><br>
 +
Note:: for every change in the ecore, you need to close and reopen the .xmi that was generated to see the changes.
  
      Make any ecore change and you would be able to instantiate and browse those
+
--[[User:Annamalai.chockalingam.gmail.com|Annamalai.chockalingam.gmail.com]] 12:17, 7 February 2007 (EST)
      changes in the Reflective Editor.
+
  
      Note:: for every change in the ecore, you need to close and reopen the .xmi
+
[[Category:EMF]]
      that was generated to see the changes.
+
</pre>
+

Latest revision as of 17:11, 5 May 2010

Introduction

EMF provides a reflective editor, which can view and edit any EMF model file, using only the model meta-data i.e. the ecore file. It provides similar function to the default generated editor, but it can't be easily customized.

In this short write up I have tried to pen down the steps involved for using this reflective editor which is quiet a hidden feature in EMF.


Using the Reflective Editor – an Example

Step 1. Create an Empty EMF Project.
Step 2. Create an Ecore using the Example EMF Model Creation Wizards > Ecore Model

        The Ecore editor would open with the package as null.
        Double Click on the package:null to update the Name and NsURI Property.
               For e.g. /resource/<Plugin Name>/<Folder Name>/<Ecore Name>.ecore

Step 3. Update the Ecore to represent your model.
Step 4. Once the ecore is updated, right click on the RootObject (EClass) of your model that you would want to instantiate and select Create Dynamic Instance...
Step 5. Selecting this would open a Wizard for creating a Dynamic Instantiation of your created Model. Provide the <filename>.xmi wherein you would like to serialise your instantiated data.
Step 6. This would open an instance of the Reflective Editor in Eclipse, loading the created <filename>.xmi that contains the instance of your model's rootObject.

       In the editor, you would find two root nodes 
               .xmi file and 
               .ecore file
       
       Looking more into detail would make it more evident that this .xmi file is
       a dynamic instantiation of the EMF Model described by the .ecore file.

Make any ecore change and you would be able to instantiate and browse those changes in the Reflective Editor.

Note:: for every change in the ecore, you need to close and reopen the .xmi that was generated to see the changes.

--Annamalai.chockalingam.gmail.com 12:17, 7 February 2007 (EST)

Back to the top