Skip to main content



      Home
Home » Modeling » M2T (model-to-text transformation) » JET in GMF Project
JET in GMF Project [message #23417] Thu, 21 June 2007 15:12 Go to next message
Eclipse UserFriend
Originally posted by: vinsarwate.yahoo.com

Hi,

I know there are few threads in this newgroup that discussed issues
related to this topic but please take a few sec to read this and pl help
me out.

In my case, I want the capability to right click and generate code (say
Java code) from my model file (some_diagram.workflow). To achieve this I
performed following steps.

1. Added JET Nature to my GMF diagram plugin project
(something.workflow.diagram).
2. Added required template to template folder. Following is a snippet from
one of the template -
<%@ jet package="something.workflow.diagram.generate"
class="WorkFlowToJavaTemplate" imports="......"%>

<% WorkFlowDiagram diagram = (WorkFlowDiagram) argument;

List activities= diagram.getActivities();
for (Iterator iter = activities.iterator(); iter.hasNext();) {
Activity activity = (Activity) iter.next();
stringBuffer.append(activity.getName());
}

%>

3. I have created an popupMenu extentension to call CodeGenerationAction
in GMF diagram plugin project. This action reads WorkFlowDiagram from
selected WorkFlow model file in navigator and passes this WorkFlowDiagram
instance to templated generated WorkFlowToJavaTemplate class.

At runtime, when I right click on WorkFlow model file and select
"Generate" option from popup menu, I am getting following error -

Feature 'version' not found. (file:///WorkFlowProject/default.workflow, 2,
175)

I know this is a bug already reported by Paul
(https://bugs.eclipse.org/bugs/show_bug.cgi?id=190809).

But my question is what is the workaround.

In one of the previous thread
( http://www.eclipse.org/newsportal/article.php?id=252&gro up=eclipse.modeling.m2t#252)
Paul explained in detail how to read EMF document. I followed those steps
to solve this problem but was not able to get passed this error.

Please see that when I added JET nature to my GMF Diagram project, it does
not create "org.eclipse.jet.transform" entry in plugin.xml. I manually
created this entry, added required dependencies and also modified
"modelLoader" attribute of "transform" node to "org.eclipse.jet.emf". But
no luck.

Could anyone please provide me pointers/guideline to achieve this
right-click and generate functionality.

Thanks.
Vinay
Re: JET in GMF Project [message #23461 is a reply to message #23417] Thu, 21 June 2007 17:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: vinsarwate.yahoo.com

Well I got something.

I realized that I don't need to add "org.eclipse.jet.transform" extension
in my GMF project as I am not running transformation at runtime, my fault.

The error "Feature 'version' not found" was becase XML loader was not able
to resolve reference to XMI schema.

For a work around, and pl correct me if this is not a correct way of doing
things, I registered both ecore model (WorkFlow and xmi) to a resource set
in following way inside my action class.

URI fileURI =
URI.createFileURI(selectedModelFile.getFullPath().toOSString ());

ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap()
.put("http://www.omg.org/XMI",
new EcoreResourceFactoryImpl());
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap()
.put("http://stp.eclipse.org/bpmn",
new WorkFlowResourceFactoryImpl());

Resource r = resourceSet.getResource(fileURI,true);
WorkFlowDiagram wfd = (WorkFlowDiagram)r.getContents().get(0);

WorkFlowToJavaTemplate codeTemplate = new WorkFlowToJavaTemplate();
System.out.println(codeTemplate.generate(wfd));
....

Thanks.
Vinay
Re: JET in GMF Project [message #23502 is a reply to message #23461] Thu, 21 June 2007 17:37 Go to previous message
Eclipse UserFriend
Originally posted by: vinsarwate.yahoo.com

Sorry copy paste mistake, http://stp.eclipse.org/bpmn is
http://something.org/workflow in previous reply.

Thanks.
Vinay
Previous Topic:[JET2] Using MessageDialog in custom Tag
Next Topic:run jet2 outside of eclipse
Goto Forum:
  


Current Time: Sun Jun 01 04:56:51 EDT 2025

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

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

Back to the top