Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » GMF aspects: organize java imports
GMF aspects: organize java imports [message #635887] Thu, 28 October 2010 13:46 Go to next message
Cedric Moonen is currently offline Cedric MoonenFriend
Messages: 274
Registered: August 2009
Senior Member
Hello,

I recently discovered that you can customize the code generation by using aspects. This makes the code much more maintainable and avoid to modify the generated code directly.

I was wondering how the java imports work ? When I customize some of the define blocks and try to use some custom types, I get errors in my generated code since the type cannot be resolved (opening the file and adding the java import fixes the problem).
I noticed that this is somehow automatically done in the GMF templates: fully qualified names are used everywhere but are then removed after the code generation and replaced by their corresponding import.
I tried to do the same but the fully qualified names are not replaced (and there's no additional import).

How can I do something similar as in the original GMF templates ?
Re: GMF aspects: organize java imports [message #635891 is a reply to message #635887] Thu, 28 October 2010 14:07 Go to previous messageGo to next message
Aurélien Pupier is currently offline Aurélien PupierFriend
Messages: 637
Registered: July 2009
Location: Grenoble, FRANCE
Senior Member

Hi,

we are using it and the import are well done.
I don't remember of any customization to do that working.

One idea, are you regenerated MANIFEST.MF too?
if no, perhaps you should try to set "required plugin identifiers" in gmfgen->gen editor generator -> gen plugin?

Regards,


Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
Re: GMF aspects: organize java imports [message #635895 is a reply to message #635891] Thu, 28 October 2010 14:30 Go to previous messageGo to next message
Cedric Moonen is currently offline Cedric MoonenFriend
Messages: 274
Registered: August 2009
Senior Member
Hi Aurelien,

Thanks for your answer.
I tried to remove the Manifest.MF so that it is completely regenerated on the next code generation but this doesn't fix the problem.
I looked at the option in the gmfgen file about the required plugin identifiers but it looks strange to me, since there are only two identifiers (related to Draw2D), so the existing code generation doesn't really work with that.

In fact, how does the code generator add the java imports on top of the generated files ? Was my assumption correct ?
Because I looked at some of the GMF templates and saw that they always use fully qualified names which are not present anymore in the generated file.

By the way, I discovered the aspects in GMF because of your blog, so thanks for that too Smile
Re: GMF aspects: organize java imports [message #635898 is a reply to message #635895] Thu, 28 October 2010 14:34 Go to previous messageGo to next message
Aurélien Pupier is currently offline Aurélien PupierFriend
Messages: 637
Registered: July 2009
Location: Grenoble, FRANCE
Senior Member

Cedric wrote on Thu, 28 October 2010 16:30
Hi Aurelien,
I tried to remove the Manifest.MF so that it is completely regenerated on the next code generation but this doesn't fix the problem.
I looked at the option in the gmfgen file about the required plugin identifiers but it looks strange to me, since there are only two identifiers (related to Draw2D), so the existing code generation doesn't really work with that.


Add your own plugin identifier and regenerate cleaning also the MANIFEST.MF. So like that, the import can be resolved.


Cedric wrote on Thu, 28 October 2010 16:30

In fact, how does the code generator add the java imports on top of the generated files ? Was my assumption correct ?


I believe that there is a java beautifier action done at the end of the generation.


Cedric wrote on Thu, 28 October 2010 16:30

By the way, I discovered the aspects in GMF because of your blog, so thanks for that too Smile


Happy that it helps you Smile


Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
Re: GMF aspects: organize java imports [message #636037 is a reply to message #635898] Fri, 29 October 2010 06:43 Go to previous message
Cedric Moonen is currently offline Cedric MoonenFriend
Messages: 274
Registered: August 2009
Senior Member
Hello Aurélien,

Thanks for your answer. I tried your suggestion but the problem still persists. In fact, it works fine for all qualified names except when it comes to my own plug-ins.
Even when the fully qualified name points to some generated code (like for instance the Messages class which is in the XXXX.diagram.part package).

Anyway, for all the other classes it works fine, so I guess this is not really important. I'll simply have the fully qualified name sometimes in the generated code.

Anyway, thanks for your help !
Cédric
Previous Topic:Node without any label
Next Topic:Rectilinear router forming 'knots'
Goto Forum:
  


Current Time: Fri Apr 26 00:51:02 GMT 2024

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

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

Back to the top