Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Selection in a View
Selection in a View [message #231304] Fri, 02 March 2007 15:46 Go to next message
Eclipse UserFriend
Originally posted by: neil.scapatech.com

Hi,

I have extended ScrollingGraphicalViewer to create a re-useable widget.

Unfortunately I cannot work out how to make my widget respond to
mouse-clicks to change the current selection in my diagram.

Previously I have extended GraphicalEditorWithFlyoutPalette where this
selection functionality seems to come for free.

With ScrollingGraphicalViewer, do I need to implement all this myself (by
using a mouse-listener and finding/selecting the appropriate EditParts
myself). I suspect this functionality must be available as part of the GEF
framework, but I simply cannot find it.

Any help is much appreciated.
Re: Selection in a View [message #231330 is a reply to message #231304] Sat, 03 March 2007 20:57 Go to previous messageGo to next message
Alex Boyko is currently offline Alex BoykoFriend
Messages: 200
Registered: July 2009
Senior Member
Hi,

The lightweight system listens to the viewer's control for various mouse
and key events and forwards them to the event dispatcher, which in your
case most likely the DomainEventDispatcher which will forward mouse events
to the currently active tool. Ones the mouse down is received by the
selection tool, it will find the figure under mouse and from the figure
and visual part map maintained on the viewer the edit part to become
selected. You could try debuging DomainEventDispatcher and see if you get
a mouse down event there.
Hope this helps.

Cheers,
Alex
Re: Selection in a View [message #231389 is a reply to message #231330] Wed, 07 March 2007 16:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: neil.scapatech.com

Thanks for the reply Alex,

In fact, it seems my event dispatcher is SWTEventDispatcher. I have tried
debugging it (stepping through it), but cannot really make much sense of
what I see. This is lower-level event management that I would, ideally,
like to have to deal with.

Perhaps I need to re-phrase my question, by using a simple analogy...

If, for example, I use a jface TreeViewer to present my domain model, then
I do not need to write code that sets the selected tree-nodes in response
to mouse-clicks. That is entirely handled for me by the TreeViewer, and
all I have to do is implement selection listeners to handle the
consequences of those selections.

Basically, am I wrong to expect gef's ScrollingGraphicalViewer to provide
similar functionality?

At the moment my code is essentially very simple...

public class MyWidget extends ScrollingGraphicalViewer
{
public MyWidget(Composite parent)
{
createControl(parent);

setRootEditPart(new ScalableFreeformRootEditPart());
setEditPartFactory(new MyEditPartFactory());
}
}

Am I missing something fundamental here that will cause my widget to
change its current selection when I click the mouse on the various
figures in my diagram?

Thanks again

Neil
Re: Selection in a View [message #231396 is a reply to message #231389] Thu, 08 March 2007 11:58 Go to previous message
Eclipse UserFriend
Originally posted by: neil.scapatech.com

I think I figured it out...

My widget did not have an EditDomain, and therefore the default
(selection) tool was never being set. I changed my code to the following
and it now works exactly as I expected...

public class MyWidget extends ScrollingGraphicalViewer
{
public MyWidget(Composite parent)
{
createControl(parent);

setRootEditPart(new ScalableFreeformRootEditPart());
setEditPartFactory(new MyEditPartFactory());

setEditDomain(new EditDomain());
}
}
Previous Topic:Graphical Editor as a view
Next Topic:logic example animation !!
Goto Forum:
  


Current Time: Mon Oct 18 23:00:12 GMT 2021

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

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

Back to the top