Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » MoDisco » EMF editor for Java metamodel: is it possible?(Can't create EMF project using java metamodel)
EMF editor for Java metamodel: is it possible? [message #772740] Fri, 30 December 2011 08:27 Go to next message
Seref Arikan is currently offline Seref Arikan
Messages: 61
Registered: August 2010
Member
The Java Discoverer in MoDisco is simply fantastic. However, I am a little bit confused about how to use it.

It gives me an XMI file, which must be a serialization of a model that complies with Java Metamodel from MoDisco project. I've noticed that the generated discovery results can only be opened with reflective ecore model editor (besides MoDisco editor). This is Helios btw.

Being the lazy person I am, I try to generate a clean EMF project using java metamodel, but it fails because the model project can't export packages prefixed with java (generated as a result of java metamodel) Once model project can't export properly, neither edit nor editor plugins can work of course.

Am I missing something here? I'll be checking out the plugin source from MoDisco discovery results browser, but I suspect that the only way to use java metamodel (ecore) is through emf reflection. Is that correct?

Your help can save me a lot time (and some more black hair on my head...)

Re: EMF editor for Java metamodel: is it possible? [message #774101 is a reply to message #772740] Tue, 03 January 2012 04:11 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo Bruneliere
Messages: 588
Registered: July 2009
Senior Member
Hello,

Thanks for using the MoDisco Java discoverer and metamodel, your feedback is very appreciated.

However, what is your final objective when generating the base EMF Editor from the Java metamodel?
The MoDisco Model Browser along with its Java metamodel-specific customization offers much more navigation capabilities and is already provided for free: http://wiki.eclipse.org/MoDisco/Components/ModelBrowser/Documentation/0.9
Note that you can also integrate it directly in your own solutions, and customizing it accordingly if required.

Best regards,

Hugo


------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
------------------------------------------
Re: EMF editor for Java metamodel: is it possible? [message #774138 is a reply to message #772740] Tue, 03 January 2012 05:39 Go to previous messageGo to next message
Gregoire Dupe is currently offline Gregoire Dupe
Messages: 72
Registered: September 2009
Location: France
Member
Hello,

> the model project can't export packages prefixed with java

I'm not sure to understand. Does "export packages" refers to the "Export-Package" section of a MANIFEST.MF file ?

I've tried to generate the edit and editor plug-in for the Java meta-model and it looks to work properly (I've used the version 0.9 of MoDisco).

But the generated editor plug-in contains the following extension:
<extension point="org.eclipse.ui.editors">
<editor
id="org.eclipse.gmt.modisco.java.emf.presentation.JavaEditorID"
name="%_UI_JavaEditor_label"
icon="icons/full/obj16/JavaModelFile.gif"
extensions="java"
class="org.eclipse.gmt.modisco.java.emf.presentation.JavaEditor"
contributorClass="org.eclipse.gmt.modisco.java.emf.presentation.JavaActionBarContributor">
</editor>
</extension>

As you can see the editor is declared for .java files and the discoverer generates .javaxmi files. Is this mismatch the cause of your problem?

Regards,
Grégoire
Re: EMF editor for Java metamodel: is it possible? [message #774167 is a reply to message #774138] Tue, 03 January 2012 06:59 Go to previous messageGo to next message
Seref Arikan is currently offline Seref Arikan
Messages: 61
Registered: August 2010
Member
Hi Grégoire,
I've used version 0.8 of Modisco. What I've done is, I've taken only metamodel file from the source directory of Modisco, and tried to generate an EMF project with it. This led to Eclipse creating a gen file for the ecore file. When I tried to do "generate all" with this gen model, the resulting model project's Meta-Inf attempted to export package java, which is normal since the ecore model includes a model named java!

I've realized that the source directory also contains a gen file, next to ecore file, and when I used both in an empty EMF project, the problem went away. To be honest, I did not check out the difference between the gen file from the project source and the one generated by Eclipse (Helios), but I can repeat the experiment and give more detail if that helps.

Which brings me to my goal, and Hugo's question. I've not looked into Modisco browser project to avoid understanding code that I would not be using directly. What I want to do is to obtain an XMI output from the discoverer (very easy thanks to Modisco plugin), and execute some logic on the results. I thought that using the usual EMF practices (ecore -> model <and maybe edit>) would give me what I want. There may be some duality of functionality with Modisco browser code, but maybe I should see how much functionality I can use from Modisco plugins to do what I want.

I think this is a fantastic project, which is probably going to save me months in a very critical piece of work. So thanks in advance to all those who made it possible. Also, thanks for the responses Wink

Cheers
Seref
Re: EMF editor for Java metamodel: is it possible? [message #774632 is a reply to message #774167] Wed, 04 January 2012 05:10 Go to previous messageGo to next message
Gregoire Dupe is currently offline Gregoire Dupe
Messages: 72
Registered: September 2009
Location: France
Member
Hello,

> I've used version 0.8 of Modisco.

If you can, you should use the version 0.9 because 0.8 is not maintained since February 2011.

> What I've done is, I've taken only metamodel file from the source directory of MoDisco, and tried to generate an EMF project with it.

I'm not sure this is a good idea. To my mind, you (and other users) should use released binaries of meta-model plug-ins because they are known, tested and validated by the 'MoDisco' team. But you can use it to generate edit and editor plug-ins.

> When I tried to do "generate all" with this gen model, the resulting model project's Meta-Inf attempted to export package java, which is normal since the ecore model includes a model named java!

Ok, I didn't know that we get the following error if we try to add a packaged prefixed by "java" in the section 'Export-Package' of a MANIFEST.MF file: "Cannot export packages prefixed with 'java'"

> I've realized that the source directory also contains a gen file, next to ecore file, and when I used both in an empty EMF project, the problem went away. To be honest, I did not check out the difference between the gen file from the project source and the one generated by Eclipse (Helios), but I can repeat the experiment and give more detail if that helps.

To get generated classes in packages prefixed with the plug-in name, we changed the value of attribute 'basePackage'.

<genPackages prefix="Java" basePackage="org.eclipse.gmt.modisco" disposableProviderFactory="true"
      loadInitialization="true" metaDataPackageSuffix="emf" classPackageSuffix="emf.impl"
      utilityPackageSuffix="emf.util" providerPackageSuffix="emf.provider" presentationPackageSuffix="emf.presentation"
      testsPackageSuffix="emf.tests" literalsInterface="false" ecorePackage="java.ecore#/">


> What I want to do is to obtain an XMI output from the discoverer (very easy thanks to Modisco plugin),

Ok.

> and execute some logic on the results.

If your "logic on the result" are model transformations (written with Java, ATL, etc.) you should be able to run them without any additional plug-ins.

If you want to be able to use the EMF command framework, you will need to generate the edit plug-in.

If you want to manually edit the javaxmi model (with your mouse and your keyboard), you can:
- use the MoDisco browser (without to care of the source code) ;
- use the 'Sample Reflexive Ecore Model editor';
- use an EMF generated editor (you will then have to generate the edit and editor plug-ins).

> I thought that using the usual EMF practices (ecore -> model <and maybe edit>) would give me what I want.

This is quite true: we just did half of the work for you Smile We do not provide the edit and editor plug-ins when we think that they are not required. This avoid to have to download big plug-ins.

Regards,
Grégoire

Re: EMF editor for Java metamodel: is it possible? [message #774651 is a reply to message #774632] Wed, 04 January 2012 05:45 Go to previous message
Seref Arikan is currently offline Seref Arikan
Messages: 61
Registered: August 2010
Member
You've done a lot more than half of the work, be fair to your self Smile

I guess I'll move to 0.9, it is just that getting things stable with an Eclipse distribution is not a trivial task, so once you're settled and comfy with Helios, you begin to dislike the idea of Indigo. Modisco is a reason good enough to move though.

There are multiple options to do what I want to do, but as a matter of principle, I start with the most flexible method, and move to more abstract methods once I can identify patterns in what I'm doing. So EMF based coding will do initially, and if I think I can use ATL or Acceleo, that will definitely be the next step.

I think the other killer feature is Java source code generation from the meta model. Just the discoverer and source code generator, based on the meta model is worth of thousands of hours. Too bad I can't buy you guys a beer and thank your for this Smile
Previous Topic:Auto-Reverse Engineering
Next Topic:Article about MoDisco published in ERCIM News 88 - Special Theme: Evolving Software
Goto Forum:
  


Current Time: Fri Apr 18 16:47:59 EDT 2014

Powered by FUDForum. Page generated in 0.01646 seconds