ListSelectionDialog [message #459766] |
Mon, 15 August 2005 21:10  |
Eclipse User |
|
|
|
Originally posted by: john.brecht.sri.com
I need to use the ListSelectionDialog, but I can find no documentation
for it. What is the 2nd argument in its constructor meant to be? All
the javadocs say is:
input - the root element to populate this dialog with
Is there some other class I ought to use instead to get a user's
selection from a list of Strings?
thanks!
-john
|
|
|
|
|
|
|
Re: ListSelectionDialog [message #459789 is a reply to message #459788] |
Tue, 16 August 2005 21:00   |
Eclipse User |
|
|
|
Hi,
John Brecht wrote:
> The user will select a String from a list of Strings. Are you saying I
> should just pass a new empty String?
You should pass whatever the list should show. As you want to show a
"list as strings", an easy choice would be to pass a "list of strings":
List<String> oder String[] or whatever object you use to store your
strings.
You would then use the ContentProvider to extract the list of choices
from your input element. For an arrays or lists you can use
ArrayContentProvider and LabelProvider.
A simple example:
new ListSelectionDialog(
window.getShell(),
new String[] { "Choice 1", "Choice 2", "Choice 3" },
new ArrayContentProvider(),
new LabelProvider(),
"Please choose!"
).open();
or
new ListSelectionDialog(
window.getShell(),
Arrays.asList("Choice 1", "Choice 2", "Choice 3"),
new ArrayContentProvider(),
new LabelProvider(),
"Please choose!"
).open();
Mike
|
|
|
Re: ListSelectionDialog [message #459819 is a reply to message #459789] |
Wed, 17 August 2005 18:30  |
Eclipse User |
|
|
|
Originally posted by: john.brecht.sri.com
Ah, OK, so the "input" is the data itself. I would have thought that
this would be the ContentProvider's job, and the fact that the API calls
this the "root element" (singular) did not make me think it was meant to
be the list of items (plural)...
Is there a good tutorial out there for SWT? The Eclipse documentation is
not terribly readable or useful.
-john
Michael Forster wrote:
> Hi,
>
> John Brecht wrote:
>
>> The user will select a String from a list of Strings. Are you saying I
>> should just pass a new empty String?
>
>
> You should pass whatever the list should show. As you want to show a
> "list as strings", an easy choice would be to pass a "list of strings":
> List<String> oder String[] or whatever object you use to store your
> strings.
>
> You would then use the ContentProvider to extract the list of choices
> from your input element. For an arrays or lists you can use
> ArrayContentProvider and LabelProvider.
>
> A simple example:
>
> new ListSelectionDialog(
> window.getShell(),
> new String[] { "Choice 1", "Choice 2", "Choice 3" },
> new ArrayContentProvider(),
> new LabelProvider(),
> "Please choose!"
> ).open();
>
> or
>
> new ListSelectionDialog(
> window.getShell(),
> Arrays.asList("Choice 1", "Choice 2", "Choice 3"),
> new ArrayContentProvider(),
> new LabelProvider(),
> "Please choose!"
> ).open();
>
>
>
> Mike
|
|
|
Powered by
FUDForum. Page generated in 0.04144 seconds