Skip to main content



      Home
Home » Eclipse Projects » GEF » Is this mandatory to have a palette to implement nodes & connections creations?
Is this mandatory to have a palette to implement nodes & connections creations? [message #29147] Fri, 11 October 2002 11:35 Go to next message
Eclipse UserFriend
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 #32694 is a reply to message #29147] Wed, 16 October 2002 15:47 Go to previous messageGo to next message
Eclipse UserFriend
Anyone here having an answer?
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 Go to previous messageGo to next message
Eclipse UserFriend
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.
>
>
Re: Is this mandatory to have a palette to implement nodes & connections creations? [message #33009 is a reply to message #32941] Wed, 16 October 2002 19:19 Go to previous message
Eclipse UserFriend
Originally posted by: hudsonr.us.eye-bee-em.com

Others have also activated the normal ConnectionCreationTool from the
context menu. This even necessary in situations where the number of "ports"
is too many to be displayed, like with Events in a GUI builder.
Previous Topic:Doesn't work?: ComponentEditPolicy with AbstractTreeEditPart
Next Topic:Multiple tabs Graphic Editor
Goto Forum:
  


Current Time: Wed Apr 23 22:57:20 EDT 2025

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

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

Back to the top