How to add Shapes inside Shapes? [message #237780] |
Thu, 09 August 2007 03:10 |
Eclipse User |
|
|
|
Originally posted by: el01120.mail.ntua.gr
Hello everyone,
I have had this problem for a long time, now it is time to ask for
help.
Could someone explain briefly what changes I need to make to the shapes
example, if I want to be able to add new Shapes inside the Shapes, and
not only to the Diagram?
I have tried (after making the appropriate changes to the model) to
install an additional EditPolicy on a Shape, which can handle adding of
new Shapes, like the ShapesXYLayoutEditPolicy installed on the
DiagramEditPart.
But no luck, when I select the CREATE tool from the
Palette, the cursor becomes a big black 'X' when the mouse is over an
existing Shape. It only becomes normal when it is over the contents
EditPart.
Actually I use the same EditPolicy on both DiagramEditPart
and ShapeEditPart, and I know it works on the DiagramEditPart because I
can add Shapes to it. I have also added at ShapeEditPart.java:
public void propertyChange(PropertyChangeEvent evt) {
...
if (Shape.CHILD_ADDED_PROP.equals(prop))
addChild(createChild(evt.getNewValue()),-1);
}
Debugging is difficult because ShapeCreateCommand
seems to be called as it should, but then the debugger takes me into a
whole bunch of GEF classes, which I don't know much about and I can't
find what is wrong.
I would be very grateful if someone helps me.
|
|
|
Re: How to add Shapes inside Shapes? [message #237784 is a reply to message #237780] |
Thu, 09 August 2007 07:02 |
Eclipse User |
|
|
|
Originally posted by: alexjaquet.gmail.com
Hi,
If I'm not wrong you have to create a second policy for the role
component and you define in this policy your rules to accept or not a child
Hope this help
Regards
Alexandre
|
|
|
Re: How to add Shapes inside Shapes? [message #237834 is a reply to message #237784] |
Fri, 10 August 2007 15:39 |
Eclipse User |
|
|
|
Originally posted by: mgauthier.trisotech.com
Hello,
Your figure part needs to install a layout policy
(EditPolicy.LAYOUT_ROLE), such as XYLayoutPolicy that you extend to
implement methods createAddCommand (that is called when an existing object
is drag over your FigurePart) and getCreateCommand (that is called when
you add a new object from the palette) to return the appropriate command
that will add your new shape.
The forbidden sign is displayed whenever no suitable command can be found
in the part and its policies.
Good luck
Melanie
|
|
|
|
Powered by
FUDForum. Page generated in 0.03521 seconds