Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Move parent when child is draged
Move parent when child is draged [message #989109] Tue, 04 December 2012 16:21 Go to next message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 530
Registered: June 2011
Senior Member
I would like to move parent editpart when child edit part is dragged.

Parent's parent editpart layout is XY and user can move it. Parent editpart layout is flowlayout.

A : parent....xylayout
B: A'child...flowlayout
c: B'child....flowlayout

User can move B. Now i would like to move B when user drag C and drop it at A then i want to move B at drop location.

Any idea?

Cheers,

Re: Move parent when child is draged [message #989434 is a reply to message #989109] Thu, 06 December 2012 08:37 Go to previous messageGo to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
Hi, is the C component also moveable within its parent (B)?
Re: Move parent when child is draged [message #989456 is a reply to message #989434] Thu, 06 December 2012 09:58 Go to previous messageGo to next message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 530
Registered: June 2011
Senior Member
No, I donot want C to be moved inside B
Re: Move parent when child is draged [message #989462 is a reply to message #989456] Thu, 06 December 2012 10:20 Go to previous messageGo to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
Then it could be possible to achieve this with returning the parent's drag tracker.

I can't tell you exactly what to do, because I can't simulate that. Generally, you should ovveride getDragTracker(Request request) on the C edit part.

There you have to return the parent's drag tracker, when the request comes from the selection tool.

Something like:
@Override
public DragTracker getDragTracker(Request request) {
    if (REQ_SELECTION.equals(request.getType()) {
        return getParent().getDragTracker(request);
    } else return super.getDragTracker(request);
}

Re: Move parent when child is draged [message #989474 is a reply to message #989462] Thu, 06 December 2012 11:38 Go to previous messageGo to next message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 530
Registered: June 2011
Senior Member
This works but now it does not let C get Selected (as we have used REQ_SELECTION). I want C to get selected but not moved.
Now C cannot be moved and B is moving that is fine but C does not get selected...

Any idea?

Thanks!
Re: Move parent when child is draged [message #989499 is a reply to message #989474] Thu, 06 December 2012 14:00 Go to previous messageGo to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
Then it's more complicated than I thought and you'll need to debug it and figure out yourself.

I think you'll need to customize the C's drag tracker. So don't return the parent's drag tracker,
instead modify the DragEditPartsTracker class. Look at its handleDragInProgress().

Welcomme to the GEF's tool hell Smile
Re: Move parent when child is draged [message #989502 is a reply to message #989499] Thu, 06 December 2012 14:22 Go to previous messageGo to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
@Override
public DragTracker getDragTracker(Request request) {
    return new DragEditPartsTracker(this) {

        @Override
        protected List createOperationSet() {
	    List operationSet = super.createOperationSet();
	    if (operationSet.remove(getSourceEditPart())) {
	        operationSet.add(getSourceEditPart().getParent());
            }
	    return operationSet;
	}

    };
}

Try this, but it could have some hidden pitfalls. And knowing the GEF, it definitelly has some.

[Updated on: Thu, 06 December 2012 14:23]

Report message to a moderator

Re: Move parent when child is draged [message #989527 is a reply to message #989502] Thu, 06 December 2012 16:01 Go to previous messageGo to next message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 530
Registered: June 2011
Senior Member
thanks for assistance

@Override
protected List createOperationSet() {
List operationSet = super.createOperationSet();

/*if (operationSet.remove(getSourceEditPart())) {
operationSet.add(getSourceEditPart().getParent());
}*/
operationSet.add(getSourceEditPart().getParent());
return operationSet;
}

I tried your code but i did not do anything then i commented as given above and now i can see C is getting selected, B is getting dragged(as shadow moves with mouse) but when mouse button is realsed to drop then nothing happen.... B remains at its original place...

any idea?

thanks!
Re: Move parent when child is draged [message #989538 is a reply to message #989527] Thu, 06 December 2012 16:36 Go to previous messageGo to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
It works for me exactly as I posted. Are you overriding that in C editPart class?
Re: Move parent when child is draged [message #989539 is a reply to message #989538] Thu, 06 December 2012 16:43 Go to previous messageGo to next message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 530
Registered: June 2011
Senior Member
Yes i am overriding in C editPart class.. what version of GEF' plugin you are using?
Re: Move parent when child is draged [message #989665 is a reply to message #989539] Fri, 07 December 2012 08:56 Go to previous messageGo to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
3.7.2, but it shouldn't be much different if you use an older version.
Re: Move parent when child is draged [message #991196 is a reply to message #989665] Mon, 17 December 2012 17:02 Go to previous message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 530
Registered: June 2011
Senior Member
do you any idea why it is not working for me?

thanks!
Previous Topic:FlowlayoutEditPolicy
Next Topic:ifigure focus
Goto Forum:
  


Current Time: Sun Dec 21 13:02:12 GMT 2014

Powered by FUDForum. Page generated in 0.03502 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software