drag & drop & SnapToHelper [message #219086] |
Fri, 07 July 2006 09:08 |
Nicolas Rousseau 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 |
Eclipse User |
|
|
|
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
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.03155 seconds