Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » drag & drop & SnapToHelper
drag & drop & SnapToHelper [message #219086] Fri, 07 July 2006 09:08 Go to next message
Nicolas Rousseau is currently offline Nicolas RousseauFriend
Messages: 18
Registered: July 2009
Junior Member
Hi,

I've got a main diagram that have several NodeContainer, then a Node with
labels inside the container.

I can drag & drop every node everywhere in the diagram and labels and the
rectangle of the NodeContainer is updated each time.
Only problem, is that i got a SnapToHelper on the Diagram, and i'd like to
use it, but only for the Nodes, not for the containers and labels.

to drag & drop the nodes, i use :

public DragTracker getDragTracker(Request request) {
return new NodeTracker(this, this.getParent());
}

this = NodePart, and this.getParent() = NodeContainerPart
then :



public class NodeTracker extends DragEditPartsTracker {
EditPart part;

public NodeTracker(EditPart sourceEditPart, EditPart part) {
super(sourceEditPart);
this.part = part;
}
protected EditPart getTargetEditPart() {
return part;
}
}


With that, i can drag & drop and it works well.. but it doesn't use the
SnapToHelper at all as there's none defined in the NodeContainer.
if i use NodeTracker(this, this.getParent().getParent()); then it uses the
SnapToHelper of the diagram... but i can't drag & drop my Node.
After checked the code of DragEditPartsTracker, the easiest thing would be
to be able to set the SnapToHelper used for the drag & drop.. but there's no
getter/setter for this.
It would be for example:

public class NodeTracker extends DragEditPartsTracker {
EditPart part;

public NodeTracker(EditPart sourceEditPart, EditPart part) {
super(sourceEditPart);
this.part = part;
setSnapToHelper(part.getParent().getAdapter(SnapToHelper.cla ss));
}
protected EditPart getTargetEditPart() {
return part;
}
}

Is there any way to use the SnapToHelper only for one component that is
inside another figure?
I use SnapToGeometry & SnapToGrid


Thanks,

Nicolas
Re: drag & drop & SnapToHelper [message #219120 is a reply to message #219086] Fri, 07 July 2006 13:14 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

Could you create a SnapToHelper that looks at the request, and does nothing
in certain situations? The problem might be when you have multiple objects
selected, and some are supposed to snap, and other aren't. Another
possibility is that you could prevent targeting. If you can't drop a node in
the diagram, but only in containers, then the diagram should not identify
itself as the target for dragging nodes.

"Nicolas Rousseau" <nicolasrousseau@hotmail.com> wrote in message
news:e8l8cp$h9q$1@utils.eclipse.org...
> Hi,
>
> I've got a main diagram that have several NodeContainer, then a Node with
> labels inside the container.
>
> I can drag & drop every node everywhere in the diagram and labels and the
> rectangle of the NodeContainer is updated each time.
> Only problem, is that i got a SnapToHelper on the Diagram, and i'd like to
> use it, but only for the Nodes, not for the containers and labels.
>
> to drag & drop the nodes, i use :
>
> public DragTracker getDragTracker(Request request) {
> return new NodeTracker(this, this.getParent());
> }
>
> this = NodePart, and this.getParent() = NodeContainerPart
> then :
>
>
>
> public class NodeTracker extends DragEditPartsTracker {
> EditPart part;
>
> public NodeTracker(EditPart sourceEditPart, EditPart part) {
> super(sourceEditPart);
> this.part = part;
> }
> protected EditPart getTargetEditPart() {
> return part;
> }
> }
>
>
> With that, i can drag & drop and it works well.. but it doesn't use the
> SnapToHelper at all as there's none defined in the NodeContainer.
> if i use NodeTracker(this, this.getParent().getParent()); then it uses the
> SnapToHelper of the diagram... but i can't drag & drop my Node.
> After checked the code of DragEditPartsTracker, the easiest thing would be
> to be able to set the SnapToHelper used for the drag & drop.. but there's
> no getter/setter for this.
> It would be for example:
>
> public class NodeTracker extends DragEditPartsTracker {
> EditPart part;
>
> public NodeTracker(EditPart sourceEditPart, EditPart part) {
> super(sourceEditPart);
> this.part = part;
> setSnapToHelper(part.getParent().getAdapter(SnapToHelper.cla ss));
> }
> protected EditPart getTargetEditPart() {
> return part;
> }
> }
>
> Is there any way to use the SnapToHelper only for one component that is
> inside another figure?
> I use SnapToGeometry & SnapToGrid
>
>
> Thanks,
>
> Nicolas
>
Re: drag & drop & SnapToHelper [message #219128 is a reply to message #219120] Fri, 07 July 2006 13:52 Go to previous message
Nicolas Rousseau is currently offline Nicolas RousseauFriend
Messages: 18
Registered: July 2009
Junior Member
I've finally found something that works, but it looks a little strange...

The children of my diagram are now the containers + the nodes, and the node
is also a children of the container.
So now when i move a label which is inside the container, it doesn't use the
SnapToHelper,
and when i move the the node, it uses the SnapToHelper of the diagram.

That's strange, but it works at least...

"Randy Hudson" <none@us.ibm.com> a
Previous Topic:Draw2d figure repaint() causes a "mouse exited"
Next Topic:SelectionAction and action delegates in common navigator framework
Goto Forum:
  


Current Time: Fri Mar 29 07:45:45 GMT 2024

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

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

Back to the top