[OT?] TableViewer with multiple colums [message #144870] |
Thu, 16 October 2003 09:58  |
Eclipse User |
|
|
|
Originally posted by: tcn.spamgourmet.com
Hi!
Well, this probably does not belong to this group but there are no
appropriate ones...
I tried to write a plugin for eclipse. So, I have a TableViewer and I even
already have two colums:
TableColumn column;
column = new TableColumn(viewer.getTable(), SWT.LEFT);
column.setText("One");
column = new TableColumn(viewer.getTable(), SWT.LEFT);
column.setText("Two");
Works. But how do I add text to the various columns? The following code in
the Provider does not work:
public String getColumnText(Object obj, int index)
{
Line l = (Line)obj;
switch (index)
{
case 0 :
return getText(l.getLevel());
case 1 :
return getText(l.getMessage());
}
return "N/A";
}
Only the first column is filled with l.getLevel(), the second remains empty.
Why?
And by the way how do I dynamically add lines to the table?
Thanks :)
Timo
|
|
|
Re: [OT?] TableViewer with multiple colums [message #144879 is a reply to message #144870] |
Thu, 16 October 2003 10:15   |
Eclipse User |
|
|
|
Hi Timo,
I just compared your code to something similar that's working and it
looks pretty much identical, so:
1. Have you tried returning a "test" string from case 1... you say the
column remains empty, but I would expect it to contain "N/A" if this was
not being successfully matched.
2. could getText(l.getMessage()) be returning a null or empty string?
cheers
Rich
Timo Nentwig wrote:
> Hi!
>
> Well, this probably does not belong to this group but there are no
> appropriate ones...
>
> I tried to write a plugin for eclipse. So, I have a TableViewer and I even
> already have two colums:
>
> TableColumn column;
>
> column = new TableColumn(viewer.getTable(), SWT.LEFT);
> column.setText("One");
>
> column = new TableColumn(viewer.getTable(), SWT.LEFT);
> column.setText("Two");
>
> Works. But how do I add text to the various columns? The following code in
> the Provider does not work:
>
> public String getColumnText(Object obj, int index)
> {
> Line l = (Line)obj;
>
> switch (index)
> {
> case 0 :
> return getText(l.getLevel());
> case 1 :
> return getText(l.getMessage());
> }
> return "N/A";
> }
>
> Only the first column is filled with l.getLevel(), the second remains empty.
>
> Why?
>
> And by the way how do I dynamically add lines to the table?
>
> Thanks :)
> Timo
|
|
|
|
|
|
|
|
Re: [OT?] TableViewer with multiple colums [message #145560 is a reply to message #145521] |
Fri, 17 October 2003 05:52  |
Eclipse User |
|
|
|
Originally posted by: tcn.spamgourmet.com
rich boakes wrote:
> The problem was the position of setLabelProvider()... I re-jigged your
> sample code and which now works on the my "TestPlugin".
>
> Solved?
YES! Cool, thanks!
....but the wizard should generate a comment for such stuff...
Timo
|
|
|
Powered by
FUDForum. Page generated in 0.03129 seconds