Skip to main content



      Home
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 Go to next message
Eclipse UserFriend
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 #14977 is a reply to message #14786] Tue, 23 July 2002 10:06 Go to previous messageGo to next message
Eclipse UserFriend
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 #14979 is a reply to message #14786] Tue, 23 July 2002 09:10 Go to previous messageGo to next message
Eclipse UserFriend
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 #14982 is a reply to message #14977] Tue, 23 July 2002 09:12 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.ibm.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 #14985 is a reply to message #14982] Tue, 23 July 2002 10:34 Go to previous messageGo to next message
Eclipse UserFriend
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 #15102 is a reply to message #14985] Tue, 23 July 2002 10:14 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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 #15144 is a reply to message #15128] Tue, 23 July 2002 12:31 Go to previous messageGo to next message
Eclipse UserFriend
Sounds like Randy's solution is the way to go.... Sounds like less work
anyway!. Randy was right, I have a context menu option for connections and
this was code from the run() method of the context menu action.
Re: starting a connection not from the palette [message #15212 is a reply to message #15144] Tue, 23 July 2002 12:37 Go to previous messageGo to next message
Eclipse UserFriend
What is the class ConnectionCreationDragTracker,i couldn't find it in the
documentation or in the sources? is it a class that i suppose to
implement, and if so, what class should it extend?
thanks
yoav
Guy Slade wrote:

> Sounds like Randy's solution is the way to go.... Sounds like less work
> anyway!. Randy was right, I have a context menu option for connections and
> this was code from the run() method of the context menu action.
Re: starting a connection not from the palette [message #15308 is a reply to message #15212] Tue, 23 July 2002 12:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.ibm.com

It is actually the ill-named ConnectionDragCreationTool.
Lookout for the upcoming rename ;-)

"Yoav Rubin" <yoav@il.ibm.com> wrote in message
news:ahk0o5$4ks$1@rogue.oti.com...
> What is the class ConnectionCreationDragTracker,i couldn't find it in the
> documentation or in the sources? is it a class that i suppose to
> implement, and if so, what class should it extend?
> thanks
> yoav
> Guy Slade wrote:
>
> > Sounds like Randy's solution is the way to go.... Sounds like less work
> > anyway!. Randy was right, I have a context menu option for connections
and
> > this was code from the run() method of the context menu action.
>
>
>
>
>
Re: starting a connection not from the palette [message #15374 is a reply to message #15308] Wed, 24 July 2002 02:22 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: g.wagenknecht.intershop.de

Hi!

"Randy Hudson" <none@ibm.com> schrieb im Newsbeitrag
news:ahk2ir$5t0$1@rogue.oti.com...
> It is actually the ill-named ConnectionDragCreationTool.
> Lookout for the upcoming rename ;-)

Can you give us a possible timeframe?

Thanks, Gunnar
Re: starting a connection not from the palette [message #15473 is a reply to message #15308] Wed, 24 July 2002 06:45 Go to previous messageGo to next message
Eclipse UserFriend
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 ;-)

> "Yoav Rubin" <yoav@il.ibm.com> wrote in message
> news:ahk0o5$4ks$1@rogue.oti.com...
> > What is the class ConnectionCreationDragTracker,i couldn't find it in the
> > documentation or in the sources? is it a class that i suppose to
> > implement, and if so, what class should it extend?
> > thanks
> > yoav
> > Guy Slade wrote:
> >
> > > Sounds like Randy's solution is the way to go.... Sounds like less work
> > > anyway!. Randy was right, I have a context menu option for connections
> and
> > > this was code from the run() method of the context menu action.
> >
> >
> >
> >
> >
Re: starting a connection not from the palette [message #15506 is a reply to message #15473] Wed, 24 July 2002 09:23 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.ibm.com

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 ;-)
>
Re: starting a connection not from the palette [message #15537 is a reply to message #15506] Wed, 24 July 2002 09:31 Go to previous message
Eclipse UserFriend
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 ;-)
> >
Previous Topic:Solution for real time drag feedback
Next Topic:a question on drag and drop a text from Word editor to Graphical Editor
Goto Forum:
  


Current Time: Sat Jul 12 20:46:02 EDT 2025

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

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

Back to the top