Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Using a custom figure for a container
Using a custom figure for a container [message #482867] Fri, 28 August 2009 11:46 Go to next message
Eclipse UserFriend
Originally posted by: cedric.moonen.fmtc.be

Hello,

I need to be able to create a diagram node which will contain two
compartments. These two compartments should use a custom figure to render
themselves (two different custom figures).

So, I created two "Figure Descriptor" (one for each compartment) in the
gmfgraph file. They both have a child "Custom Figure" which indicates my
custom figure.
I then created two new compartments under the Canvas and set the "Figure"
property to the correct "Figure Descriptor" that I just created.

In the gmfmap file, I create a "Top Node Reference" and add two
compartment mappings with the "Compartment" property set to the correct
compartment of my gmfgraph.

The problem is that the generated code doesn't use my custom figures for
the compartments: when I run the application, my node contains two
compartments which behave as expected for the addition of children but
they are just the default rectangles. Looking at the generated code I also
realized that my two custom figures are never used (I searched for the
class name and it is not use anywhere in the generated code).

Is this a bug, or I am misunderstanding the concept of compartments ?

Thanks
Cédric
Re: Using a custom figure for a compatment [message #482920 is a reply to message #482867] Fri, 28 August 2009 14:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cedric.moonen.fmtc.be

After searching for a while, I realized that maybe my approach using
compartments is maybe not the most adapted one.
Let me try to explain my problem from a higher point of view:

I need to have a top node figure containing two other figures (not diagram
nodes at this level). Those two figures are custom figures. The user will
be able to create children diagram nodes in both of these figures (or
compartment).

I was able to have two compartments in which I can add the children nodes
but the compartments are standard compartments and I really need to draw
the compartment myself using a custom figure (and using a particular
layout manager inside the compartment).

Is there a different way to do that than using compartments ?

Thanks
Cédric
Re: Using a custom figure for a compatment [message #482924 is a reply to message #482920] Fri, 28 August 2009 14:45 Go to previous messageGo to next message
Artur Kronenberg is currently offline Artur KronenbergFriend
Messages: 159
Registered: August 2009
Senior Member
Hi Cedric,

To me it sounds like you need nodes that are used like the diagram
(drawing in them, moving around the nodes, having connections etc.).

compartments will work for that. When you generate your editor, in the
graph you can specify a specific figure, so you will have your own figure
there. You can mark that one as a compartment. I think you still need to
specify a flow layout on that figure.

When you have your gmfgen file you need to go into the "Gen Diagram
XXXEditPart" and into your compartment. There is an atribute "List
Layout". If you set that to false your node compartment will handle the
incoming nodes like the diagram itself or in a similar way.

Hope that helps.

Best regards,
Artur

Cédric wrote:

> After searching for a while, I realized that maybe my approach using
> compartments is maybe not the most adapted one.
> Let me try to explain my problem from a higher point of view:

> I need to have a top node figure containing two other figures (not diagram
> nodes at this level). Those two figures are custom figures. The user will
> be able to create children diagram nodes in both of these figures (or
> compartment).

> I was able to have two compartments in which I can add the children nodes
> but the compartments are standard compartments and I really need to draw
> the compartment myself using a custom figure (and using a particular
> layout manager inside the compartment).

> Is there a different way to do that than using compartments ?

> Thanks
> Cédric
Re: Using a custom figure for a compatment [message #483093 is a reply to message #482924] Mon, 31 August 2009 06:50 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cedric.moonen.fmtc.be

Hello Artur,

Thanks for your reply. Unfortunately I'm very new to GMF and I didn't
really understand your reply. I'm having trouble with the part "You can
mark that one as a compartment". I didn't find anything like the ability
to specify that a figure is a compartment. The only thing that comes close
is to create a compartment node and specify a figure in the "Figure"
property. But then, as explained in my first message, the figure seems to
be unused and the default compartment is used instead.

Thanks
Cédric
Re: Using a custom figure for a container [message #483145 is a reply to message #482867] Mon, 31 August 2009 10:57 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Cédric,

Unfortunately compartment support in GMF cannot be completely generated right
now, so you'll always see default compartment figure representing compartment..
What you can do is:
- Create Node figure having custom figure you've created for a compartment
inside
- create one mode "rectangle" child of this custom figure as a placeholder
for the compartment figure
- use this rectangle as a figure for the compartment

as a result the following figure structure will be created by GMF
- Node Figure
- CustomFigureForTheCompartment
- Rectangle-placeholder for GMF compartment figure
- GMF compartment figure

I believe this workaround will probably solve your problems because usually
you just need to represent compartment in some special way which you can
do by placing compartment figure into the custom one.

-----------------
Alex Shatalin
Re: Using a custom figure for a container [message #483157 is a reply to message #483145] Mon, 31 August 2009 12:07 Go to previous messageGo to next message
Cedric Moonen is currently offline Cedric MoonenFriend
Messages: 274
Registered: August 2009
Senior Member
Hello Alex,

Thanks for your reply. However, I can't get to a working solution. Let me first re-explain what I'm trying to do by showing you an image.

http://free0.hiboox.com/images/3609/6320b62d192cdebca3514c3bff27cd10.bmp

You can see that my top-level node is made of three "areas":
- a header in which some custom drawing will be made
- a main compartment in which I have a column with some text and custom drawing and a part where children are added
- a secondary compartment which contain a column and only one child

I really need to have full control of my layout and sizing, so I don't want any scroll bar from the compartment.

If I try to follow your advice, here iswhat I have for the structure in the gmfgraph:
- Canvas
    - Figure Gallery
        - Figure Descriptor MainFigure
            - Custom Figure MainFigure
                - Custom Figure MainCompartment
                    - Rectangle CompartmentPlaceholder
        - Figure Descriptor MainCompartment
            - Figure Ref (Points to the CompartmentPlaceholder)
    - Compartment (Points to the Figure Descr of the compartment).


To simplify the example and trying to find a solution, I deliberately ignored the secondary compartment.

It doesn't work as expected (well, as I was expecting Wink ) because if I debug, I see that my top-level node is created correctly but if I look at its children, it has the custom figure for my compartment as direct child (which is fine) and a ShapeCompartmentFigure (which is not fine). The custom figure has a height of 0 (so, it is not visible) and whenever I am adding children, they are added to the ShapeCompartmentFigure and I want them to be children of my custom figure.

In fact, I am using compartments only because it seems to be the only way to be able to add children in two different areas of my figure.
If I would be able to use figures and to specify that some children have to be contained in a figure, this would probably be a better solution.

Do you have any idea how I can end-up with something like that ? Or do you think this is impossible ?

Thanks
Cédric
Re: Using a custom figure for a container [message #483368 is a reply to message #483157] Tue, 01 September 2009 11:28 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello c,

To make Rectangle CompartmentPlaceholder a child of Custom Figure MainCompartment
you need to:
- Create CustomFigure representing MainCompartment
- Create FigureAccessor and specify method name (getter) of Cuspom figure
to get appropriate content pane
- Create below FigureAccessor new real figure representing return type of
this method
- Create Rectangle CompartmentPlaceholder below this figure or just use this
figure
- Create Child Access below Figure descriptor referencing either CompartmentPlaceholder
or "this" figure itself
- Use this Figure Descriptor MainFigure as a compartment figure and specify
created above ChildAccess as an accessor for this compartment.

-----------------
Alex Shatalin
Re: Using a custom figure for a container [message #483589 is a reply to message #483368] Wed, 02 September 2009 09:14 Go to previous messageGo to next message
Cedric Moonen is currently offline Cedric MoonenFriend
Messages: 274
Registered: August 2009
Senior Member
Hello Alex,

Once again, thanks for you reply (and your patience). I'm sorry but I
can't really get to a satisfactory solution. Everything I tried ended up
with having a real compartment in which to add my children, not my custom
figure (and so, a XY layout with toolbars).

Let me explain my problem using a different approach, without talking
about compartments. What I need to have is a custom figure which contains
two areas (let's call them that way, not to confuse it with GMF
compartments). These two areas can accept children (the user creates a new
node and put it in one of these areas). These two areas are custom classes
which let me specify my own layout manager and draw some custom
information in them.

So, ideally, the generated code should follow a bit this hierarchy: a base
figure (IFigure) for the full node which contains two child figures (being
my custom figures). Both of these figures will contain children figures
(which are related to other diagram nodes).

That's what I'm trying to achieve. It doesn't sound like an impossible
task but I've been unable to find a satisfactory solution for that. Is
there a way to reach that with or without using compartments ? It seems
that compartments add a layer of complexity which doesn't allow me to have
full control over the layout.

Thanks a lot
Cédric
Re: Using a custom figure for a container [message #483818 is a reply to message #483589] Thu, 03 September 2009 08:24 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Cédric,

> That's what I'm trying to achieve. It doesn't sound like an impossible
> task but I've been unable to find a satisfactory solution for that. Is
> there a way to reach that with or without using compartments ? It
> seems that compartments add a layer of complexity which doesn't allow
> me to have full control over the layout.
This is right. Yuo cannot get rid of compartment figure/layout unless you
use it.
The only way for now is to modify generated code in order to not use standard
compartment figures.
So, I suggest you to generate code with two compartments and then modify
generated EditParts to use your custom figures.
This modification will not be simple - some EritPolicies should be modified
as well, but it is definitly possible to implement functionality you requested,
so you need to debug GEF/Draw2d code and modify it..

-----------------
Alex Shatalin
Previous Topic:Create EditPart from ModelExplorer view
Next Topic:Use image in FigureDescriptor
Goto Forum:
  


Current Time: Sat Jul 27 10:42:19 GMT 2024

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

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

Back to the top