Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 317241

Summary: Diagram generation does not respect the Interface Name Pattern supplied in genmodel
Product: [Modeling] GMF-Tooling Reporter: Josh M <public.web.josh>
Component: CoreAssignee: Andres Alvarez Mattos <aamattos>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3 CC: aamattos, andres.alvarez.mattos, borlander, mistria
Version: unspecifiedFlags: borlander: iplog-
mistria: review+
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed Patch
none
Modified Template
none
Proposed Patch
none
Patch (With compilation errors)
borlander: iplog+
Proposed Patch
none
Git Proposed Patch borlander: iplog+

Description Josh M CLA 2010-06-17 16:34:53 EDT
Build Identifier: 20100218-1602

If the user specifies an Interface Name Pattern (I{0}, for example) in the model's genmodel, the GMF generated diagram code does not respect that setting.

Reproducible: Always

Steps to Reproduce:
1. Create a model (.ecore) and corresponding .genmodel file.
2. Change the Interface Name Pattern (INP) from blank to: I{0}
3. Generate model and edit code from .genmodel
4. Build a .gmfgen using this model and .genmodel
5. Generate diagram code
6. Many compile errors now exist because the gmfgen code is generated as if the INP was still blank.
Comment 1 Eclipse Webmaster CLA 2010-07-19 22:21:24 EDT
[GMF Restructure] Bug 319140 : product GMF and component
Generation was the original product and component for this bug
Comment 2 Andres Alvarez Mattos CLA 2011-06-27 06:47:54 EDT
Created attachment 198634 [details]
Proposed Patch

This is a suggested solution to this bug.
I declared via the org.eclipse.m2m.qvt.oml.javaBlackboxUnits extension point, an utility class to be called from the MetaModel.qvto template
Comment 3 Andres Alvarez Mattos CLA 2011-06-27 06:49:28 EDT
Created attachment 198635 [details]
Modified Template

Template with the modifications to call an utility class registered via org.eclipse.m2m.qvt.oml.javaBlackboxUnits extension point
Comment 4 Mickael Istria CLA 2011-06-27 06:54:01 EDT
The patch you attached is in binary format, so that I cannot take a look at it. Can you please resend it in a diff format?
Comment 5 Andres Alvarez Mattos CLA 2011-06-27 06:59:48 EDT
Created attachment 198636 [details]
Proposed Patch
Comment 6 Andres Alvarez Mattos CLA 2011-06-27 06:59:58 EDT
The Code is generated incorrectly because the template MetaModel.qvto is not
calculating the generated Factories, Packages and Interfaces names according to
the user specified patterns.

I suggest to modify the org.eclipse.gmf.codegen plugin, declaring via the
org.eclipse.m2m.qvt.oml.javaBlackboxUnits extension point an utility class (for
example GenPackageUtils) with the methods to correctly use the user custom
patterns, and modify the MetaModetl.qvto file to call the appropiate methods in
the utility class. 

I tested this solution with the Utility class defined in a plugin called
org.eclipse.gmf.codegen.patch  using Dynamic Templates in my GMF project to
overwrite the MetaModetl.qvto file
Comment 7 Andres Alvarez Mattos CLA 2011-06-28 04:46:38 EDT
Hi Mickael, I incorrectly marked the attachment as a patch. Its an independent plugin in where I put the utility class mentioned in other comment. 

thanks

(In reply to comment #4)
> The patch you attached is in binary format, so that I cannot take a look at it.
> Can you please resend it in a diff format?
Comment 8 Mickael Istria CLA 2011-06-28 04:50:44 EDT
Ok,
We'll give it a try ASAP, and since there is a workaround, we'll probably get it integrated for a 2.4.1 release (to be released by november).
However, it will be available on Interim builds just after the 2.4.0 release is done.
Comment 9 Mickael Istria CLA 2011-07-08 04:50:48 EDT
Andres,

Your solution looks good. Do you think you could provide it as a patch on org.eclipse.gmf.codegen plugin? ( See http://wiki.eclipse.org/Graphical_Modeling_Framework/Get_Involved )

With a patch, we'll be able to run tests easily, and this could be integrated in 2.4.0.
Comment 10 Andres Alvarez Mattos CLA 2011-07-11 07:38:41 EDT
Created attachment 199410 [details]
Patch (With compilation errors)

Mickael, I'm having troubles to integrate my solution with the plugin org.eclipse.gmf.codegen.

1 - I downloaded the source code from /cvsroot/modeling/org.eclipse.gmp
2 - Created a Class called GenPackageUtils.java in templates.qvtlib
3 - Modified the extension point org.eclipse.m2m.qvt.oml.javaBlackboxUnits to include the class specified above
4 - Created GenPackageUtils.qvto in folder templates.nativestubs (Not sure about this step)
5 - Modified MetaModel.qvto to call the methods from GenPackageUtils.

Following these steps I'm getting compilation errors at MetaModel.qvto. (I'm attaching these changes as a patch)

When I tried this solution locally, I only made the changes specified in steps 2 and 3, and then used dynamic templates modifying MetaModel.qvto, and it worked for me.

Any Ideas ?

thanks
Comment 11 Andres Alvarez Mattos CLA 2012-03-29 13:56:40 EDT
Created attachment 213347 [details]
Proposed Patch

Explained on comment #10
Comment 12 Andres Alvarez Mattos CLA 2012-03-29 14:07:52 EDT
Created attachment 213350 [details]
Git Proposed Patch
Comment 13 Mickael Istria CLA 2012-04-03 05:56:56 EDT
This patch was integrated and seems to be working well (tested locally and on CI without issue).
See https://hudson.eclipse.org/hudson/job/tycho-gmp.gmf.tooling.maintenance/21/ for report.

Gracias Andres for this fix!
Here is the patch, you are marked as author. http://git.eclipse.org/c/gmf-tooling/org.eclipse.gmf-tooling.git/commit/?h=2.4.x-maintenance&id=8aa88810eb643d8154ebdcd880291cccb9ed4c06
Comment 14 Mickael Istria CLA 2012-04-12 08:53:20 EDT
Andres, can you check a recent snapshot built to ensure your patch works
correctly?
http://download.eclipse.org/modeling/gmp/gmf-tooling/updates/dev-snapshots/2.4.x-maintenance
Comment 15 Andres Alvarez Mattos CLA 2012-04-13 05:34:17 EDT
Hi Mickael, I tested the snapshot built, and it worked fine.
thanks !
Comment 16 Michael Golubev CLA 2012-06-01 05:02:43 EDT
Marking Bugzilla itslef (not attachments) with iplog- to remove Eclipse Webmaster from IP log