Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » How to create plugin to execute egl files
How to create plugin to execute egl files [message #1063122] Wed, 12 June 2013 07:59 Go to next message
Patricia Fernández is currently offline Patricia Fernández
Messages: 41
Registered: October 2012
Member
Hi,

I'm such a newbie in this environment, so if my question it's silly I'm sorry.

I created a buttom and a menu in the Eclipse's toolbar to apply the transformation from uml to C#. What I need is to create a... maybe a wizard? a plugin?... where I can show a window and let the user choose the source file (which is going to be the .uml model to transformate) and then apply the EGL templates I created to generate the C# code project.

The transformation from UML-code is already done and tested with a launch file. Also, I created few java tools (for exceptions, warnings, to choose between different models in the same file...) and wonder if those are compatible with what I need to create?

How can I do that? Could anyone help me where to start? I'm a bit lost.

Thanks in advance.
Re: How to create plugin to execute egl files [message #1063146 is a reply to message #1063122] Wed, 12 June 2013 09:30 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris Kolovos
Messages: 836
Registered: July 2009
Senior Member
Hi Patricia,

The com.googlecode.pongo.ui and com.googlecode.pongo projects under [1] should provide a fairly complete example of how to launch an EGL transformation through a context menu. If you're using tools contributed through the Epsilon extension point, you should also add the following line of code:

module.getContext().getNativeTypeDelegates().add(new ExtensionPointToolNativeTypeDelegate());

Cheers,
Dimitris

[1] https://code.google.com/p/pongo/source/browse/#svn%2Ftrunk
Re: How to create plugin to execute egl files [message #1063147 is a reply to message #1063122] Wed, 12 June 2013 09:33 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-Dominguez
Messages: 304
Registered: January 2010
Senior Member
If I have understood it correctly, you have the Java code required to run the transformation, and you'd like to invoke it from a wizard where the user can select a model, right?

I think you might get better help from the PDE forum, but in any case, here is a tutorial that might help you on creating a plugin with a wizard:

http://www.vogella.com/articles/EclipseWizards/article.html

You could use the last step to set up a new IProject and run the transformation there. You should only have to define a dependency from the wizard plugin to the transformation plugin.

Creating a project programmatically is not hard. You could do something like in this createProject(...) method:

http://goo.gl/qSHGp
Re: How to create plugin to execute egl files [message #1063152 is a reply to message #1063147] Wed, 12 June 2013 09:42 Go to previous messageGo to next message
Patricia Fernández is currently offline Patricia Fernández
Messages: 41
Registered: October 2012
Member
Thank you Dimistris, I will try that and see if it works as I need to.

Antonio Garcia-Dominguez wrote on Wed, 12 June 2013 09:33
If I have understood it correctly, you have the Java code required to run the transformation, and you'd like to invoke it from a wizard where the user can select a model, right?


Hi Antonio,

I currently have the EGL/EOL files, uml file, java tools (as a jar in the dropins folder) and the launch configuration file to run the egl templates.

Then, what I need to do first is create the java code to run the transformation and then create a wizard which uses said java code, am I right?

Thank you both for the help.
Re: How to create plugin to execute egl files [message #1063156 is a reply to message #1063152] Wed, 12 June 2013 09:53 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-Dominguez
Messages: 304
Registered: January 2010
Senior Member
Hi Patricia,

Yes, that's right. You should look at Dimitris' example for wrapping your transformation into a Java class, and then use the Vogella tutorial to provide a wizard for it.

No problem,
Antonio
Re: How to create plugin to execute egl files [message #1063534 is a reply to message #1063146] Thu, 13 June 2013 07:44 Go to previous messageGo to next message
Patricia Fernández is currently offline Patricia Fernández
Messages: 41
Registered: October 2012
Member
Dimitris Kolovos wrote on Wed, 12 June 2013 09:30
Hi Patricia,

The com.googlecode.pongo.ui and com.googlecode.pongo projects under [1] should provide a fairly complete example of how to launch an EGL transformation through a context menu.
[1] https://code.google.com/p/pongo/source/browse/#svn%2Ftrunk


Hi Dimistris,

I've just ckecked that example, but it's done with .ecore and .emf model files, and mine's an .uml one. How am I supposed to adapt it to my case? I can't find any documentation, just the code you provided.

Also... how does pongo.egx file works? Should I need to add a similar one to my project?


Sorry for all the questions and thanks for your time.
Re: How to create plugin to execute egl files [message #1063542 is a reply to message #1063534] Thu, 13 June 2013 07:53 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris Kolovos
Messages: 836
Registered: July 2009
Senior Member
Hi Patricia,

EGX is a coordination language for EGL templates (see http://eclipse.org/epsilon/examples/index.php?example=org.eclipse.epsilon.examples.egl.library for an additional example).

To use a UML model instead of an Ecore model, in line 41 of PongoGenerator you'd need to instantiate a UmlModel [1] instead of an EmfModel, and replace model.setMetamodelUri(EcorePackage.eINSTANCE.getNsURI()); with model.setMetamodelUri(UMLPackage.eINSTANCE.getNsURI()); a couple of lines below.

Cheers,
Dimitris

[1] To use UmlModel you need to add org.eclipse.epsilon.emc.uml to the dependencies of your plugin
Re: How to create plugin to execute egl files [message #1063564 is a reply to message #1063542] Thu, 13 June 2013 08:21 Go to previous messageGo to next message
Patricia Fernández is currently offline Patricia Fernández
Messages: 41
Registered: October 2012
Member
Thanks, it seems that there is one line that isn't working (Package.Registry.INSTANCE.put(UMLPackage.eNsURI, UMLPackage.eINSTANCE);).

import org.eclipse.uml2.uml.Package; 
import org.eclipse.uml2.uml.UMLPackage;
...

if (inputFile.getName().endsWith(".uml")) {
                UmlModel model = new UmlModel();
                model.setName("UMLModel");
                Package.Registry.INSTANCE.put(UMLPackage.eNsURI, UMLPackage.eINSTANCE);
                model.setMetamodelUri(UMLPackage.eNsURI);
                model.setModelFile(inputFile.getAbsolutePath());
                model.load();
	        generate(model, inputFile.getParentFile());
	        model.disposeModel(); 
} 


And also here (module.parse(CodeGenerator.class.getResource("CodeGenerator.egx").toURI());
module.getContext().getModelRepository().addModel((IModel) model)
)

protected void generate(UmlModel model, File directory) throws Exception {
                ...
          module.parse(CodeGenerator.class.getResource("CodeGenerator.egx").toURI());
                module.getContext().getModelRepository().addModel((IModel) model);
                
                if (generatePluginXml) {


Also, does .egx file mean that all the generate commands I have in my code need to be re-done in some way?

For example, I got the following simplified bunch of lines in one of my templates:

var t := TemplateFactory.load('One.egl'); 
t.generate (secondleveldirectory+'\\'+modelProject.name+'.java');


Do I need to add the template 'Example.egl' which contains those lines, to the .egx file?

[Updated on: Thu, 13 June 2013 08:59]

Report message to a moderator

Re: How to create plugin to execute egl files [message #1063732 is a reply to message #1063564] Thu, 13 June 2013 18:28 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris Kolovos
Messages: 836
Registered: July 2009
Senior Member
Hi Patricia,

I'm afraid that "isn't working" is too vague for me to be able to provide any useful advice. Could you please elaborate more?

Regarding EGX, if you already have your coordination logic expressed in EGL you can ignore EGX and run your root EGL template as demonstrated in [1].

Cheers,
Dimitris

[1] http://eclipse.org/epsilon/examples/index.php?example=org.eclipse.epsilon.examples.standalone
Re: How to create plugin to execute egl files [message #1063786 is a reply to message #1063732] Fri, 14 June 2013 05:04 Go to previous messageGo to next message
Patricia Fernández is currently offline Patricia Fernández
Messages: 41
Registered: October 2012
Member
Package.Registry.INSTANCE.put(UMLPackage.eNsURI, UMLPackage.eINSTANCE);

Quote:
Registry cannot be solved or is not a field




module.parse(CodeGenerator.class.getResource("CodeGenerator.egx").toURI());
module.getContext().getModelRepository().addModel((IModel) model)


Quote:
The type org.eclipse.epsilon.erl.ErlModule cannot be resolved. It is indirecty referenced from required .class files

[Updated on: Fri, 14 June 2013 05:05]

Report message to a moderator

Re: How to create plugin to execute egl files [message #1063787 is a reply to message #1063786] Fri, 14 June 2013 05:08 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris Kolovos
Messages: 836
Registered: July 2009
Senior Member
Hi Patricia,

I believe that Package.Registry should read EPackage.Registry instead. Regarding the 2nd error, please add org.eclipse.epsilon.erl.engine to the dependencies of your plugin.

Cheers,
Dimitris
Re: How to create plugin to execute egl files [message #1257632 is a reply to message #1063787] Wed, 26 February 2014 11:47 Go to previous messageGo to next message
Dana Dg is currently offline Dana Dg
Messages: 3
Registered: February 2014
Junior Member
Hi
I have added the dependency epsilon.erl.engine but I still have the problem: "The type org.eclipse.epsilon.erl.ErlModule cannot be resolved....".

Thanks,

Dna
Re: How to create plugin to execute egl files [message #1257716 is a reply to message #1257632] Wed, 26 February 2014 13:21 Go to previous message
Dimitris Kolovos is currently offline Dimitris Kolovos
Messages: 836
Registered: July 2009
Senior Member
Hi Dana,

You should also add org.eclipse.epsilon.erl.engine to the dependencies of your plugin.

Cheers,
Dimitris
Previous Topic:How to use Epsilon Modelling language to create a simple game?(such as Go)
Next Topic:Modify gmf.node
Goto Forum:
  


Current Time: Fri Aug 22 23:50:24 EDT 2014

Powered by FUDForum. Page generated in 0.02636 seconds