Skip to main content



      Home
Home » Eclipse Projects » JFace » How to do empty selection (IStructuredSelection.isEmpty() == true)?
How to do empty selection (IStructuredSelection.isEmpty() == true)? [message #901399] Sat, 11 August 2012 15:01 Go to next message
Eclipse UserFriend
Hi all,
I'm just wondering how to do "empty" selection as a user of e.g. TreeViewer.

Because when selection changed event is triggered it is because
something has been selected so I don't understand how this "something"
can be empty.

treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {

// When this selection will be empty??
if(event.getSelection().isEmpty()) {
return;
}
...
}
});

Thanks
Libor
Re: How to do empty selection (IStructuredSelection.isEmpty() == true)? [message #901408 is a reply to message #901399] Sat, 11 August 2012 18:34 Go to previous messageGo to next message
Eclipse UserFriend
Hi Libor,

your Tree probably has the style SWT.SINGLE. If you set it's style to SWT.MULTI, it is possible to clear the selection (i.e. through Ctrl+Click on the last selected element).

Greetings
Christoph
Re: How to do empty selection (IStructuredSelection.isEmpty() == true)? [message #901481 is a reply to message #901408] Sun, 12 August 2012 23:00 Go to previous messageGo to next message
Eclipse UserFriend
step 1:you select a tree item
step 2:program deleted the selected tree item
step 3: a selection changed event with empty selection is fired
Re: How to do empty selection (IStructuredSelection.isEmpty() == true)? [message #901537 is a reply to message #901481] Mon, 13 August 2012 05:46 Go to previous message
Eclipse UserFriend
If you request a selection from a non selected viewer you will get an EMPTY selection (not null). On the other hand the selection of a viewer is/can be cleared by setting an EMPTY selection. That's why selection.isEmpty() actually makes sense. See for example:

org.eclipse.jface.viewers.StructuredSelection.EMPTY


Regards
Thorsten
Previous Topic:Disable one radio button in a RadioGroupFieldEditor
Next Topic:detect class name of opened jface dialog,detect at runtime
Goto Forum:
  


Current Time: Thu Jul 24 13:37:31 EDT 2025

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

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

Back to the top