Skip to main content



      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 14:27 Go to next message
Eclipse UserFriend
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 02: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 19:19 Go to previous message
Eclipse UserFriend
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: Tue Jul 08 17:27:22 EDT 2025

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

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

Back to the top