Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Defining and instantiating shapes using GMF editor
Defining and instantiating shapes using GMF editor [message #218314] Wed, 11 February 2009 20:09 Go to next message
Venkanna is currently offline VenkannaFriend
Messages: 2
Registered: July 2009
Junior Member
Hi,
I am a newbee to the Eclipse world and GMF. I am trying to create an
editor where user will be able to define shapes and instantiate them later
as objects (like Nodes).

The usecase is, for logic example, I would like to provide the ability
to the user to define complex shape objects and its ports in one editor
(like NAND NOR gate shapes) and later instantiate the defined
figures/shapes in another editor. The domain model for the both editor is
assumed to be common.

My run-time object model would be something like the following:

Root
|_ Object A - 1
|_ Object A - 2
|_ Object B - 1
|_ Instance of Object A -1
|_ Instance of Object A -2
|_ Object B - 2
|_ Instance of Object A -1
|_ Instance of Object A -2

Object of type A is defined by one kind of editor. Each object should
open an editor.
Object of type B is defined by another kind of editor. Each object should
open a different editor

In this regard, I have several difficulties to achieve what I want.

1) Multiple diagrams having same domain model (There are already some
posts regarding this like
http://wiki.eclipse.org/GMF_Tips#Sharing_single_EditingDomai n_instance_across_several_diagrams.
I wil try them)

2) Defining Shapes
2.1 ) I could not find the support for an arc figure in gmfgraph
defintion. How can I define arc shapes?

3) How to instantiate the defined object in other editor? Is there
anything I can do at the modeling level. If I have achieve this by writing
the code, can someone help out with clues on what to change?

4) Also I would like to maintain all of diagram data in the domain model
itself and have figures updates based on the attributes of domain model
objects. Is this kind of usecase supported by GMF modeling?

Thanks in Advance.

Regards,
Venkanna
Re: Defining and instantiating shapes using GMF editor [message #218433 is a reply to message #218314] Thu, 12 February 2009 11:41 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Venkanna,

> 2.1 ) I could not find the support for an arc figure in gmfgraph
> defintion. How can I define arc shapes?
You can always create regilar draw2d figure and plug it into the .gmfgraph
using CustomFigure.

> 3) How to instantiate the defined object in other editor? Is there
> anything I can do at the modeling level. If I have achieve this by
> writing the code, can someone help out with clues on what to change?
In this place I do not understand you completely. Do you want to create new
meta-object (EClass instance) and then instantiate this meta-object (create
corresponding EObject referencing this EClass) or are you just going to open
sub-diagram visualizing internal structure of the “defined object”?

> 4) Also I would like to maintain all of diagram data in the domain
> model itself and have figures updates based on the attributes of
> domain model objects. Is this kind of usecase supported by GMF
> modeling?
It should be possible with GMF. There is an option in .gmfgen model switching
between different and same file for domain and diagram modes. Concerning
figures update – you have to create several mappings with appropriate constraints
+ call diagram update then corresponding attribute was changed (using the
custom code).

-----------------
Alex Shatalin
Re: Defining and instantiating shapes using GMF editor [message #219169 is a reply to message #218433] Wed, 18 February 2009 13:27 Go to previous messageGo to next message
Venkanna is currently offline VenkannaFriend
Messages: 2
Registered: July 2009
Junior Member
Thanks Alex for your responses. Please see my comments below...

Alex Shatalin wrote:


>> 3) How to instantiate the defined object in other editor? Is there
>> anything I can do at the modeling level. If I have achieve this by
>> writing the code, can someone help out with clues on what to change?
> In this place I do not understand you completely. Do you want to create new
> meta-object (EClass instance) and then instantiate this meta-object (create
> corresponding EObject referencing this EClass) or are you just going to open
> sub-diagram visualizing internal structure of the “defined object”?

In my case, I have two classes (EClass objects) Symbol and Instance. I
also have two kind of diagrams. Diagram-1 is used to define a shape Symbol
object (e.g., NAND gate shape with two inputs and one output). An Instance
object is created from Symbol object using its graphics shapes and ports
(much like a copy of an object. However Symbol represents a diagram and
Instance is like a Node). In Diagram-2, User should be able to select a
symbol object and place an Instance object corresponding to the Symbol
object.

In this regard, what I am struggling here is that, the graphics data for
Symbol object is stored in a diagram file. I should somehow access the
diagram data and create an Instance object which contains the same graphic
shapes and ports.

One way I thought was to put the diagram data (shapes properties,
coordinates) as a part of the domain data model. Hence I asked the below
question. Do you see any other way I can achieve what I wanted?

Symbol has a set of graphics and ports (
>> 4) Also I would like to maintain all of diagram data in the domain
>> model itself and have figures updates based on the attributes of
>> domain model objects. Is this kind of usecase supported by GMF
>> modeling?
> It should be possible with GMF. There is an option in .gmfgen model
switching
> between different and same file for domain and diagram modes. Concerning
> figures update – you have to create several mappings with appropriate
constraints
> + call diagram update then corresponding attribute was changed (using the
> custom code).

I used the Same File for Diagram and Model option in gmfgen. Basically it
keeps both diagram and domain model in the same file instead of two files.
However what I wanted is single model which also contains graphics data.
Are you saying this is possible with GMF? If so, could you please explain
with more details? For example, I have a simple domain model for shapes
(like circle, rectangle), Can I generate GMF based editor such that all
the graphical data is stored in the domain model (The Ecore domain
model)itself .
Re: Defining and instantiating shapes using GMF editor [message #219466 is a reply to message #219169] Fri, 20 February 2009 11:27 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Venkanna,

> In my case, I have two classes (EClass objects) Symbol and Instance. I
> also have two kind of diagrams. Diagram-1 is used to define a shape
> Symbol object (e.g., NAND gate shape with two inputs and one output).
> An Instance object is created from Symbol object using its graphics
> shapes and ports (much like a copy of an object. However Symbol
> represents a diagram and Instance is like a Node). In Diagram-2, User
> should be able to select a symbol object and place an Instance object
> corresponding to the Symbol object.
Well, this use case is not covered in GMF now. So you can definitely generate
come code with GMF and then you have to modify this code significantly.

> In this regard, what I am struggling here is that, the graphics data
> for Symbol object is stored in a diagram file. I should somehow access
> the diagram data and create an Instance object which contains the same
> graphic shapes and ports.
You can do it - graphical data is stored by EMF, so you can use EMF to load
it (get instances of GMF notation model) and use it to access actual data.

> below question. Do you see any other way I can achieve what I wanted?
No - your plan to create this kind of diagram looks good.

> I used the Same File for Diagram and Model option in gmfgen. Basically
> it keeps both diagram and domain model in the same file instead of two
> files. However what I wanted is single model which also contains
> graphics data. Are you saying this is possible with GMF? If so, could\
It is possible, but you have to be ready to modify generated code (or code
generation templates) a lot.

> you please explain with more details? For example, I have a simple
> domain model for shapes (like circle, rectangle), Can I generate GMF
> based editor such that all the graphical data is stored in the domain
You can not genrate it with GMF now. You have to modify code/better - templates
for it. As a starting point you can have a look on org.eclipse.gmf.graphdef.editor
plugin - this is WYSIWYG diagram editor for GMF graphical model, so it solves
nearly the same problem.

-----------------
Alex Shatalin
Previous Topic:Large Diagrams & GMF
Next Topic:Problems with Duplicate action
Goto Forum:
  


Current Time: Mon Mar 01 06:51:40 GMT 2021

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

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

Back to the top