Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 19:01 Go to next message
Libor Jelinek is currently offline Libor JelinekFriend
Messages: 143
Registered: January 2012
Location: Prague, Czech Rep.
Senior Member

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()) {

Re: How to do empty selection (IStructuredSelection.isEmpty() == true)? [message #901408 is a reply to message #901399] Sat, 11 August 2012 22:34 Go to previous messageGo to next message
Christoph Keimel is currently offline Christoph KeimelFriend
Messages: 480
Registered: December 2010
Location: Germany
Senior Member
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).

Re: How to do empty selection (IStructuredSelection.isEmpty() == true)? [message #901481 is a reply to message #901408] Mon, 13 August 2012 03:00 Go to previous messageGo to next message
jim liu is currently offline jim liuFriend
Messages: 37
Registered: February 2011
Location: shanghai
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

java eclipse Search
Re: How to do empty selection (IStructuredSelection.isEmpty() == true)? [message #901537 is a reply to message #901481] Mon, 13 August 2012 09:46 Go to previous message
Thorsten Schlathölter is currently offline Thorsten SchlathölterFriend
Messages: 306
Registered: February 2012
Location: Düsseldorf
Senior Member
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:


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: Mon Jun 18 00:38:43 GMT 2018

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

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

Back to the top