Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 30126

Summary: [Dialogs] Initial selection problem using ElementListSelectionDialog
Product: [Eclipse Project] Platform Reporter: Mark Gaylard <mg>
Component: UIAssignee: Tod Creasey <Tod_Creasey>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P3    
Version: 2.1   
Target Milestone: 2.1 RC1   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Mark Gaylard CLA 2003-01-23 18:27:34 EST
I'm having trouble getting a dialog to open with the initial selection shown. 
I've stepped through the code and everything seems to be fine until I 
hit FilteredList$TableUpdater.run(). In here, it resets the table 
selection to item 0 (FilteredList.java line 509). This happens after the 
showSelection() method in Table.class. 

The order I'm creating/setting things is:

dialog = new ElementListSelectionDialog(...)
dialog.setIgnoreCase(false)
dialog.setMultipleSelection(true)
dialog.setElements(...)
dialog.setInitialSelection(...)
dialog.open()


The elements in the initialSelection list are in the elements list 
(FilteredList.setSelection(Object[] elements) finds and matches them ok). 

When the dialog is shown, the first element is selected, but only as a 
"non-focused control" selection.
Comment 1 Tod Creasey CLA 2003-01-24 13:18:02 EST
Moving to Lynne as she is looking at this dialog right now.
Comment 2 Lynne Kues CLA 2003-02-19 12:40:33 EST
Please give me an example demonstrating your problem.  I am running the current 
2.1 build.  If I run the following, the items are selected and focus is in the 
text field (as expected).

import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.dialogs.ElementListSelectionDialog;

/*
 * Created on Feb 19, 2003
 *
 * To change this generated comment go to 
 * Window>Preferences>Java>Code Generation>Code Template
 */

/**
 * @author lynne
 *
 * To change this generated comment go to 
 * Window>Preferences>Java>Code Generation>Code Template
 */
public class TestElementSelectionDialog {
    public static void main (String [] args) {
        Display display = new Display ();
        Shell shell = new Shell (display);
        ILabelProvider labelProvider = new LabelProvider();
        ElementListSelectionDialog dialog = new ElementListSelectionDialog
(shell, labelProvider);
        dialog.setIgnoreCase(false);
        dialog.setMultipleSelection(true);
        dialog.setElements(new String[] 
{"a123", "a456", "b789", "a111", "a222"});
        dialog.setInitialSelections(new String[] {"a123", "a456", "a111"});
        dialog.setFilter("a");
        dialog.open();
    }
}
Comment 3 Nick Edgar CLA 2003-02-19 13:49:36 EST
There were problems here which have been fixed.
Tod, please verify.
Comment 4 Tod Creasey CLA 2003-02-19 13:52:50 EST

*** This bug has been marked as a duplicate of 22991 ***