Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » GMF integartion wid xpand(code generation with graphical editor )
GMF integartion wid xpand [message #647028] Tue, 04 January 2011 07:08 Go to next message
Ravi Kiran is currently offline Ravi KiranFriend
Messages: 41
Registered: December 2010
Member
i am new bie to eclipse .
i need to create a graphcal editor that can generate code or text
i chose gmf and successfully created editor. i also worked on xpand with the same ecore model and was able to generate some code. now i want to integrate both gmf editor and xpand code generator. will it be possible?

or should i go for any other code generator acceleo or jet ?

please help as soon as possible.
Re: GMF integartion wid xpand [message #647066 is a reply to message #647028] Tue, 04 January 2011 13:03 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 360
Registered: July 2009
Location: Dortmund
Senior Member

I already had a longer post to this issue, but on submit the session was expired and the text is lost. Grrr.

So now the short answer:
- The GMF models are ordinary EMF XMI files
- Xpand can be invoked with an instantiated EMF AST. This can be done either by invoking a workflow or loading the resource yourself and using the XpandFacade.

Some links:
http://www.peterfriese.de/using-xpand-in-your-eclipse-wizards/
http:// svn.codehaus.org/openxma/org.openxma.dsl/trunk/org.openxma.d sl.ui/src/org/openxma/dsl/ui/handlers/DomGeneratorJob.java
http:// www.edna-site.org/svn/trunk/rcp/org.edna.uml2xsd.ui/src/org/ edna/uml2xsd/ui/

HTH,
~Karsten


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: GMF integartion wid xpand [message #651025 is a reply to message #647066] Thu, 27 January 2011 13:42 Go to previous messageGo to next message
Ravi Kiran is currently offline Ravi KiranFriend
Messages: 41
Registered: December 2010
Member
Hi

Thanks for reply

i have been able to use that way to generate the code for gmf but i m trying out a similar way but have been from a while

i have a created a menu and command using extensions in gmf manifest file. and been trying to invoke xpand generator


the code for the command is as shown below

public class customCommand extends AbstractHandler implements IHandler {

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
// TODO Auto-generated method stub


Shell s=HandlerUtil.getActiveShell(event);
MessageBox mb=new MessageBox(s,SWT.None);









WorkflowRunner runner = new WorkflowRunner();
Bundle bundle=Platform.getBundle("MistScriptGenerator");
URL wfUrl = bundle.getEntry("src/workflow/generator.oaw");
String wfFile = "";



try {

wfFile = FileLocator.toFileURL(wfUrl).getFile();
mb.setMessage(wfFile);
mb.open();

Map<String, String> properties = new HashMap<String, String>();
//properties.put("model", $diagramFile$.getLocation().toOSString());
properties=null;
boolean isSuccess = runner.run(wfFile,new org.openarchitectureware.workflow.monitor.NullProgressMonito r(), properties, null);


}
catch (Exception e)
{


}

return null;
}

}

i able succesfully able to get path for the workflow
now while invoking the workflow i will have to input the gmf diagram file to the workflow. but how can i give the path for the file ?

i execute my gmf digram by opening it another workbench
now how do i get the path of gmf diagram file ?


i have registered epackage in my workflow.

can you please guide me the project deadline is very soon

Re: GMF integartion wid xpand [message #651283 is a reply to message #651025] Fri, 28 January 2011 17:20 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6499
Registered: July 2009
Senior Member
Hi Ravi,

i get the question to be answered is: how do i get access to the model file if i add a handler to execute something from a gmf context menu. so maybe the gmf forum might be the right place.

~Christian
icon14.gif  Re: GMF integartion wid xpand [message #651291 is a reply to message #651283] Fri, 28 January 2011 18:08 Go to previous messageGo to next message
Ravi Kiran is currently offline Ravi KiranFriend
Messages: 41
Registered: December 2010
Member
thanks chris

for briefing it in two line Cool

Re: GMF integartion wid xpand [message #651300 is a reply to message #651291] Fri, 28 January 2011 19:05 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6499
Registered: July 2009
Senior Member
So what about something like

(GMF Stuff / not Xpand stuff)

ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
		if (currentSelection instanceof IStructuredSelection) {
			IStructuredSelection ss = (IStructuredSelection)currentSelection;
			if (!ss.isEmpty()) {
				Object so = ss.getFirstElement();
				if (so instanceof EditPart) {
					Object m = ((EditPart)so).getModel();
					if (m instanceof EObject) {
						System.out.println(((EObject)m).eResource().getURI().toString());
					}
				}
			}
		}


And if you have split up graphical and physical storage
System.out.println(((Diagram)m).getElement().eResource().get URI());

~Christian

Christian

[Updated on: Fri, 28 January 2011 19:09]

Report message to a moderator

Re: GMF integartion wid xpand [message #651501 is a reply to message #651300] Mon, 31 January 2011 13:03 Go to previous messageGo to next message
Ravi Kiran is currently offline Ravi KiranFriend
Messages: 41
Registered: December 2010
Member
hi chris

thanks for your patience and reply

i have tried using the code to get the diagram file but editor part class doesn't have a function getModel

so its giving error

can you please suggest me how i can go ahead?





Re: GMF integartion wid xpand [message #651505 is a reply to message #651501] Mon, 31 January 2011 13:17 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6499
Registered: July 2009
Senior Member
Hi,

which EditPart class did you import? it is a std GMF class.

~ Christian
Re: GMF integartion wid xpand [message #651714 is a reply to message #651505] Tue, 01 February 2011 11:55 Go to previous messageGo to next message
Ravi Kiran is currently offline Ravi KiranFriend
Messages: 41
Registered: December 2010
Member
i was using emf editor part class

but now i know that
gmf class should be used but what is exact import statement ?

is it org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts

?

and apart from this even if i hard code the path for diagaram file my workflow is not running
Re: GMF integartion wid xpand [message #651718 is a reply to message #651714] Tue, 01 February 2011 12:24 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6499
Registered: July 2009
Senior Member
Hi,

what about org.eclipse.gef.EditPart? just guessing - do not have my sample code here - but with some sysouts it should be easy to find out what class so is an instance of.

about hardcoding - without knowing your workflow i cannot say - maybe you should first get it running hardcoded.

and how do you hardcode it?

~Christian

[Updated on: Tue, 01 February 2011 12:26]

Report message to a moderator

Re: GMF integartion wid xpand [message #651719 is a reply to message #651718] Tue, 01 February 2011 12:33 Go to previous messageGo to next message
Ravi Kiran is currently offline Ravi KiranFriend
Messages: 41
Registered: December 2010
Member
and about that location of the file.can we do it like this

PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().getActiveEditor().getTitle()

the above gives only the title i want the file location

i hard coded it like this
i checked the diagram file properties where we have the diagram file hard disk location

"C:\Documents and Settings\rtiragat\runtime-EclipseApplication\Automation\defa ult.mist_diagram "






my workflow is the below

in the below "automation.AutomationPackage" class attribute in gmf plugin.xml


<?xml version="1.0"?>
<workflow>
<property name="model" value="MistScriptGenerator/src/TestCase.xmi" />
<property name="src-gen" value="src-gen" />

<!-- set up EMF for standalone execution -->
<bean class="org.eclipse.mwe.emf.StandaloneSetup" >
<platformUri value=".."/>
<registerGeneratedEPackage value="automation.AutomationPackage"/>
<!-- Load GMF Notation package Don't load from model as it gives errors -->
<registerGeneratedEPackage value="org.eclipse.gmf.runtime.notation.NotationPackage"/>

</bean>

<!-- load model and store it in slot 'model' -->
<component class="org.eclipse.mwe.emf.Reader">
<uri value="platform:/resource/${model}" />
<modelSlot value="model" />
</component>

<!-- check model -->
<component class="oaw.check.CheckComponent">
<metaModel id="mm"
class="org.eclipse.m2t.type.emf.EmfRegistryMetaModel"/>
<checkFile value="metamodel::Checks" />
<emfAllChildrenSlot value="model" />
</component>

<!-- generate code -->
<component class="org.openarchitectureware.xpand2.Generator">
<metaModel idRef="mm"/>
<expand
value="template::Template::main FOR model" />
<outlet path="${src-gen}" >
<postprocessor class="org.openarchitectureware.xpand2.output.JavaBeautifier " />
</outlet>
</component>
</workflow>

Re: GMF integartion wid xpand [message #651722 is a reply to message #651719] Tue, 01 February 2011 12:40 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6499
Registered: July 2009
Senior Member
Hi,

if you reference the model like <uri value="platform:/resource/${model}" /> then shouldn't be the hardcoded name Automation/default.mist_diagram

~Christian
Re: GMF integartion wid xpand [message #651732 is a reply to message #651722] Tue, 01 February 2011 13:12 Go to previous messageGo to next message
Ravi Kiran is currently offline Ravi KiranFriend
Messages: 41
Registered: December 2010
Member
hi chri
in the workflow

path="C:\\Documents and Settings\\rtiragat\\runtime-EclipseApplication\\Automation\\ default.mist_diagram "
properties.put("model",path);

boolean isSuccess = runner.run(" C:\\Documents and Settings\\rtiragat\\workspace\\MistScriptGenerator\\src\\wor kflow\\generator.oaw ",new org.openarchitectureware.workflow.monitor.NullProgressMonito r(), properties, null);

i m filling the model attribute with the diagram file location


i guess i should edit my workflow like this

<uri value="platform:/resource/${model}" />

to
<uri value="${model}" />

is it not?



i guess i should kept it <uri value="platform:/resource/${model}" />

but what should i fill this model with ?
because i open a new eclipe application to run this gmf plugin i created and new java project and in that i created mist diagram

[Updated on: Tue, 01 February 2011 13:16]

Report message to a moderator

Re: GMF integartion wid xpand [message #651741 is a reply to message #651732] Tue, 01 February 2011 13:18 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6499
Registered: July 2009
Senior Member
Hi,

do not know if this works with C:\\ - play around with c:\\ c:// file:// and so on. - try to get workflow running by rightclick.

~ Christian
Re: GMF integartion wid xpand [message #651752 is a reply to message #651741] Tue, 01 February 2011 13:31 Go to previous messageGo to next message
Ravi Kiran is currently offline Ravi KiranFriend
Messages: 41
Registered: December 2010
Member
hi chris

workflow runs fine when i right click and run as oaw
the the problem is running from the gmf context menu

while i was trying to do this my gmf plugin got crashed may be i have try doing that first

"Automation/default.mist_diagarm" should work


many thanks for your patience
Re: GMF integartion wid xpand [message #651753 is a reply to message #651752] Tue, 01 February 2011 13:33 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6499
Registered: July 2009
Senior Member
Hi,

the code i gave you before should help you to get a complete platform:/resource uri from context menu on a gmf diagram/element.

~ Christian
Re: GMF integartion wid xpand [message #651929 is a reply to message #651753] Wed, 02 February 2011 05:54 Go to previous messageGo to next message
Ravi Kiran is currently offline Ravi KiranFriend
Messages: 41
Registered: December 2010
Member
hi chris

the code snipped u gave worked fine. just that editor part had to be replaced with editpart of gef. that's cool

but now a new problem surfaced out

when i execute it's going out of memory.
shall i show you the error dump..

Re: GMF integartion wid xpand [message #651935 is a reply to message #651929] Wed, 02 February 2011 06:28 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6499
Registered: July 2009
Senior Member
Hi, what about simply increasing memory

~Christian
Re: GMF integartion wid xpand [message #651945 is a reply to message #651935] Wed, 02 February 2011 08:03 Go to previous messageGo to next message
Ravi Kiran is currently offline Ravi KiranFriend
Messages: 41
Registered: December 2010
Member
just now found out that it wasn't because of memory . but still not executing should i include the generator plugin in the diagram plugin dependency?

will that work?

the following is the output on the console



!SESSION 2011-02-02 13:31:56.907 -----------------------------------------------
eclipse.buildId=M20100909-0800
java.version=1.6.0_16
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Framework arguments: -product org.eclipse.platform.ide
Command-line arguments: -product org.eclipse.platform.ide -data C:\Documents and Settings\rtiragat\workspace/../runtime-EclipseApplication -dev file:C:/Documents and Settings/rtiragat/workspace/.metadata/.plugins/org.eclipse.p de.core/Eclipse Application/dev.properties -os win32 -ws win32 -arch x86 -consoleLog

!ENTRY org.eclipse.ui 4 0 2011-02-02 13:32:10.680
!MESSAGE Unable to create editor ID dummy.diagram.part.DummyDiagramEditorID: No editor descriptor for id dummy.diagram.part.DummyDiagramEditorID
!STACK 1
org.eclipse.ui.PartInitException: No editor descriptor for id dummy.diagram.part.DummyDiagramEditorID
at org.eclipse.ui.internal.EditorReference.createPartHelper(Edi torReference.java:601)
at org.eclipse.ui.internal.EditorReference.createPart(EditorRef erence.java:465)
at org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb enchPartReference.java:595)
at org.eclipse.ui.internal.EditorAreaHelper.setVisibleEditor(Ed itorAreaHelper.java:271)
at org.eclipse.ui.internal.EditorManager.setVisibleEditor(Edito rManager.java:1429)
at org.eclipse.ui.internal.EditorManager$5.runWithException(Edi torManager.java:942)
at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run (StartupThreading.java:31)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:134)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:4041)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3660)
at org.eclipse.ui.application.WorkbenchAdvisor.openWindows(Work benchAdvisor.java:803)
at org.eclipse.ui.internal.Workbench$31.runWithException(Workbe nch.java:1567)
at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run (StartupThreading.java:31)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:134)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:4041)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3660)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2548)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:24 38)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
at org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:664)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:115)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 619)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
!SUBENTRY 1 org.eclipse.ui 4 0 2011-02-02 13:32:10.695
!MESSAGE No editor descriptor for id dummy.diagram.part.DummyDiagramEditorID

!ENTRY org.eclipse.ui 2 2 2011-02-02 13:32:10.804
!MESSAGE Ignored attempt to add saveable that was already registered
!STACK 0
org.eclipse.core.runtime.AssertionFailedException: unknown saveable: org.eclipse.ui.internal.DefaultSaveable@b5a95a from part: org.eclipse.ui.internal.ErrorEditorPart@b5a95a
at org.eclipse.ui.internal.SaveablesList.logWarning(SaveablesLi st.java:187)
at org.eclipse.ui.internal.SaveablesList.addModel(SaveablesList .java:117)
at org.eclipse.ui.internal.SaveablesList.addModels(SaveablesLis t.java:289)
at org.eclipse.ui.internal.SaveablesList.postOpen(SaveablesList .java:684)
at org.eclipse.ui.internal.PartList.partOpened(PartList.java:23 4)
at org.eclipse.ui.internal.PartList.access$0(PartList.java:210)
at org.eclipse.ui.internal.PartList$1.propertyChanged(PartList. java:40)
at org.eclipse.ui.internal.WorkbenchPartReference.fireInternalP ropertyChange(WorkbenchPartReference.java:375)
at org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb enchPartReference.java:610)
at org.eclipse.ui.internal.EditorAreaHelper.setVisibleEditor(Ed itorAreaHelper.java:271)
at org.eclipse.ui.internal.EditorManager.setVisibleEditor(Edito rManager.java:1429)
at org.eclipse.ui.internal.EditorManager$5.runWithException(Edi torManager.java:942)
at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run (StartupThreading.java:31)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:134)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:4041)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3660)
at org.eclipse.ui.application.WorkbenchAdvisor.openWindows(Work benchAdvisor.java:803)
at org.eclipse.ui.internal.Workbench$31.runWithException(Workbe nch.java:1567)
at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run (StartupThreading.java:31)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:134)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:4041)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3660)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2548)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:24 38)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
at org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:664)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:115)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 619)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
at org.eclipse.equinox.launcher.Main.main(Main.java:1383)

!ENTRY org.eclipse.emf.ecore 2 0 2011-02-02 13:32:12.136
!MESSAGE Both 'org.eclipse.gmf.bridge.trace' and 'org.eclipse.xpand.incremental' register an extension parser for 'trace'

!ENTRY org.eclipse.osgi 2 1 2011-02-02 13:32:20.843
!MESSAGE NLS unused message: Mist1Group_title in: messages

!ENTRY org.eclipse.osgi 2 1 2011-02-02 13:32:20.843
!MESSAGE NLS unused message: StartBlock2CreationTool_title in: messages

!ENTRY org.eclipse.osgi 2 1 2011-02-02 13:32:20.843
!MESSAGE NLS unused message: StartBlock2CreationTool_desc in: messages

!ENTRY org.eclipse.osgi 2 1 2011-02-02 13:32:20.843
!MESSAGE NLS unused message: EndBlock3CreationTool_title in: messages

!ENTRY org.eclipse.osgi 2 1 2011-02-02 13:32:20.843
!MESSAGE NLS unused message: EndBlock3CreationTool_desc in: messages

!ENTRY org.eclipse.osgi 2 1 2011-02-02 13:32:20.843
!MESSAGE NLS unused message: MakeCallBlock4CreationTool_title in: messages

!ENTRY org.eclipse.osgi 2 1 2011-02-02 13:32:20.843
!MESSAGE NLS unused message: MakeCallBlock4CreationTool_desc in: messages

!ENTRY org.eclipse.osgi 2 1 2011-02-02 13:32:20.843
!MESSAGE NLS unused message: Mist1Group_desc in: messages

!ENTRY org.eclipse.osgi 2 1 2011-02-02 13:32:20.843
!MESSAGE NLS unused message: Mist2Group_title in: messages

!ENTRY org.eclipse.osgi 2 1 2011-02-02 13:32:20.843
!MESSAGE NLS unused message: Mist2Group_desc in: messages

!ENTRY org.eclipse.emf.cdo.dawn.examples.acore.diagram 1 0 2011-02-02 13:32:23.353
!MESSAGE Using DawnAcoreEditPartProvider instead of the original one.

!ENTRY org.eclipse.emf.cdo.dawn.examples.acore.diagram 1 0 2011-02-02 13:32:23.353
!MESSAGE Using DawnAcoreEditPartFactory instead of the original one
Re: GMF integartion wid xpand [message #651948 is a reply to message #651945] Wed, 02 February 2011 08:11 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6499
Registered: July 2009
Senior Member
Hi,

From the console output i cannot see any hint on the generation Wink so i cannot help. please check

- Is the Workflow running
- Is the Generator or whatever you start in the workflow run (mabye you add some logging to your templates / create a file in the root.
- What is you template like?
- Does the workflow run standalone?
....

~Christian
Re: GMF integartion wid xpand [message #656589 is a reply to message #651945] Sun, 27 February 2011 03:15 Go to previous messageGo to next message
gkr  is currently offline gkr Friend
Messages: 13
Registered: March 2010
Junior Member
Hello Ravi,

Did you successfully complete this project? I have got a similar
project and stuck in similar situation.

If you still have the project with you, can you please send it to me; so that I can have a look?

Thanks

gandharva Kumar

gbondiway [at] gmail [dot] com

[Updated on: Sun, 27 February 2011 03:19]

Report message to a moderator

Re: GMF integartion wid xpand [message #657017 is a reply to message #656589] Tue, 01 March 2011 11:32 Go to previous messageGo to next message
Ravi Kiran is currently offline Ravi KiranFriend
Messages: 41
Registered: December 2010
Member
hi kumar

sorry for responding late. project is almost done but code generation works only partially


i can send you the requires code snippets not the entire projects it's proprietary please feel free to ask any code snippets


Regards
Ravi
Re: GMF integartion wid xpand [message #657024 is a reply to message #657017] Tue, 01 March 2011 11:53 Go to previous messageGo to next message
gkr  is currently offline gkr Friend
Messages: 13
Registered: March 2010
Junior Member
Hi Ravi,

I'm stuck at point where I need to integrate a generator in my GMF editor. I would like to ask-
1) I have used Xpand earlier to generate code from EMF model/ metamodel. The workflow file needs to refer to the EMF metamodel. Problem is- how to use Xpand to generate code from GMF diagram/ model file?

2) how to embed the generator in the editor so that Code can be generated on click of a button?

Thanks a lot.
Re: GMF integartion wid xpand [message #657046 is a reply to message #657024] Tue, 01 March 2011 13:00 Go to previous messageGo to next message
Ravi Kiran is currently offline Ravi KiranFriend
Messages: 41
Registered: December 2010
Member
hi Kumar

propably u know to invoke generator for XMI file

gmf is also a XMI file. it consists of two file one is diagram file other is model file.model file is same as XMI

pass that file to the generator

workflow configuration needs to know that u r going to generate code for gmf files. so u r work flow configuration needs to register the gmf model

that can be done by including a tag in the .oaw file or .mwe file


please find below my oaw file

------------------------------------------------------------ ------------

<?xml version="1.0"?>
<workflow>
	<property name="model" value="D:\\mist\\default.mist" />
	<!--<property name="model" value="Automation/default.mist_diagram" />-->
	<!--<property name="src-gen" value="src-gen" />-->
	<property name="src-gen" value="/C:/"/>
	
	
	<!-- set up EMF for standalone execution -->
	<!--<bean class="org.eclipse.mwe.emf.StandaloneSetup" >-->
			
<bean class="org.eclipse.mwe.emf.StandaloneSetup" >
		<platformUri value="../.."/>
		<registerGeneratedEPackage value="mist.MistPackage"/> // [B]here u need to give the class name of plugin that contains ecore file (emf) [/B]
		<!-- Load GMF Notation package Don't load from model as it gives errors -->
		<registerGeneratedEPackage value="org.eclipse.gmf.runtime.notation.NotationPackage"/>
	</bean>


   <!-- instantiate metamodel -->
	<bean id="mm_emf" class="org.eclipse.m2t.type.emf.EmfRegistryMetaModel"/>  
<!-- load model and store it in slot 'model' -->
<!--<component class="org.eclipse.mwe.emf.Reader">-->
	<component class="org.openarchitectureware.emf.XmiReader">
	<modelFile value="${model}"/>	  
	  <outputSlot value="model"/>
		<firstElementOnly value="true"/>
	
	    <!--<model value="${model}"/>-->
	    
	<!--    <uri value="platform:/resource/${model}" />-->
		<!--<modelSlot value="model" />-->
	</component>

	
	
		<!-- check model -->
	<component class="oaw.check.CheckComponent">
		<metaModel idRef="mm_emf"/>
		<checkFile value="metamodel::Checks" />
		<emfAllChildrenSlot value="model" />
	</component>
	
	
	

<!--  generate code -->
	<component class="org.openarchitectureware.xpand2.Generator">
		<metaModel idRef="mm_emf"/>
		<expand
			value="template::Template::main FOR model" />
		<outlet path="${src-gen}" >
			<postprocessor class="org.openarchitectureware.xpand2.output.JavaBeautifier" />
		<fileEncoding value="UTF-8"/>
		</outlet>
	</component>
</workflow>






------------------------------------------------------------ ---------

u can add a menu and a command to the eclipse ide through extensions .which on clicking will invoke this work flow

you can refer to the following links
http:// www.openarchitectureware.org/pub/documentation/4.3.1/html/co ntents/core_reference.html#xpand_reference_introduction


follwing code for invoking workflow from any application code :-
Starting from your own code
You can also run the generator from your own application code. Two things to note:

the contents of the properties map override the properties defined in the workflow.
The slotContents map allows you to fill stuff into the workflow from your application. This is a typical use case: you run oAW from within your app because you already have a model in memory.
  String wfFile = "somePath\\workflow.oaw";
  Map properties = new HashMap();
  Map slotContents = new HashMap();
  new WorkflowRunner().run(wfFile ,
    new NullProgressMonitor(), properties, slotContents)


how to add menu
http:// www.vogella.de/articles/EclipseRCP/article.html#commands_men u

don't forget to add dependency of the generator plugin to gmf plugin



regards
Ravi

[Updated on: Tue, 01 March 2011 13:04]

Report message to a moderator

Re: GMF integartion wid xpand [message #657215 is a reply to message #657046] Tue, 01 March 2011 23:42 Go to previous message
gkr  is currently offline gkr Friend
Messages: 13
Registered: March 2010
Junior Member
Thanks a lot Ravi.

Didn't get the "running workflow from code" part, but I'll try first. Hope I will not have to trouble you again.

regards,
gandharva
Previous Topic:[Acceleo 3] Overriding Templates
Next Topic:[Xtend] model transformations with interfaces
Goto Forum:
  


Current Time: Fri Nov 28 23:26:16 GMT 2014

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

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