Selection decoration with XYLayoutEditPolicy in parent [message #239422] |
Fri, 26 October 2007 19:32 |
Eclipse User |
|
|
|
Originally posted by: lance.walton.casualmiracles.com.removethispart
Hi.
I'm a newbie for GEF and am trying to get something very simple working (it is
for a real project though). I'd appreciate some help.
My 'root' edit part has an XYLayoutEditPolicy installed under the
EditPolicy.LAYOUT_ROLE key. I've also disabled
EditPolicy.SELECTION_FEEDBACK_ROLE by installing null for that key.
I have a child edit part which the figure is just a line. When I select the
line, I want handles to appear on each end so that I can drag them around and
I don't want the usual bounding rectangle to appear. I have used Polyline as
the figure for this, and in the edit part (a subclass of
AbstractGraphicalEditPart), I have the following:
protected void createEditPolicies() {
installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new
LineSelectionEditPolicy());
installEditPolicy(EditPolicy.COMPONENT_ROLE, new ItemEditPolicy());
}
LineSelectionEditPolicy looks like this:
public class LineSelectionEditPolicy extends SelectionHandlesEditPolicy {
protected List<IFigure> createSelectionHandles() {
GraphicalEditPart editPart = (GraphicalEditPart) getHost();
List<IFigure> handles = new ArrayList<IFigure>();
handles.add(new MoveHandle(editPart, new
RelativeLocator(editPart.getFigure(), 0, 0)));
handles.add(new MoveHandle(editPart, new
RelativeLocator(editPart.getFigure(), 1, 1)));
return handles;
}
}
(I realise that the RelativeLocator creation parameters are not quite right -
don't worry about that for now unless it's relevant :-).
Now, after I have placed a line and then select it, I still get the usual
bounding rectangle. If I debug, I can see that my
LineSelectionEditPolicy.createSelectionHandles() method is being used.
Debugging some more, placing a breakpoint in the
AbstractEditPart.installEditPolicy(), I see my policies being installed.
However, at some point I can see other policies being installed, such as
ResizableEditPolicy under the key "PrimaryDrag Policy", and this appears to be
happening as a result of the parent edit parts
XYLayoutEditPolicy.activateEditPolicies() being invoked. IS this what's
causing the rectangle to appear?
What do I need to do to stop the bounding rectangle appearing?
Regards,
Lance
--
Lance Walton
http://www.casualmiracles.com/
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03011 seconds