Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Text to Graph editor
Text to Graph editor [message #75357] Tue, 07 November 2006 10:34 Go to next message
Eclipse UserFriend
Originally posted by: Laph95.gmail.com

Hi all !

My problem is a bit complex I assume because I don't find anything on the
Internet (or anywhere else) to help me.

I'm currently realizing a project which is actually an RCP application. My
application is an editor for a language developed in my company.
This language have to be edited in a textual way but also in a graphical
way.

In a first time I want to convert my "textual" file in a "graphical" file.
This way, I want to use GMF. So I designed an EMF model, then all the
steps to GMF generated code. My editor is actually operational (i.e. I can
draw my forms, etc.) but is independant from the text file.
What I want to do now is to "link" the text to the graphic.
More precisely I want to parse a text source code file, and then
automatically generate a graph file which represents the source code in a
graphical style (with colors, lines, Rectangles, etc :). I don't have
example of existing application of that kind... So :

I have an ANTLR parser for my own language.
I have my EMF model.
I have GMF code generated.
I have much motivation :)

But I still don't know how to begin to draw automatically my graphical
view from my textual view.
If someone even know how I can do that (if it is possible) or just a link
to a website which could help me...

Thanks a lot (and all apologies for my approximative english) !!
Re: Text to Graph editor [message #75408 is a reply to message #75357] Tue, 07 November 2006 10:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Laph,

Part of what you'll need is a resource implementation that can read and
write your text file to and from an instance of your Ecore model. To
accomplish this, you should probably derive directly from ResourceImpl
and implement the doLoad and doSave methods to parse your text file and
to print to your text file. Once you've implemented this, then the rest
of GMF should just fit in nicely since the diagram can be a separate
resource that acts as a view of a model stored separately in your text
file and hence your text file will effectively act as an alternative
serialization format for the XMI/XML serialization EMF typically produces.


Laph wrote:

> Hi all !
>
> My problem is a bit complex I assume because I don't find anything on
> the Internet (or anywhere else) to help me.
>
> I'm currently realizing a project which is actually an RCP
> application. My application is an editor for a language developed in
> my company.
> This language have to be edited in a textual way but also in a
> graphical way.
>
> In a first time I want to convert my "textual" file in a "graphical"
> file.
> This way, I want to use GMF. So I designed an EMF model, then all the
> steps to GMF generated code. My editor is actually operational (i.e. I
> can draw my forms, etc.) but is independant from the text file.
> What I want to do now is to "link" the text to the graphic.
> More precisely I want to parse a text source code file, and then
> automatically generate a graph file which represents the source code
> in a graphical style (with colors, lines, Rectangles, etc :). I don't
> have example of existing application of that kind... So :
>
> I have an ANTLR parser for my own language.
> I have my EMF model.
> I have GMF code generated.
> I have much motivation :)
>
> But I still don't know how to begin to draw automatically my graphical
> view from my textual view.
> If someone even know how I can do that (if it is possible) or just a
> link to a website which could help me...
>
> Thanks a lot (and all apologies for my approximative english) !!
>
Re: Text to Graph editor [message #75424 is a reply to message #75357] Tue, 07 November 2006 11:05 Go to previous messageGo to next message
Eclipse UserFriend
Hello Laph,

I suggest you to try implementing Resource.Factory interface and register
corresponding implementation file extension used to store this textual language:

<extension point="org.eclipse.emf.ecore.extension_parser">
<parser
type="<fileExtension>"
class="<F.Q.NameOfResourceFactory>">
</parser>
</extension>

This resource factory implementation have to parse corresponding textual
file using existing parser and return Resource implementation containing
EMF model you’ve mentioned. As a result generated diagramming code will be
able to initialize diagram file using existing textual representation of
the model.

-----------------
Alex Shatalin
Re: Text to Graph editor [message #75643 is a reply to message #75424] Wed, 08 November 2006 04:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Laph95.gmail.com

First of all thank you for your answers...

Then I think I did a little mistake in my project description : I'd have
say "graphical view" instead of "graphical file".

I'll try to explain graphically what I want to do...

Input : I have a source code file which represents automata (some kind of
statecharts compared to UML format). Of course the language is composed by
states and links between states. I have an ANTLR parser for this language
(which have a textual format), I also have an eCore model and all I
explained in my first post.
For exemple, the input language looks like that :

state A
to B
...
endstate A

state B
...
endstate B

Output : I want to draw a view corresponding to my input file.
For exemple, I'd like to realize such a view (of course including colors,
forms, etc) :

------- t -------
| A |---------->| B |
------- -------

Whete 'A' and 'B' are visual reprentations of states and 't' visual
representations of links between states.

So I have the eCore model and I think I have to implement this model by
parsing my input file.
I also think GMF is able to draw the graphical view from my generated
eCore model but I still don't know HOW GMF could do that (are there
dedicated methods ??).

To resume all of that, I have input and output but I really don't know how
to realize all of that.
Maybe this little draw will resume all the thing :

A -------> B -------> C

Where 'A' is my input source code (textual file), 'B' is my eCore model
generated by parsing 'A', and 'C' is the graphical view I want to
visualize in the end.
My main problem is the two links... What I have to do ? Which way is the
best one to realize such a thing ?

I wish this post is more precise than the first one.

Thanks again for your answers !
Re: Text to Graph editor [message #75659 is a reply to message #75643] Wed, 08 November 2006 05:17 Go to previous messageGo to next message
Eclipse UserFriend
Hello Laph,

> Then I think I did a little mistake in my project description : I'd
> have say "graphical view" instead of "graphical file".

So, you need something like .gif with the picture of the diagram inside?
GMF can export diagrams to image.

> A -------> B -------> C
> Where 'A' is my input source code (textual file), 'B' is my eCore
> model
> generated by parsing 'A', and 'C' is the graphical view I want to
> visualize in the end.

1. You have to design end generate GMF diagram for your ecore metamodel (B
is an instance of this metamodel) As a result you’ll get BC arrow for free.
2. Most interesting question is how to parse textual file and produce EMF
model as an output (A  B). AFAIU you already have some parser for this textual
notation. I suggest you to modify this parser to produce B as a result of
parsing A and then you’ll cover all the steps on the way AC.

I suggest you to start with creating GMF diagram working with B stored in
XMI. Once this diagram will be finished, you can start with parsing A and
producing B and finally you can read my prev. posting and following the suggestions
from those posting you’ll get all A C steps automatically. In other words,
as a result your diagram will be based on diagram file containing diagram
information and domain file containing semantic elements stored in appropriate
textual syntax. AFAIU, this is what you’d like to get. Please, correct me
if I’m wrong.

-----------------
Alex Shatalin
Re: Text to Graph editor [message #75710 is a reply to message #75659] Wed, 08 November 2006 05:59 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Laph95.gmail.com

Thanks for your precise answer, it's clearer for me now...

Nevertheless the only thing which is always actually blur in my mind is
the B to C arrow.
You explain this is a kind of "free" arrow but in my case, I think it's a
problem for me.

Effectively, my eCore model is really simple : only one class and some
attributes because in our language, everything IS this class. I.d. a
state's kind is that class, transitions' kind is that class, etc.
Only attributes allow me to get the differences between the states (for
example INIT state, FINAL state, SIMPLE state, COMPOSITE state, etc.).

So I'm wondering how I can get a good graphical view (with good forms
drawn on it) with attributes for only basement ?
Thanks to GMF, I have a mapping which explain relationship between the
elements in the view but I don't know how to be sure I'll get the good
element drawn in the view if I have one and only one class in my
metamodel...
Is there a solution to get a element in the view corresponding to an
attribute of my unique class ?

So what I actually want is to open a GMF graphic view with an instance of
my eCore model for only argument (it's the same procedure than a text
editor's opening with the file's name as argument).

I wish what I mean is clear because it's a big project and it isn't easy
to explain such things quickly and clearly.
Thanks a lot for your help !!
Re: Text to Graph editor [message #75743 is a reply to message #75710] Wed, 08 November 2006 06:34 Go to previous messageGo to next message
Eclipse UserFriend
Hello Laph,

First, you can change your metamodel and introduce more metalcasses there.
;-)
Second, you can use constraints in mapping to destinguish between different
instances of the same EClass with different values of this "metaclass" attribute.
So, it is possible. ;-)

You to take your metamodel and generate a diagram for it. GMF tutorials could
be useful to gather some practical information.

-----------------
Alex Shatalin
Re: Text to Graph editor [message #75759 is a reply to message #75743] Wed, 08 November 2006 08:04 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Laph95.gmail.com

Hi Alex,

First : This solution is impossible because my hierarchy refuse such a
method

Second : Ok for the constraints way, I'll try it now.

Third : Is there a specific way to get a graphical view from my eCode
model instance ? You said it's "free" but I still don't know how. My
question about this link is still active. Is there a method to call in my
GMF editor factory ? Is it really automatic ? I can't represent myself how
GMF will realize the view from my model instance without a command ?

Do you know if such applications already exist ? I've searched on Eclipse
Plugin Directory but I haven't found anything which looks like mine.
Otherway is there any help on GMF/EMF wherever (books, Internet, etc.) ?
You seem to control that technology so I misuse a little of your science :)
Re: Text to Graph editor [message #75793 is a reply to message #75759] Wed, 08 November 2006 09:18 Go to previous messageGo to next message
Eclipse UserFriend
Hello Laph,

> Third : Is there a specific way to get a graphical view from my eCode
> model instance ? You said it's "free" but I still don't know how. My
> question about this link is still active. Is there a method to call in
> my GMF editor factory ? Is it really automatic ? I can't represent
> myself how GMF will realize the view from my model instance without a
> command ?

Sure, you have to “initiate” this process. GMF will generate ???InitDiagramFileAction
for you so you’ll be able to create new diagram using existing model file
(stored in XMI or in text once you’ll implement corresponding ResourceFactory)
by executing this popup menu action. If you need to create diagram from the
code you can take a look on the generated action and write corresponding
piece of code somewhere in your system (another UI action or kind of resource
listener or ...)

In general this action will take existing model file and create diagram reflecting
contents of this file with kind of default layout.

> Do you know if such applications already exist ? I've searched on

No, I do not know anything about this kind of applications but default EMF
serialization (XMI) is just one way to store EMF models. EMF provides you
with the possibility to store model into any kind of syntax and this is proven
solution. GMF in this schema is just interacting with EMF API and leverage
corresponding features of EMF. Concerning the diagramming itself – you can
take a look on existing samples – again, your diagram looks rather simple
and similar to all the rest of GMF-based diagrams. So, I do not see any problems
in implementing this application. The most tricky part in text parser I’d
say. ;-)

-----------------
Alex Shatalin
Re: Text to Graph editor [message #75845 is a reply to message #75793] Wed, 08 November 2006 10:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Laph95.gmail.com

Thanks for your precisions.

I'll begin to fill my parser to instanciate my eCore model. From there I
spear I'll can draw something correctly in my view.

I think the "parser work" isn't the hardest part of my work I think or the
last part is actually as easy as you've said.

First I have to learn more about constraints because I don't understand
yet what is OCL and how to use it.
I wish it isn't too hard because it's a big job and I don't have much time
for that.

Thanks again !
Re: Text to Graph editor [message #79108 is a reply to message #75845] Tue, 21 November 2006 05:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Laph95.gmail.com

Hi again !

Since last time I wrote something here, I've progressed a lot...

As I said, I still want to realize a text/graph editor. I finally found a
plug-in (which isn't free, obviously :) corresponding to what I try to do.
You can check a screenshot there :
http://www.gentleware.com/fileadmin/newpics/screenshots_apol lo/apollo_navigation.png

I want to get approximately the same result but the difference is my
graphical part is a kind of UML statechart diagram (and not a UML class
diagram as in the link) and the text part is my own language (and not Java
as in the link).

What I have now is a few more than last time :
I've realized my ANTLR parser which instanciate my eCore model. The
instance is exactly what I want, this part is ok.
In average, I realized a method to serialize my eCore model instance to
XMI file format.

Now when I still don't know how to open "graphically" my XMI file.

When I create a "graphical" file (i.e. I open an editor and I can draw
forms inside), the workspace create automatically 2 files : "default.xxx"
and "default.xxx_diagram".
I've noticed that my XMI file (from my parsing I remind) is approximately
the same "form" than the "default.xxx" file but the graphical view is set
when I open the "default.xxx_diagram" file.

So I want to know how to get the good "default.xxx_diagram" file from my
XMI file.
Maybe GMF generate this itself but I haven't found how to do that.

If somebody can help me ;)
I can give more details if it is required.

Thanks !
Re: Text to Graph editor [message #79427 is a reply to message #79108] Tue, 21 November 2006 11:32 Go to previous messageGo to next message
Eclipse UserFriend
Hello Laph95,

There should be a popup menu action ???InitDiagramFileAction generated and
available on any .xxx files. AFAIU, all you need is to allow this action
for your XMI file (rename it to .xxx and call the action or register this
action for your XMI file extension).

-----------------
Alex Shatalin
Re: Text to Graph editor [message #79892 is a reply to message #79427] Wed, 22 November 2006 05:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Laph95.gmail.com

Ok now I have something :)

The graphical view isn't exactly what I wished but there is probably some
corrections to do in the ANTLR parser and in the GMF mapping.

So I have to search for :

- how to get exactly what I want in my graphical view,
- how to organize clearly different forms in the view,
- how to get the xxxInitDiagramFileAction automatically !

Hundred thanks for your help !
Re: Text to Graph editor [message #80698 is a reply to message #79892] Fri, 24 November 2006 08:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Laph95.gmail.com

This topic helped me a lot for my project so I'll post a little question
again :

Is there an "easy" solution to get a clear diagram after its creation ?
I.e. I get exactly what I want in the graphical view but the different
forms drawn have some overlap (or obstruction) problem.

I just want to know if I can add something in the GMF mapping (or so) to
get some kind of forms "unoverlappable" ?
There's also the connections problem which is the same but with link
forms. I mean the arrows overlap the other forms and I don't want that...

If there's a solution...

Thanks !
Re: Text to Graph editor [message #80801 is a reply to message #80698] Fri, 24 November 2006 17:16 Go to previous message
Eclipse UserFriend
Hello Laph,

No special support for it. Standard layout should be called at the end of
diagram creation, so if it is not called (layouting your diagram manually
will produce different results) - submitt a request. If something is not
layouted correctly - submitt a request for layout subsystem. ;-)


-----------------
Alex Shatalin
Previous Topic:Adding a "design label" to a link
Next Topic:Various grid-related questions
Goto Forum:
  


Current Time: Sun Jun 08 16:21:52 EDT 2025

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

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

Back to the top