Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Call Java methods from GMF Editor (generated with eugenia)
Call Java methods from GMF Editor (generated with eugenia) [message #822546] Fri, 16 March 2012 22:33 Go to next message
Robson Silva is currently offline Robson Silva
Messages: 6
Registered: March 2012
Junior Member
Hello,

I've generated an editor for my metamodel with Eugenia and now I'm trying to find a way to execute a manually written code inserted in the automatic generated java implementation of "op1". I marked the implementation of "op1" as "generated NOT" and added a dummy, for example, system.out.println("anything"). How can I call the method "op1" while I'm running the generated GMF Editor?

@gmf.diagram
class ClTest {
val Comp[*] comps;

op void op1 (Comp c);
}

Thanks.
Re: Call Java methods from GMF Editor (generated with eugenia) [message #822548 is a reply to message #822546] Fri, 16 March 2012 23:38 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris Kolovos
Messages: 880
Registered: July 2009
Senior Member
Hi,

You'll need to define an extension to the org.eclipse.ui.popupMenus extension point to do this. http://www.ibm.com/developerworks/opensource/tutorials/os-eclplgns/section4.html provides a good tutorial on this. You'll need to set objectClass to org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart instead of org.eclipse.core.resources.IFile, and then you can access the underlying EObject using resolveSemanticElement().

Hope this helps,
Dimitris
Re: Call Java methods from GMF Editor (generated with eugenia) [message #826217 is a reply to message #822548] Wed, 21 March 2012 20:23 Go to previous messageGo to next message
Robson Silva is currently offline Robson Silva
Messages: 6
Registered: March 2012
Junior Member
Dear Dimitrius,

Thank you for the answer.

Your suggestion seems to be very helpfull. But, I would like to know
whether there is any way to do this without creating a new plugin. Is it
possible to change one of the eclipse projects generated automatically by
EuGENia from the metamodel (showed below) to achieve this?

For example, eugenia generate a interface ClTest.java and an implementation
ClTestImpl.java for the class ClTest. In the interface, the method declaration
void op1 (Comp c); is created and in ClTestImpl.java an empty implementation
in created. I would like to put some code in this empty implementation and
somehow call this method in the generated GMF editor.


@gmf.diagram
class ClTest {
val Comp[*] comps;

op void op1 (Comp c);
}


Thanks for the help
Re: Call Java methods from GMF Editor (generated with eugenia) [message #826776 is a reply to message #826217] Thu, 22 March 2012 13:45 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris Kolovos
Messages: 880
Registered: July 2009
Senior Member
Hi,

Unfortunately, Eugenia doesn't provide such a feature. As a matter of fact, Eugenia doesn't generate any code at all; it just produces the .gmfxxx models and then passes them on to GMF for the code generation step.

Another option would be to define your actions as EWL wizards. See http://www.eclipse.org/epsilon/cinema/player.php?screencast=GMFWizards2 for an example (note that in the current version of EWL, in the "Configure Wizards" step of the process you need to provide the nsURI of your Ecore metamodel instead of the extension).

Cheers,
Dimitris
Re: Call Java methods from GMF Editor (generated with eugenia) [message #826779 is a reply to message #826776] Thu, 22 March 2012 13:52 Go to previous message
Dimitris Kolovos is currently offline Dimitris Kolovos
Messages: 880
Registered: July 2009
Senior Member
I forgot to mention that an advantage of going with the EWL solution is that if your actions modify the underlying model, you get support for transactions (i.e. undo/redo) for free.

Cheers,
Dimitris
Previous Topic:[announcement] ACademics Modelling with Eclipse Workshop - ECMFA 2012
Next Topic:Bug in org.eclipse.epsilon.evl.emf.validation
Goto Forum:
  


Current Time: Tue Oct 21 08:46:28 GMT 2014

Powered by FUDForum. Page generated in 0.02044 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software