|
Re: ComboViewer Add SelectionChangedListener does not work [message #329378 is a reply to message #329374] |
Sun, 22 June 2008 09:08 |
Eclipse User |
|
|
|
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!");
> }
> }
> });
>
|
|
|
Powered by
FUDForum. Page generated in 0.01945 seconds