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 15:01 Go to next message
Libor Jelinek is currently offline Libor Jelinek
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()) {
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
Christoph Keimel is currently offline Christoph Keimel
Messages: 297
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).

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
jim liu is currently offline jim liu
Messages: 37
Registered: February 2011
Location: shanghai
Member
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
http://javafind.appspot.com/
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
Thorsten Schlathölter is currently offline Thorsten Schlathölter
Messages: 207
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:

org.eclipse.jface.viewers.StructuredSelection.EMPTY


Regards
Thorsten
Previous Topic:Modify indent of tree elements
Next Topic:Disable one radio button in a RadioGroupFieldEditor
Goto Forum:
  


Current Time: Fri Apr 18 22:09:58 EDT 2014

Powered by FUDForum. Page generated in 0.01601 seconds