Dragging a parent via a child [message #190809] |
Sat, 06 August 2005 00:09 |
Eclipse User |
|
|
|
Originally posted by: mbernst.stanford.edu
As in the Logic Example, I have a container EditPart which holds several
child EditParts. Unlike the logic example, however, these children are
"anchored" inside the container and cannot be orphaned and moved around when
the user attempts to drag them. Instead, I would like to somehow pass the
drag (REQ_MOVE) request up to the parent, so that when the user drags the
child, the parent is the one that moves (and pulls the child along with it).
I've been fiddling around with EditPolicies, getTargetEditPart() and
getCommand() all morning and afternoon, but I can't seem to figure this out.
Is there a straightforward way to drag the parent instead of the child?
Thanks,
Michael
|
|
|
Re: Dragging a parent via a child [message #190896 is a reply to message #190809] |
Sat, 06 August 2005 21:42 |
Eclipse User |
|
|
|
Originally posted by: venkataraman.m.tcs.com
Michael, As I interpret your requirement a little clearly ...your
requirements are ..
1.CONTAINER WHEN MOVED SHOULD MOVE ITS CHILDREN ALSO AS IF CONTAINER IS
JUST A SHAPE.
2. CHILDREN SHOULD NOT BE ORAPHANED MEANS CHILDREN CANNOT GO OUTSIDE THE
CONTAINER.
3. CHIDREN's LOCATION IS FIXED IN THE CONTAINER.
4. CHILDREN ARE NOT DRAGGABLE BUT SELECTABLE FOR SOME EDITING.
If the above are your requirements then I suggest you follow the steps
below...
a. Make your container figure to have XYLayout.
b. Make your container Figure class override useLocalCoordinates and
return true.
c. Have a subclass of XYLayoutLayoutEditPolicy and install an instance of
it as LAYOUT_ROLE editpolicy in the container. XYLayoutLayoutEditPolicy
should return a appropriate changeConstraint command.
d. Override refreshVisuals of child editparts call setLayoutConstraint on
the container editpart with the new constraint obtained from child
figure's model.
I hope that works.
Thanks
Venkat
|
|
|
|
Re: Dragging a parent via a child [message #191108 is a reply to message #190809] |
Mon, 08 August 2005 19:44 |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
In your drag tracker, When the drag starts (handleDragStarted) change the
source of the drag from being the child to the parent.
"mbernst" <mbernst@stanford.edu> wrote in message
news:dd0v34$f1i$1@news.eclipse.org...
> As in the Logic Example, I have a container EditPart which holds several
> child EditParts. Unlike the logic example, however, these children are
> "anchored" inside the container and cannot be orphaned and moved around
> when the user attempts to drag them. Instead, I would like to somehow
> pass the drag (REQ_MOVE) request up to the parent, so that when the user
> drags the child, the parent is the one that moves (and pulls the child
> along with it).
>
> I've been fiddling around with EditPolicies, getTargetEditPart() and
> getCommand() all morning and afternoon, but I can't seem to figure this
> out. Is there a straightforward way to drag the parent instead of the
> child?
>
> Thanks,
> Michael
>
|
|
|
Re: Dragging a parent via a child [message #191360 is a reply to message #191108] |
Tue, 09 August 2005 23:04 |
Eclipse User |
|
|
|
Originally posted by: mbernst.stanford.edu
Thanks a bunch, Randy. Your tactic worked wonderfully, but only after I
also transferred the selection to the parent. Otherwise, I had problems
with getOperationSet() etc:
/**
* @see org.eclipse.gef.tools.AbstractTool#handleDragStarted()
*/
protected boolean handleDragStarted() {
EditPartViewer viewer = getCurrentViewer();
viewer.select(getSourceEditPart().getParent());
this.setSourceEditPart(getSourceEditPart().getParent());
return super.handleDragStarted();
}
Thanks again!
- Michael
Randy Hudson wrote:
> In your drag tracker, When the drag starts (handleDragStarted) change the
> source of the drag from being the child to the parent.
>
> "mbernst" <mbernst@stanford.edu> wrote in message
> news:dd0v34$f1i$1@news.eclipse.org...
>
>>As in the Logic Example, I have a container EditPart which holds several
>>child EditParts. Unlike the logic example, however, these children are
>>"anchored" inside the container and cannot be orphaned and moved around
>>when the user attempts to drag them. Instead, I would like to somehow
>>pass the drag (REQ_MOVE) request up to the parent, so that when the user
>>drags the child, the parent is the one that moves (and pulls the child
>>along with it).
>>
>>I've been fiddling around with EditPolicies, getTargetEditPart() and
>>getCommand() all morning and afternoon, but I can't seem to figure this
>>out. Is there a straightforward way to drag the parent instead of the
>>child?
>>
>>Thanks,
>>Michael
>>
>
>
>
|
|
|
Re: Dragging a parent via a child [message #191415 is a reply to message #191108] |
Wed, 10 August 2005 11:44 |
Eclipse User |
|
|
|
Originally posted by: christian.sell.netcologne.nospam.de
Randy Hudson wrote:
> In your drag tracker, When the drag starts (handleDragStarted) change the
> source of the drag from being the child to the parent.
could you or someone elaborate what "your drag tracker" means? I havent
been dealing with a drag tracker yet..
thanks,
christian
|
|
|
Re: Dragging a parent via a child [message #191423 is a reply to message #191360] |
Wed, 10 August 2005 12:28 |
Eclipse User |
|
|
|
Originally posted by: christian.sell.nospam.de
Hello,
I have now overridden the "getDragTracker(Request request)" method in my
child edit part, and returned a DragTracker that was implemented as
described in the previous mail. I can verify that the tracker gets created
and its handleDragStarted method (which sets the source part) gets called.
However, the move still does not work for the parent edit part - I see a
no-drop sign, and the part remains where it is.
What am I doing wrong??
thanks,
Christian
|
|
|
Re: Dragging a parent via a child [message #191431 is a reply to message #191423] |
Wed, 10 August 2005 13:46 |
Eclipse User |
|
|
|
Originally posted by: cse.nospam.de
Hello,
I have been able to solve this by additionally overriding the method
createOperationSet() in my DragTracker, and return a list containing only
the enclosing part.
What sometimes bothers me with these experiences is that I still dont
understand conceptionally why this has to be, and the only way to get
there was through heavy debugging..
thanks,
chris
|
|
|
Powered by
FUDForum. Page generated in 0.03261 seconds