Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Compartment layout problem
Compartment layout problem [message #546820] Wed, 14 July 2010 10:27 Go to next message
Gonzalo Ortiz Jaureguizar is currently offline Gonzalo Ortiz JaureguizarFriend
Messages: 4
Registered: March 2010
Junior Member
Hi

I'm making a plugin that allows to design abstracts GUIs with GMF. The
idea is to have a number of widget. Two special widgets that serve as
horizontal and vertical layout (HBox and VBox respectively). I made a
first approach by turning off the listLayout attribute on gmfgen and
using FreeLayout everything seems to work properly. Then I changed the
layout of one of the compartments as this
(http://wiki.eclipse.org/GMF/Recipes) first "recipe" says (I only change
the layout, I don't add the new EditPolicy yet) but the compartment
began to fail and now can not add content.

After a while testing and debugging I discovered that if I add the
content in the model file (the file that does not finish on *_diagram)
or use a "Seq Initializer", the model does contain the correct value,
but *CompartimentEditPart.getModelChildren() returns the empty
collection when it's called inside refreshChildren method. Digging
further, I found that this behavior was because after adding the content
to the model (in this case in HBoxImpl class) is added in the
compartment class, but when it does the generated code assumes that the
compartment is using the free layout and this throws an exception. When
I select the tool that adds an item in to the compartment and I move the
mouse over it the same exception is thrown:

java.lang.ClassCastException: org.eclipse.draw2d.FlowLayout cannot be
cast to org.eclipse.draw2d.XYLayout
at
org.eclipse.gef.editpolicies.XYLayoutEditPolicy.getXYLayout( XYLayoutEditPolicy.java:131)
at
org.eclipse.gef.editpolicies.XYLayoutEditPolicy.getLayoutOri gin(XYLayoutEditPolicy.java:110)
at
org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy.get ConstraintFor(ConstrainedLayoutEditPolicy.java:209)
at
org.eclipse.gmf.runtime.diagram.ui.editpolicies.XYLayoutEdit Policy.getConstraintFor(XYLayoutEditPolicy.java:336)
at
org.eclipse.gmf.runtime.diagram.ui.editpolicies.XYLayoutEdit Policy.getCreateCommand(XYLayoutEditPolicy.java:256)
at
org.eclipse.gmf.runtime.diagram.ui.editpolicies.XYLayoutEdit Policy.getCommand(XYLayoutEditPolicy.java:321)
at
org.eclipse.gef.editparts.AbstractEditPart.getCommand(Abstra ctEditPart.java:470)
at
org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.access$1(GraphicalEditPart.java:1)
at
org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt$1.run(GraphicalEditPart.java:482)
at
org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl.runExclusive(TransactionalEditingDomainImpl.java:313)
at
org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.getCommand(GraphicalEditPart.java:477)
at
org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEdit Policy.getUnspecifiedTypeCreateCommand(CreationEditPolicy.ja va:395)
at
org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEdit Policy.getCommand(CreationEditPolicy.java:85)
at
org.eclipse.gef.editparts.AbstractEditPart.getCommand(Abstra ctEditPart.java:473)
at
org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.access$1(GraphicalEditPart.java:1)
at
org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt$1.run(GraphicalEditPart.java:482)
at
org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl.runExclusive(TransactionalEditingDomainImpl.java:313)
at
org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.getCommand(GraphicalEditPart.java:477)
at org.eclipse.gef.tools.TargetingTool.getCommand(TargetingTool .java:122)
(...)

So... What am I doing wrong? How can I say to GMF that this compartment
will have another layout? I am using Eclipse 3.5.2 and GMF 2.2.

Thank you very much for your help!

Gonzalo
Re: Compartment layout problem [message #546825 is a reply to message #546820] Wed, 14 July 2010 11:02 Go to previous messageGo to next message
emil salageanu is currently offline emil salageanuFriend
Messages: 94
Registered: June 2010
Location: Nice, France
Member
Hi,

I'm also having little problems with compartment layouts at the moment (see my thread http://www.eclipse.org/forums/index.php?t=msg&th=171856& amp;start=0&).

I think you need to set the list attribute to "yes" in the gmfgen, for that compartment (and regenerate the code), in order to have the new layout working.

Can you see selection feedback when using list layout?
Re: Compartment layout problem [message #546829 is a reply to message #546825] Wed, 14 July 2010 11:23 Go to previous messageGo to next message
Gonzalo Ortiz Jaureguizar is currently offline Gonzalo Ortiz JaureguizarFriend
Messages: 4
Registered: March 2010
Junior Member
Thanks for your quick response but I can't use listLayout because my
model is recursive and when I am generating the code, an error is thrown:

Diagnosis of Gen Editor Generator layout2.diagram
Node is referenced from multiple containers with different 'List
Layout' value

Any other idea?



El 14/07/10 13:02, emil salageanu escribió:
> Hi,
>
> I'm also having little problems with compartment layouts at the moment
> (see my thread
> http://www.eclipse.org/forums/index.php?t=msg&th=171856& amp;start=0&).
>
> I think you need to set the list attribute to "yes" in the gmfgen, for
> that compartment (and regenerate the code), in order to have the new
> layout working.
> Can you see selection feedback when using list layout?
[SOLVED] Compartment layout problem [message #546893 is a reply to message #546829] Wed, 14 July 2010 13:51 Go to previous message
Gonzalo Ortiz Jaureguizar is currently offline Gonzalo Ortiz JaureguizarFriend
Messages: 4
Registered: March 2010
Junior Member
hi all:

I finally found the solution ... if I had finished the "recipe"
(http://wiki.eclipse.org/GMF/Recipes) I probably would have had less
problems ... but I would have learned less!

Following the java trace I have discovered that by default the generated
code adds a XYLayoutEditPolicy that assumes that the layout of the
compartment is, obviously, of type XYLayout. Removing this layout policy
or replacing it by other of a type FlowLayoutEditPolicy (as the recipe
used to change elements order) the error is fixed. This can be done by
calling removeEditPolicy(EditPolicy.LAYOUT_ROLE) inside
createDefaultEditPolicies (in compartment edit part source class).

The thing I do not know is why only some compartments used this policy
and others do not (for example, the compartment I have in the top level
node do not use this policy). Someone could solve the doubt?

El 14/07/10 13:23, Gonzalo Ortiz Jaureguizar escribió:
> Thanks for your quick response but I can't use listLayout because my
> model is recursive and when I am generating the code, an error is thrown:
>
> Diagnosis of Gen Editor Generator layout2.diagram
> Node is referenced from multiple containers with different 'List Layout'
> value
>
> Any other idea?
>
>
>
> El 14/07/10 13:02, emil salageanu escribió:
>> Hi,
>>
>> I'm also having little problems with compartment layouts at the moment
>> (see my thread
>> http://www.eclipse.org/forums/index.php?t=msg&th=171856& amp;start=0&).
>>
>> I think you need to set the list attribute to "yes" in the gmfgen, for
>> that compartment (and regenerate the code), in order to have the new
>> layout working.
>> Can you see selection feedback when using list layout?
>
Previous Topic: GMF application headless build
Next Topic:How to get from an EditPart instance to the Editor instance it is currently in?
Goto Forum:
  


Current Time: Sat May 25 20:03:31 GMT 2024

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

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

Back to the top