Using a custom figure for a container [message #482867] |
Fri, 28 August 2009 07:46  |
Eclipse User |
|
|
|
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 container [message #483157 is a reply to message #483145] |
Mon, 31 August 2009 08:07   |
Eclipse User |
|
|
|
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.

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 ) 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 #483818 is a reply to message #483589] |
Thu, 03 September 2009 04:24  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.04380 seconds