Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » ComboViewer Add SelectionChangedListener does not work
ComboViewer Add SelectionChangedListener does not work [message #329374] Sat, 21 June 2008 21:42 Go to next message
Eclipse UserFriend
I use the following code to add SelectionChangedListener. It does not
work. It always returns selection is empty when I do select some item in
the combo. Could you please tell me what's wrong with the code?
acctNumberCombo = new ComboViewer(parent, SWT.SINGLE|SWT.DROP_DOWN);
acctNumberCombo.setContentProvider(new ArrayContentProvider());

acctNumberCombo.addSelectionChangedListener(new
ISelectionChangedListener(){
StructuredSelection selected;
public void selectionChanged(SelectionChangedEvent event) {
selected = (StructuredSelection)event.getSelection();
System.out.println(selected.getClass().getName());
if( (selected!=null)&&(!selected.isEmpty()) ){
System.out.println(selected.getFirstElement());
}else{
System.out.println("Selection is empty!");
}
}
});
Re: ComboViewer Add SelectionChangedListener does not work [message #329378 is a reply to message #329374] Sun, 22 June 2008 05:08 Go to previous message
Eclipse UserFriend
Originally posted by: malloovidio.bluewin.ch

Hao,

your code seems to work fine for me in Eclipse 3.4 RC1. How are you trying
to select an item from the combo (drop-down-list/cursor/free-text+ENTER)?

Regards,
Ovidio


hao wrote:
> I use the following code to add SelectionChangedListener. It does not
> work. It always returns selection is empty when I do select some item in
> the combo. Could you please tell me what's wrong with the code?
> acctNumberCombo = new ComboViewer(parent,
> SWT.SINGLE|SWT.DROP_DOWN);
> acctNumberCombo.setContentProvider(new ArrayContentProvider());
>
> acctNumberCombo.addSelectionChangedListener(new
> ISelectionChangedListener(){
> StructuredSelection selected;
> public void selectionChanged(SelectionChangedEvent event) {
> selected = (StructuredSelection)event.getSelection();
> System.out.println(selected.getClass().getName());
> if( (selected!=null)&&(!selected.isEmpty()) ){
> System.out.println(selected.getFirstElement());
> }else{
> System.out.println("Selection is empty!");
> }
> }
> });
>
Previous Topic:How to set Default "Rus As" > launchShortcut to F11 or Ctrl+F11 selection
Next Topic:dealing with multi-byte characters in editor
Goto Forum:
  


Current Time: Thu May 08 19:28:57 EDT 2025

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

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

Back to the top