Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Xtext Graphical View
Xtext Graphical View [message #1036534] Mon, 08 April 2013 14:01 Go to next message
d 627 is currently offline d 627Friend
Messages: 28
Registered: March 2013
Junior Member
Hi there.

This is my problem: I'm working with xtext and I have to create a GRAPHICAL REPRESENTATION of the projects creating with my own language, I mean, once my dsl is creating I'm able to use it creating a "X" project and the idea is to be able to see the rappresentation of that project.

I've been searching for a good example, and for possible solutions, but is like a dead road. I've seen some posts about EUGENIA, GMF, SPRAY... but in any of those they explain what to do. There is also a video in xtext home page with the generic graphic view example, but once and again there is no the explanation about how to create the conexion beetwen my dsl and the results that I can obtain.

What do you suggest, what can I do, do you know a good example.....


Thanks a lot.
Re: Xtext Graphical View [message #1036537 is a reply to message #1036534] Mon, 08 April 2013 14:07 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 913
Registered: July 2009
Senior Member
Hi Daniel,

I'm not sure I completely understand the problem you are describing. Is it the case that you already have an Xtext-based language and you need to visualise/edit models that conform to this language using a graphical editor?

Cheers,
Dimitris
Re: Xtext Graphical View [message #1036538 is a reply to message #1036537] Mon, 08 April 2013 14:10 Go to previous messageGo to next message
d 627 is currently offline d 627Friend
Messages: 28
Registered: March 2013
Junior Member
Exactly Dimitris.

I have create my own language using xtext (working good), the next step is create a project using this languge (no problema with that), but at the end I have to create a graphic representation of this project (in order to see dependences, edge, classes), that allows the user to make some analisis based on the graph and not in the code.
Re: Xtext Graphical View [message #1036545 is a reply to message #1036538] Mon, 08 April 2013 14:19 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 913
Registered: July 2009
Senior Member
You can try to annotate the Ecore metamodel produced from the Xtext grammar using the annotations provided by Eugenia [1] and then generate a GMF-based editor from it (don't go for the "Generate GMF Editor" option as you *only* want to generate the .diagram project). In your runtime workbench you should then be able to right-click on your models in the project explorer and select "Initialise XYZ diagram file".

Cheers,
Dimitris

[1] http://eclipse.org/epsilon/doc/articles/eugenia-gmf-tutorial/
Re: Xtext Graphical View [message #1036564 is a reply to message #1036545] Mon, 08 April 2013 14:49 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 913
Registered: July 2009
Senior Member
Hi Daniel,

I've tried this and it works fine. Please find a list of steps below:

1. Create a new Xtext project (keep all the defaults)
2. Launch GenerateMyDsl.mwe2
3. Annotate MyDsl.ecore (org.xtext.example.mydsl/src-gen/org/xtext/example/mydsl/MyDsl.ecore)
4. Right-click on MyDsl.ecore and select Eugenia->Generate GMF tool, graph and map models
5. Open MyDsl.genmodel, right-click on its root and select Generate Edit Code
6. Right-click on MyDsl.gmfmap and select Create generator model... (keep all the defaults)
7. Right-click on MyDsl.gmfgen and select Eugenia-> Synchronize GMFGen
8. Right-click on MyDsl.gmfgen and select Generate diagram code
9. Launch a new Eclipse instance
10. Create a new .mydsl file and add some valid contents to it
11. Right-click on the file in the project explorer and select Initialise mysdsl diagram file (you should now also be able to edit your .mydsl file through the GMF editor)

The complete code for the scenario above is available in https://dl.dropbox.com/u/5636547/org.xtext.example.mydsl.eugenia.zip

Cheers,
Dimitris
Re: Xtext Graphical View [message #1036675 is a reply to message #1036564] Mon, 08 April 2013 17:23 Go to previous messageGo to next message
d 627 is currently offline d 627Friend
Messages: 28
Registered: March 2013
Junior Member
Thanks a lot Dimitris, you are very helpfull. I'm trying to follow the steps you wrote, but until now when I generate the GMF tool, graph and map models I've got an error . In the error log appears: !ENTRY org.eclipse.ui 2 2 2013-04-08 17:59:45.370
!MESSAGE Invalid property category path: ValidationPropertiesPage (bundle: org.eclipse.wst.xml.ui, propertyPage: org.eclipse.wst.xml.ui.propertyPage.project.validation)

!ENTRY org.eclipse.epsilon.common.dt 4 0 2013-04-08 18:05:41.507
!MESSAGE Method 'getContainmentReferences' not found (bundleresource://566.fwk142345952/transformations/ECore2GMF.eol@189:38.
!STACK 0

I've been looking for the solution in other forums, but nothing 'till now.
Re: Xtext Graphical View [message #1036699 is a reply to message #1036675] Mon, 08 April 2013 17:54 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 913
Registered: July 2009
Senior Member
Hi Daniel,

By the sound of it, I suspect that you may have forgotten to annotate one of your EClasses as @gmf.diagram

Cheers,
Dimitris
Re: Xtext Graphical View [message #1036711 is a reply to message #1036699] Mon, 08 April 2013 18:11 Go to previous messageGo to next message
d 627 is currently offline d 627Friend
Messages: 28
Registered: March 2013
Junior Member
Dimitris so sorry for disturbing you so much, but is it possible to send a private mail?

[Updated on: Mon, 15 April 2013 20:18]

Report message to a moderator

Re: Xtext Graphical View [message #1036712 is a reply to message #1036711] Mon, 08 April 2013 18:15 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 913
Registered: July 2009
Senior Member
Hi Daniel,

No problem. Please feel free to email me at epsilon.devs@gmail.com and send me a copy of your .ecore so that I can have a quick look.

Cheers,
Dimitris
Re: Xtext Graphical View [message #1037262 is a reply to message #1036534] Tue, 09 April 2013 10:55 Go to previous messageGo to next message
Claudio Heeg is currently offline Claudio HeegFriend
Messages: 75
Registered: April 2013
Member
Well this is pretty amazing.
Converting the Xtext Domainmodel Example into a graphical view was quite easy, I have to say.

But, one problem that I had:
Whatever I tried, the context menu was only correct if I chose the file extension "domainmodel" (same name as the package). "dmodel" did not work, i.e. no option to generate a diagram from the .dmodel file context menu.

Where should I look to be able to change that?
Re: Xtext Graphical View [message #1037270 is a reply to message #1037262] Tue, 09 April 2013 11:08 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 913
Registered: July 2009
Senior Member
Hi Claudio,

I suspect that the extension of the domain model files is somehow controlled by Xtext but I'm afraid my knowledge of Xtext is quite limited to be able to help with this. If you do find out (people in the Xtext forum may be able to help) it'd be great if you could post the answer here for completeness.

Cheers,
Dimitris
Re: Xtext Graphical View [message #1037280 is a reply to message #1037270] Tue, 09 April 2013 11:22 Go to previous messageGo to next message
Claudio Heeg is currently offline Claudio HeegFriend
Messages: 75
Registered: April 2013
Member
Hello,

thanks for the quick response, I'll try to figure it out and will be sure to share.
One question on the Epsilon part of that, though - which part of the model does define the extension the diagram is applied to? My thinking being that what I am looking for is bound to be somewhere in the Ecore model itself, as basically everything is created from that.
Re: Xtext Graphical View [message #1037306 is a reply to message #1037280] Tue, 09 April 2013 11:56 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 913
Registered: July 2009
Senior Member
Hi Claudio,

Thanks! The diagram extension is defined through the diagram.extension detail of the gmf.diagram annotation [1].

Cheers,
Dimitris

[1] http://eclipse.org/epsilon/doc/articles/eugenia-gmf-tutorial/
Re: Xtext Graphical View [message #1037315 is a reply to message #1037306] Tue, 09 April 2013 12:08 Go to previous messageGo to next message
Claudio Heeg is currently offline Claudio HeegFriend
Messages: 75
Registered: April 2013
Member
Hello,

sorry, I probably haven't expressed myself properly.
I was wondering where the file extension for files from which a diagram can be created is specified, "domainmodel" in this specific case.
It is likely an extension added to the context menu, applied to a specific file extension, as the menu entry "Initialize [...] diagram" (see picture) only appears in .domainmodel files. I believe if I can find out where that menu entry is registered I can figure out how to work with different extensions.


Edit:
Nevermind, I found it, it's in the popup menu extension of the diagram. Now to find out _why_ it's specified as *.domainmodel there.

Edit2:
Doesn't matter, just editing the nameFilter to *.dmodel does the trick.
Trivial solutions to annoying problems are nice.
It is, however, a little bit of a nuisance that I have to change this all the time when I generate the diagram code anew.

[Updated on: Tue, 09 April 2013 12:40]

Report message to a moderator

Re: Xtext Graphical View [message #1037930 is a reply to message #1037315] Wed, 10 April 2013 07:31 Go to previous messageGo to next message
Mårten Carlzon is currently offline Mårten CarlzonFriend
Messages: 60
Registered: March 2013
Location: Sweden
Member

Hi

I jump in here if that's ok Smile

Dimitris, I tried to follow your steps but when I tried to generate the tool, graph, map thingies I got the following error message:
Method 'getContainmentReferences' not found (bundleresource://614.fwk1639539799/transformations/ECore2GMF.eol@189:38)

and when I run your zip folder i get the following errors when I try to make the mydsl_diagram file
"Premature end of file." and "java.lang.NullPointerException errors" so I end up with an empty diagram file I cant do much with.

So I don't seem to have much luck with making diagram files at the moment Smile

But I was wondering what I should look at in your code to see the interaction between XText and GMF? I am working at the moment in Graphiti and I have an XText grammar and a Graphiti diagram plugin and I am looking at merging them and even though your code is using GMF I thought it could be a good help.

Am I on the right track if I think the connection is in the plugin.xml from your org.xtext.example.mydsl.diagram package and the files in your org.xtext.example.mydsl.myDsl.provider package?
Re: Xtext Graphical View [message #1037944 is a reply to message #1037930] Wed, 10 April 2013 07:51 Go to previous messageGo to next message
Claudio Heeg is currently offline Claudio HeegFriend
Messages: 75
Registered: April 2013
Member
Oh dear, I wrote up such a nice post and the forum ate it. Rude.
-

Anyway, I hope you don't mind if I answer to the best of my knowledge.
I'm by no means an expert on either Xtext or GMF-based tools, so take what I say with a grain of salt, but I gathered at least some knowledge during the last weeks.

As you probably know, Xtext relies on the EMF, i.e. creates an Ecore model for every grammar to then work with its nodes.
Eugenia (in this case, but other GMF tools too, as far as I know) also uses that model, but takes it in another direction to create a graphical view for it.
So I think the connection between Xtext and Eugenia is more or less only indirect via the Ecore model.

As for your error, I'll take a guess and say it's caused by an erroneous annotation.
Re: Xtext Graphical View [message #1037978 is a reply to message #1037944] Wed, 10 April 2013 08:45 Go to previous messageGo to next message
Mårten Carlzon is currently offline Mårten CarlzonFriend
Messages: 60
Registered: March 2013
Location: Sweden
Member

Feeling responsible for eating your post so... sorry.
(I blame that I am new to forums find it easier to continue in an existing thread then beginning a new one Smile)

-

Have no problem with you answering my question, it explains a lot of the structure so I don't mind.
And now I know a bit more what to look for so thanks for the reply, and if I get more questions I will start a new thread Smile
Re: Xtext Graphical View [message #1041225 is a reply to message #1036564] Sun, 14 April 2013 20:43 Go to previous messageGo to next message
serhat gezgin is currently offline serhat gezginFriend
Messages: 240
Registered: January 2013
Location: Izmir
Senior Member
Hi,

it worked fine but when i create element from .mydsl file my eclipse give me

Conflicting handlers for org.eclipse.ui.edit.text.contentAssist.proposals:
{ActionHandler(org.eclipse.ui.texteditor.ContentAssistAction@3aa0b6d7)} vs
{org.eclipse.xtext.ui.editor.handler.ContentAssistHandler@264af45e} error.

But anyway it works. U know why this error have been occured ?

Regards,
Re: Xtext Graphical View [message #1041646 is a reply to message #1041225] Mon, 15 April 2013 11:14 Go to previous messageGo to next message
Claudio Heeg is currently offline Claudio HeegFriend
Messages: 75
Registered: April 2013
Member
This was a bug [1] in Xtext 2.3.1.
It has been fixed in the recent release, 2.4.0.

--
[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=390173
Re: Xtext Graphical View [message #1041684 is a reply to message #1041646] Mon, 15 April 2013 12:12 Go to previous messageGo to next message
serhat gezgin is currently offline serhat gezginFriend
Messages: 240
Registered: January 2013
Location: Izmir
Senior Member
Thanks now it fixed Smile

And i want to ask u,

u know how to make embedded xtex in GMF like on properties view

or right click on content of diagram ?

Regards

[Updated on: Mon, 15 April 2013 12:14]

Report message to a moderator

Re: Xtext Graphical View [message #1041951 is a reply to message #1041684] Mon, 15 April 2013 20:18 Go to previous messageGo to next message
d 627 is currently offline d 627Friend
Messages: 28
Registered: March 2013
Junior Member
Ok I've been having all the possible problems to reproduce this example. I just follow all the steps that Dimitris wrote but for some reason, even when diagram package is creating correctly, when I launch the new Eclipse Application I don't see the option for initialize the diagram file.
I've been looking for all the possible explanation but nothing until now.

[Updated on: Tue, 16 April 2013 12:11]

Report message to a moderator

Re: Xtext Graphical View [message #1041972 is a reply to message #1041951] Mon, 15 April 2013 20:52 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 913
Registered: July 2009
Senior Member
Hi Daniel,

The file extension for the "Initialize XYZ Diagram" menu item is specified through an extension to the "org.eclipse.ui.popupMenus" extension point in plugin.xml of your .diagram project. To change it, you need to change the value of its nameFilter attribute.

Cheers,
Dimitris
Re: Xtext Graphical View [message #1042421 is a reply to message #1041972] Tue, 16 April 2013 12:11 Go to previous messageGo to next message
d 627 is currently offline d 627Friend
Messages: 28
Registered: March 2013
Junior Member
Once again thanks a lot Dimitris, that was the solution for my problem. Now finally I can begin with my homework.
Re: Xtext Graphical View [message #1053039 is a reply to message #1042421] Thu, 02 May 2013 07:37 Go to previous messageGo to next message
serhat gezgin is currently offline serhat gezginFriend
Messages: 240
Registered: January 2013
Location: Izmir
Senior Member
Hi all

I use this steps and my senchronization work perfect but when i generate my first

diagram from xtext program i always get error (error log attached as a error.txt file)

(But only first iteration i get this error on second or later iteration i dont get this error.)

and there is another problem is i can't create diagram file. I must create xtext program file and then i must genereate diagram file. So i want to ask u how can i create diagram file independently from xtext resource ?

first part of error ;

!ENTRY org.eclipse.osgi 2 0 2013-04-21 01:42:55.171
!MESSAGE The activator org.eclipse.gmf.examples.runtime.diagram.decorator.DecoratorPlugin for bundle org.eclipse.gmf.examples.runtime.diagram.decorator is invalid
!STACK 0
org.osgi.framework.BundleException: The activator org.eclipse.gmf.examples.runtime.diagram.decorator.DecoratorPlugin for bundle org.eclipse.gmf.examples.runtime.diagram.decorator is invalid
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleActivator(AbstractBundle.java:172)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:679)
	at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:300)
	at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:440)
	at org.eclipse.osgi.internal.loader.BundleLoader.setLazyTrigger(BundleLoader.java:263)
	at org.eclipse.osgi.framework.internal.core.BundleHost.loadClass(BundleHost.java:236)
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadClass(AbstractBundle.java:1212)
	at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:174)
	at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:905)
	at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
	at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:55)
	at org.eclipse.gmf.runtime.common.core.service.Service$ProviderDescriptor.getProvider(Service.java:158)
	at org.eclipse.gmf.runtime.diagram.ui.internal.services.decorator.DecoratorService$ProviderDescriptor.provides(DecoratorService.java:72)
	at org.eclipse.gmf.runtime.common.core.service.Service.safeProvides(Service.java:859)
	at org.eclipse.gmf.runtime.common.core.service.ExecutionStrategy.getUncachedProviders(ExecutionStrategy.java:254)
	at org.eclipse.gmf.runtime.common.core.service.Service.getProviders(Service.java:537)
	at org.eclipse.gmf.runtime.common.core.service.ExecutionStrategy$4.execute(ExecutionStrategy.java:178)
	at org.eclipse.gmf.runtime.common.core.service.Service.execute(Service.java:651)
	at org.eclipse.gmf.runtime.diagram.ui.internal.services.decorator.DecoratorService.createDecorators(DecoratorService.java:121)
	at org.eclipse.gmf.runtime.diagram.ui.editpolicies.DecorationEditPolicy.refresh(DecorationEditPolicy.java:184)
	at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart$3.run(GraphicalEditPart.java:858)
	at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.runExclusive(TransactionalEditingDomainImpl.java:328)
	at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.refresh(GraphicalEditPart.java:851)
	at org.eclipse.gef.editparts.AbstractEditPart.addNotify(AbstractEditPart.java:253)
	at org.eclipse.gef.editparts.AbstractGraphicalEditPart.addNotify(AbstractGraphicalEditPart.java:223)
	at org.eclipse.gef.editparts.AbstractEditPart.addChild(AbstractEditPart.java:212)
	at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.addChild(GraphicalEditPart.java:1319)
	at org.eclipse.gef.editparts.AbstractEditPart.refreshChildren(AbstractEditPart.java:781)
	at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.handleNotificationEvent(GraphicalEditPart.java:1464)
	at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.notifyChanged(GraphicalEditPart.java:1438)
	at org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBroker.fireNotification(DiagramEventBroker.java:504)
	at org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBroker.resourceSetChanged(DiagramEventBroker.java:399)
	at org.eclipse.gmf.runtime.diagram.ui.DiagramEventBrokerThreadSafe.resourceSetChanged(DiagramEventBrokerThreadSafe.java:73)
	at org.eclipse.gmf.runtime.diagram.core.DiagramEditingDomainFactory$DiagramEditingDomain.postcommit(DiagramEditingDomainFactory.java:214)
	at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.deactivate(TransactionalEditingDomainImpl.java:543)
	at org.eclipse.emf.transaction.impl.TransactionImpl.close(TransactionImpl.java:712)
	at org.eclipse.emf.transaction.impl.TransactionImpl.commit(TransactionImpl.java:474)
	at org.eclipse.emf.workspa
.
.
.
.


But only one i get this error on second or later iteration i dont get this error.

Anyone can help me to solve this eror ?

Regards
  • Attachment: error.txt
    (Size: 82.37KB, Downloaded 75 times)

[Updated on: Thu, 02 May 2013 10:16]

Report message to a moderator

Re: Xtext Graphical View [message #1053155 is a reply to message #1053039] Thu, 02 May 2013 18:18 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 913
Registered: July 2009
Senior Member
Hi,

Please have a look at the Overview tab of org.eclipse.gmf.examples.runtime.diagram.decorator's plugin.xml and make sure that it points to a valid Activator.

Cheers,
Dimitris
Re: Xtext Graphical View [message #1053218 is a reply to message #1053155] Fri, 03 May 2013 08:08 Go to previous messageGo to next message
serhat gezgin is currently offline serhat gezginFriend
Messages: 240
Registered: January 2013
Location: Izmir
Senior Member
Hi,

Thanks for answer.

i look org.eclipse.gmf.examples.runtime.diagram.decorator's plugin.xml and i see ;

Bundle-Activator: org.eclipse.gmf.examples.runtime.diagram.decorator.DecoratorPlugin

is it true ? dont know How can I be sure

Regards
Re: Xtext Graphical View [message #1053736 is a reply to message #1053155] Tue, 07 May 2013 12:35 Go to previous message
serhat gezgin is currently offline serhat gezginFriend
Messages: 240
Registered: January 2013
Location: Izmir
Senior Member
Hi,

problem fixed, when i get update and recreate project. But now i have another problem

too I make new project (with synchronization steps) and then i write epsilon evl for

model validation it works perfect. But gmf error occured on diagram and xtext file

(separately) and evl quick fixed dont run on xtext file. Because of this i want error

and warnings dont occure on xtext file. How can i done this ? Anyone can help me ?

Just i want to write aperate error and warning for xtext file and gmf diagram

(sample scenario on attached picture.)

Regards

Previous Topic:EuGENia Annotations
Next Topic:Qualified names on referance labels
Goto Forum:
  


Current Time: Sat Nov 29 09:09:46 GMT 2014

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

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