Selection in a View [message #231304] |
Fri, 02 March 2007 15:46 |
Eclipse User |
|
|
|
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 #231389 is a reply to message #231330] |
Wed, 07 March 2007 16:17 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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());
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.04301 seconds