Is this mandatory to have a palette to implement nodes & connections creations? [message #29147] |
Fri, 11 October 2002 11:35  |
Eclipse User |
|
|
|
Hello,
This is probably a naive question, but I try it anyway:
In all GEF examples (Logical Diagram Editor standard example, Shape Editor
on Eclipse Wiki site) when nodes and/or connections are created, a palette
is used.
My question is whether I can allow creation of node and/or connections in a
palette-less editor, for example:
a - allow connection creation if the user select a kind of visible "port"
(maybe "Anchor" is a better word?) on the node's figure, and drags it toward
the connection's destination "port"
b - allow nodes creation if the user clicked on a given action button in the
toolbar or selected a menu or even typed some kind of shortcut key dedicated
to this creation...
In either case, how the appropriate GEF requests are created, and more
specifically, what should be implement to make it work as specified above?
Alex.
|
|
|
|
Re: Is this mandatory to have a palette to implement nodes & connections creations? [message #32941 is a reply to message #29147] |
Wed, 16 October 2002 18:11   |
Eclipse User |
|
|
|
Adding connections without a palette is fairly easy. You just need to return a
ConnectionDragCreationTool from your EditPart's getDragTracker(Request) method
if the mouse is over a ConnectionAnchor. All I had to do to get this to work in
the logic example was add these 2 methods to LogicEditPart...
------------------------------------------------------------ ----------
public DragTracker getDragTracker(Request request) {
if (isMouseOverSourceAnchor(request))
return new ConnectionDragCreationTool();
return super.getDragTracker(request);
}
public boolean isMouseOverSourceAnchor(Request request) {
if (request instanceof LocationRequest) {
LocationRequest req = (LocationRequest)request;
Vector sourceAnchors = getNodeFigure().getSourceConnectionAnchors();
for (int i = 0; i < sourceAnchors.size(); i++) {
ConnectionAnchor anchor = (ConnectionAnchor)sourceAnchors.get(i);
Point p = anchor.getLocation(null).getTranslated(-3, -3);
Rectangle rect = Rectangle.SINGLETON;
rect.setLocation(p);
rect.setSize(6, 6);
if (rect.contains(req.getLocation()))
return true;
}
}
return false;
}
------------------------------------------------------------ ----------
You might also want to add some sort of feedback that tells the user he/she can
create a connection there.
Eric
"Alexandre Vermeerbergen" <ave@ds-fr.com> wrote in message
news:ao6pll$j80$1@rogue.oti.com...
> Hello,
>
> This is probably a naive question, but I try it anyway:
>
> In all GEF examples (Logical Diagram Editor standard example, Shape Editor
> on Eclipse Wiki site) when nodes and/or connections are created, a palette
> is used.
>
> My question is whether I can allow creation of node and/or connections in a
> palette-less editor, for example:
> a - allow connection creation if the user select a kind of visible "port"
> (maybe "Anchor" is a better word?) on the node's figure, and drags it toward
> the connection's destination "port"
> b - allow nodes creation if the user clicked on a given action button in the
> toolbar or selected a menu or even typed some kind of shortcut key dedicated
> to this creation...
>
> In either case, how the appropriate GEF requests are created, and more
> specifically, what should be implement to make it work as specified above?
>
> Alex.
>
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.24302 seconds