Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » How do I enforce single selection in GEF?
How do I enforce single selection in GEF? [message #184817] Fri, 17 June 2005 18:27 Go to next message
Damian Biollo is currently offline Damian BiolloFriend
Messages: 19
Registered: July 2009
Junior Member
Hi there,

This might be a useful item for the GEF faq...

By default GEF supports multiple selection. You can hold down Ctrl or Shift
to multi-select.
I have found a way to force it to support single selection instead; although
I'm not sure if this is the best or only way to do it.

Here's a snippet of code to get it working:


public abstract class MyFilterPart extends AbstractGraphicalEditPart
{
public DragTracker getDragTracker (Request request)
{
// Create a drag tracker that will enforce single selection
return new DragEditPartsTracker (this)
{
protected void performSelection ()
{
if (hasSelectionOccurred ())
return;

setFlag (FLAG_SELECTION_PERFORMED, true);
getCurrentViewer ().select (getSourceEditPart ());
}
};
}
Re: How do I enforce single selection in GEF? [message #184874 is a reply to message #184817] Sun, 19 June 2005 06:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

Probably the viewer should support it. Open a feature request. An
extension of GraphicalViewer could probably make something like this happen.

You could customize the Tracker which performs selection, but then you'd
have to worry about hte keyhandler


"Damian" <damian_biollo@hotmail.com> wrote in message
news:d8v4mr$g1n$1@news.eclipse.org...
> Hi there,
>
> This might be a useful item for the GEF faq...
>
> By default GEF supports multiple selection. You can hold down Ctrl or
> Shift
> to multi-select.
> I have found a way to force it to support single selection instead;
> although
> I'm not sure if this is the best or only way to do it.
>
> Here's a snippet of code to get it working:
>
>
> public abstract class MyFilterPart extends AbstractGraphicalEditPart
> {
> public DragTracker getDragTracker (Request request)
> {
> // Create a drag tracker that will enforce single selection
> return new DragEditPartsTracker (this)
> {
> protected void performSelection ()
> {
> if (hasSelectionOccurred ())
> return;
>
> setFlag (FLAG_SELECTION_PERFORMED, true);
> getCurrentViewer ().select (getSourceEditPart ());
> }
> };
> }
>
>
Re: How do I enforce single selection in GEF? [message #185980 is a reply to message #184874] Thu, 30 June 2005 23:19 Go to previous message
Damian Biollo is currently offline Damian BiolloFriend
Messages: 19
Registered: July 2009
Junior Member
I've added the enh request -- id 102420.


"Randy Hudson" <none@us.ibm.com> wrote in message
news:d9339h$234$1@news.eclipse.org...
> Probably the viewer should support it. Open a feature request. An
> extension of GraphicalViewer could probably make something like this
happen.
>
> You could customize the Tracker which performs selection, but then you'd
> have to worry about hte keyhandler
>
>
> "Damian" <damian_biollo@hotmail.com> wrote in message
> news:d8v4mr$g1n$1@news.eclipse.org...
> > Hi there,
> >
> > This might be a useful item for the GEF faq...
> >
> > By default GEF supports multiple selection. You can hold down Ctrl or
> > Shift
> > to multi-select.
> > I have found a way to force it to support single selection instead;
> > although
> > I'm not sure if this is the best or only way to do it.
> >
> > Here's a snippet of code to get it working:
> >
> >
> > public abstract class MyFilterPart extends AbstractGraphicalEditPart
> > {
> > public DragTracker getDragTracker (Request request)
> > {
> > // Create a drag tracker that will enforce single selection
> > return new DragEditPartsTracker (this)
> > {
> > protected void performSelection ()
> > {
> > if (hasSelectionOccurred ())
> > return;
> >
> > setFlag (FLAG_SELECTION_PERFORMED, true);
> > getCurrentViewer ().select (getSourceEditPart ());
> > }
> > };
> > }
> >
> >
>
>
Previous Topic:Icon selectable for connections
Next Topic:Key Shortcuts
Goto Forum:
  


Current Time: Thu Dec 12 19:30:59 GMT 2024

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

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

Back to the top