Home » Eclipse Projects » GEF » starting a connection not from the palette
starting a connection not from the palette [message #14786] |
Mon, 22 July 2002 10:14  |
Eclipse User |
|
|
|
Hi
in my application i have a graph with nodes, terminals and connections
between them. i would like my users to be able to start a connection
between two nodes (editparts), when they click on the terminal, without
the need to select the "Connection" entry in the palette. i got a utility
method that tells me if the click was over the appropriate terminal, and i
also called myConnectionTool.acticate() and
myEditDomain.setTool(myConnectionTool), and it works partially. the
connection tool got activated correctly, but there is still a need to
click again in order to start the connection creation. what method is
called after the first click? so far i used the method getDragTrackrer in
the editpart that was selected, but it seems like the wrong place for this
hookup. i guess i will need also to re-use the mouseEvent , but from
where can i get it?
thanks
yoav
|
|
| |
Re: starting a connection not from the palette [message #14979 is a reply to message #14786] |
Tue, 23 July 2002 09:10   |
Eclipse User |
|
|
|
Originally posted by: none.ibm.com
This question was asked recently, but I'll recap.
"Yoav Rubin" <yoav@il.ibm.com> wrote in message
news:ahh3vc$hh9$1@rogue.oti.com...
> Hi
> in my application i have a graph with nodes, terminals and connections
> between them. i would like my users to be able to start a connection
> between two nodes (editparts), when they click on the terminal, without
> the need to select the "Connection" entry in the palette. i got a utility
> method that tells me if the click was over the appropriate terminal, and i
> also called myConnectionTool.acticate() and
If the connection is to be created by dragging from a terminal to another
terminal, you should use a *DragTracker*. There is a
ConnectionCreationDragTracker specifically for this purpose. Don't call
setTool(). The SelectionTool should stay active, but manages and delegates
events to its drag tracker. The SelectionTool will query the node editpart
for a drag tracker at an x,y location.
> myEditDomain.setTool(myConnectionTool), and it works partially. the
> connection tool got activated correctly, but there is still a need to
> click again in order to start the connection creation. what method is
> called after the first click? so far i used the method getDragTrackrer in
> the editpart that was selected, but it seems like the wrong place for this
> hookup. i guess i will need also to re-use the mouseEvent , but from
> where can i get it?
> thanks
> yoav
>
|
|
| | |
Re: starting a connection not from the palette [message #15102 is a reply to message #14985] |
Tue, 23 July 2002 10:14   |
Eclipse User |
|
|
|
well, you were right regarding identifying my problem, i've used the
snippet, but it seems that it doesn't work. what do you mean by saying "if
used in the right place" ,where is the right place?
do you know how can i invoke a mouseEvent in the connection tool instead
of invoking an event on the canvas?
thanks
yoav
Guy Slade wrote:
> I thought part of his problem was that even thought he captured the fact
> that the user had clicked over the editpart and he had successfully
> activated the connection action, the user still had to click again to attach
> the connection to the editpart (connection source ).....
> " and it works partially. the
> connection tool got activated correctly, but there is still a need to
> click again in order to start the connection creation."
> This was a code snippet that, if used in the right place, would mean that
> the user would not have to do that second click.... the connection would
> already be attached to the editpart and the user just needs to click the
> target of the connection.
> ....at least I thought that was part of his problem.... but I could be wrong
> :)
> "Randy Hudson" <none@ibm.com> wrote in message
> news:ahjmvq$t3j$1@rogue.oti.com...
> > Guy, are you sure this is relevant to the question? When do you do this?
> > I'm guessing what you are describing is done for a connection initiated
> from
> > the context menu.
> >
> > "Guy Slade" <gslade@us.ibm.com> wrote in message
> > news:ahjm0g$sco$1@rogue.oti.com...
> > > I do something similar. What you need to do is programatically create a
> > > mouse down event and dispatch it..... here's my code, hopefully you can
> > slot
> > > it in where it needs to go....
> > > ...or at least this is one way to do it anyway!
> > >
> > > Guy
> > >
> > >
> > > /**
> > > * Create a mouse down event that thinks it is over the blob and dispatch
> > it.
> > > * This is a bit of a fudge to mimic what the user ought to do.
> > > */
> > > MyEditPart editPart = ((MyEditPart)getSelectedObjects().get(0));
> > > Point point = editPart.getModel().getLocation();
> > > editPart.getFigure().translateToAbsolute(point);
> > >
> > > Canvas canvas = (Canvas)
> > >
> ((StrutsGraphicalEditor)getEditorPart()).getPrimaryViewer(). getControl();
> > > Event event = new Event();
> > > event.button = 1;
> > > event.count = 0;
> > > event.detail = 0;
> > > event.end = 0;
> > > event.height = 0;
> > > event.keyCode = 0;
> > > event.start = 0;
> > > event.stateMask = 0;
> > > event.time = 9516624; // any old time... doesn't matter
> > > event.type = 3;
> > > event.widget = canvas;
> > > event.width = 0;
> > > event.x = point.x;
> > > event.y = point.y;
> > > /**
> > > * Set the connection tool to be the current tool
> > > */
> > > ((DefaultEditDomain)(getEditorPart().getEditDomain()).setToo l(new
> > > ConnectionTool());
> > > /**
> > > * Dispatch the mouse down event
> > > */
> > > canvas.notifyListeners(3,event);
> > >
> > >
> > >
> > >
> >
> >
|
|
|
Re: starting a connection not from the palette [message #15128 is a reply to message #14985] |
Tue, 23 July 2002 11:03   |
Eclipse User |
|
|
|
Originally posted by: none.ibm.com
You're right. Anyway, the ConnectionCreationDragTracker does *not* require
click and click. Just press, drag, release. And, the SelectionTool
forwards the first mousedown to the tool, so there is no need to recreate
this event.
"Guy Slade" <gslade@us.ibm.com> wrote in message
news:ahjnli$tng$1@rogue.oti.com...
> I thought part of his problem was that even thought he captured the fact
> that the user had clicked over the editpart and he had successfully
> activated the connection action, the user still had to click again to
attach
> the connection to the editpart (connection source ).....
> " and it works partially. the
> connection tool got activated correctly, but there is still a need to
> click again in order to start the connection creation."
>
> This was a code snippet that, if used in the right place, would mean that
> the user would not have to do that second click.... the connection would
> already be attached to the editpart and the user just needs to click the
> target of the connection.
>
> ...at least I thought that was part of his problem.... but I could be
wrong
> :)
>
>
> "Randy Hudson" <none@ibm.com> wrote in message
> news:ahjmvq$t3j$1@rogue.oti.com...
> > Guy, are you sure this is relevant to the question? When do you do
this?
> > I'm guessing what you are describing is done for a connection initiated
> from
> > the context menu.
> >
> > "Guy Slade" <gslade@us.ibm.com> wrote in message
> > news:ahjm0g$sco$1@rogue.oti.com...
> > > I do something similar. What you need to do is programatically create
a
> > > mouse down event and dispatch it..... here's my code, hopefully you
can
> > slot
> > > it in where it needs to go....
> > > ...or at least this is one way to do it anyway!
> > >
> > > Guy
> > >
> > >
> > > /**
> > > * Create a mouse down event that thinks it is over the blob and
dispatch
> > it.
> > > * This is a bit of a fudge to mimic what the user ought to do.
> > > */
> > > MyEditPart editPart = ((MyEditPart)getSelectedObjects().get(0));
> > > Point point = editPart.getModel().getLocation();
> > > editPart.getFigure().translateToAbsolute(point);
> > >
> > > Canvas canvas = (Canvas)
> > >
> ((StrutsGraphicalEditor)getEditorPart()).getPrimaryViewer(). getControl();
> > > Event event = new Event();
> > > event.button = 1;
> > > event.count = 0;
> > > event.detail = 0;
> > > event.end = 0;
> > > event.height = 0;
> > > event.keyCode = 0;
> > > event.start = 0;
> > > event.stateMask = 0;
> > > event.time = 9516624; // any old time... doesn't matter
> > > event.type = 3;
> > > event.widget = canvas;
> > > event.width = 0;
> > > event.x = point.x;
> > > event.y = point.y;
> > > /**
> > > * Set the connection tool to be the current tool
> > > */
> > > ((DefaultEditDomain)(getEditorPart().getEditDomain()).setToo l(new
> > > ConnectionTool());
> > > /**
> > > * Dispatch the mouse down event
> > > */
> > > canvas.notifyListeners(3,event);
> > >
> > >
> > >
> > >
> >
> >
>
>
|
|
| | | | | | |
Re: starting a connection not from the palette [message #15537 is a reply to message #15506] |
Wed, 24 July 2002 09:31  |
Eclipse User |
|
|
|
Hi
i needed t ovoride the handleButtonDown method, since i wanted my users to
be able to select the terminal from a list.
i have just found a way to do so and it works. what i did was declaring
MyConnectionCreationTool (that extends ConnectionCreationTool) to also
implement DragTracker, and prior to returing it from the
editpart#getDragTracker i called
MyConnectionCreationTool#setTargetEditPart with the appropriate editpart.
in order to do so i overriden the setTargetEditPart method in
ConnectionCreationTool, and changed its visibility to public.
Randy Hudson wrote:
> Why do you have your own ConnectionCreationTool? Which methods do you need
> to override?
> Your options are to subclass both creation tool implementations, or open a
> feature request that we make AbstractConnectionCreationTool support both
> modes of operation, which could be configured in a constructor parameter.
> "Yoav Rubin" <yoav@il.ibm.com> wrote in message
> news:ahm0fi$2i2$1@rogue.oti.com...
> > Hi
> > it seems that i can't use this solution. i am using my own
> > ConnectionCreationTool, that extends gef.tools.ConnectionCreationTool, and
> > if i return from getDragTracker a new ConnectionDragCreationTool, my tool
> > does not get called, and the connection isn't created. any idea what can i
> > do?
> > thanks
> > yoav
> > Randy Hudson wrote:
> >
> > > It is actually the ill-named ConnectionDragCreationTool.
> > > Lookout for the upcoming rename ;-)
> >
|
|
|
Goto Forum:
Current Time: Sat Jul 12 20:46:02 EDT 2025
Powered by FUDForum. Page generated in 0.03936 seconds
|