Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » ListSelectionDialog
ListSelectionDialog [message #459766] Tue, 16 August 2005 01:10 Go to next message
Eclipse UserFriend
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 #459767 is a reply to message #459766] Tue, 16 August 2005 03:40 Go to previous messageGo to next message
Michael Forster is currently offline Michael ForsterFriend
Messages: 4
Registered: July 2009
Junior Member
John Brecht wrote:
> 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

You should definitely read the JFace documentation in the Ecplipse help:
http://help.eclipse.org/help31/topic/org.eclipse.platform.do c.isv/guide/jface_viewers.htm,
especially "Viewer architecture".

.... An input element is the main object that the viewer is displaying
(or editing). From the viewer's point of view, an input element can be
any object at all. It does not assume any particular interface is
implemented by the input element. (We'll see why in a moment when we
look at content providers.) ...

Mike
Re: ListSelectionDialog [message #459786 is a reply to message #459767] Tue, 16 August 2005 21:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: john.brecht.sri.com

That documentation is still unclear - "any object at all", "does not
assume any particular interface"... And there are no examples either.
What might I use? A Label? TextField? Combo?

-john

Michael Forster wrote:
> John Brecht wrote:
>
>> 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
>
>
> You should definitely read the JFace documentation in the Ecplipse help:
> http://help.eclipse.org/help31/topic/org.eclipse.platform.do c.isv/guide/jface_viewers.htm,
> especially "Viewer architecture".
>
> ... An input element is the main object that the viewer is displaying
> (or editing). From the viewer's point of view, an input element can be
> any object at all. It does not assume any particular interface is
> implemented by the input element. (We'll see why in a moment when we
> look at content providers.) ...
>
> Mike
Re: ListSelectionDialog [message #459787 is a reply to message #459786] Tue, 16 August 2005 21:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sunil_kamath.nohotspammail.com

"John Brecht" <john.brecht@sri.com> wrote in message
news:ddtkm9$afo$1@news.eclipse.org...
> That documentation is still unclear - "any object at all", "does not
> assume any particular interface"... And there are no examples either. What
> might I use? A Label? TextField? Combo?
>
> -john
>
Anything you like, as long as your content provider and label provider can
interpret it.
That being said, a SWT widget would be the last thing that would come to
mind.
I would suggest the model object for whatever you wish the user to select.
---
Sunil
Re: ListSelectionDialog [message #459788 is a reply to message #459787] Tue, 16 August 2005 22:04 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: john.brecht.sri.com

The user will select a String from a list of Strings. Are you saying I
should just pass a new empty String?

-john

Sunil Kamath wrote:
> "John Brecht" <john.brecht@sri.com> wrote in message
> news:ddtkm9$afo$1@news.eclipse.org...
>
>>That documentation is still unclear - "any object at all", "does not
>>assume any particular interface"... And there are no examples either. What
>>might I use? A Label? TextField? Combo?
>>
>>-john
>>
>
> Anything you like, as long as your content provider and label provider can
> interpret it.
> That being said, a SWT widget would be the last thing that would come to
> mind.
> I would suggest the model object for whatever you wish the user to select.
> ---
> Sunil
>
>
Re: ListSelectionDialog [message #459789 is a reply to message #459788] Wed, 17 August 2005 01:00 Go to previous messageGo to next message
Michael Forster is currently offline Michael ForsterFriend
Messages: 4
Registered: July 2009
Junior Member
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 22:30 Go to previous message
Eclipse UserFriend
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
Previous Topic:JFace: NoClassDefFoundError
Next Topic:Is it possible to convert a image file or Acrobat file?
Goto Forum:
  


Current Time: Tue Apr 23 15:39:43 GMT 2024

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

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

Back to the top