|
|
|
|
|
|
|
Re: Custom Layout in Compartment [message #234161 is a reply to message #233847] |
Thu, 18 June 2009 20:03 |
No real name Messages: 3 Registered: July 2009 |
Junior Member |
|
|
Hi Alex, Sven and Srinath,
thanks a lot for your suggestions. Finally I found a solution using all
of them:
Instead of using the ShapeCompartmentEditPart I directly used the
ResizableCompartmentEditPart, copied what I need from
ShapeCompartmentEditPart and customized it so that it has the right
LayoutEditPolicy and the right Figures.
Furthermore I let my own layout extend XYLayout.
The complete solution:
public class MyCompartmentEditPart extends ResizableCompartmentEditPart{
....
public IFigure createFigure() {
ResizableCompartmentFigure rcf;
if (getParent() == getTopGraphicEditPart()){
rcf = (ResizableCompartmentFigure) super.createFigure();
} else {
rcf = new NestedResizableCompartmentFigure(getMapMode());
}
rcf.getContentPane().setLayoutManager(new MyLayoutManager());
return rcf;
}
....
protected void createDefaultEditPolicies() {
super.createDefaultEditPolicies();
installEditPolicy(EditPolicy.LAYOUT_ROLE,
new MyLayoutEditPolicy());
}
}
My custom layout is a bit large, it arranges the children in a grid. For
anyone who wants to do a custom layout in a compartment, too:
Take the XYLayout as a basis and look how calculatePreferredSize(..) and
layout(..) is done there. At first I made the mistake that I did not use
the constraints that the layout stores and directly called
child.getPreferredSize(..). This returns much too big values, because an
other layout manager of the child then tries to use the complete space.
Again, thank you all for your help, finally I got it working :-)
Cheers,
Balthasar
|
|
|
Powered by
FUDForum. Page generated in 0.03505 seconds