How to move an EditPart [message #153667] |
Mon, 11 October 2004 14:48  |
Eclipse User |
|
|
|
I'm having trouble implementing Move via the Selection Tool.
To install policies on the EditParts I use this:
protected void createEditPolicies()
{
installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE,
new ResizableSelection());
}
The ResizableSelection is very simple:
public class ResizableSelection extends ResizableEditPolicy
{
protected Command getResizeCommand(ChangeBoundsRequest p_req)
{
return new ResizeCommand((ComponentPart)p_req.getEditParts().get(0),
p_req);
}
protected Command getMoveCommand(ChangeBoundsRequest p_req)
{
return new MoveCommand(p_req);
}
}
getResizeCommand() is called when I drag a resize handle and the
ResizeCommand() works fine.
However when I move the EditPart, getMoveCommand() is never called.
Visually the part does show the XOR graphics as it's Moved, but when the
mouse button is released nothing happens since my getMoveCommand() never
gets called.
Also as the component is being dragged, the cursor is the universal "no
way" symbol (or whatever a circle with a diagonal line through it is
called.)
Resize was so easy, but I'm stumped about how to move the EditPart. Any
guidance would be greatly appreciated.
|
|
|
|
Re: How to move an EditPart [message #153776 is a reply to message #153738] |
Tue, 12 October 2004 11:30  |
Eclipse User |
|
|
|
Jens v. P. wrote:
> I'm using the XYLayoutPolicy for this purpose. That means not the
> edited element (EditPart with installed Policies) is responsible for
> creating the command but its parent element, usually a XYLaout. I'm
> using the XYLayoutPolicy. That's working fine. All examples I've found
> are working like that, too.
> I tried the selection policy first. I'm a little bit confused: Is it
> possible to implement moving and sizing by using XYLayoutPolicy and
> ResizablePolicy?
> Jens
I had tried using an XYLayoutPolicy on the parent as well as Resizable and
NonResizable Policies on the children. That never worked.
Turns out that what I needed to do to get it to work was:
Do NOT install the Resizable/NonResiable policies via
EditPart.createEditPolicies().
Instead, override XYLayoutPolicy.createChildEditPolicy() to install the
appropriate resizable/nonresiable policy on the child.
This then calls the commands associated with the policy correctly.
|
|
|
Powered by
FUDForum. Page generated in 0.45295 seconds