CheckboxTableViewer problem [message #27968] |
Tue, 17 March 2009 01:45  |
Eclipse User |
|
|
|
Hello.
I am using a CheckboxTableViewer in one of my dialogs I like to test
with SWTBot.
Is it possible to check rows using SWTBot?
I tried something like:
final Table table = bot.table().widget;
table.getDisplay().syncExec(new Runnable(){
@Override
public void run() {
table.getItems()[0].setChecked(true);
table.getItems()[1].setChecked(true);
table.update();
}
});
But this does not change the underlying model (the input of the viewer).
Is there a solution?
Best regards,
Kai
|
|
|
Re: CheckboxTableViewer problem [message #28008 is a reply to message #27968] |
Tue, 17 March 2009 03:04   |
Eclipse User |
|
|
|
On 17/3/09 07:15, Kai Schlamp wrote:
> But this does not change the underlying model (the input of the viewer).
> Is there a solution?
Looking at CheckboxTableViewer#handleSelect, you'll need to call
widget.notifyListeners() with SWT.Selection with the event details as
needed by that method.
I'd recommend filing a bug, unless you'd like to maintain this piece of
code yourself :)
-- Ketan
|
|
|
Re: CheckboxTableViewer problem [message #28126 is a reply to message #28008] |
Tue, 17 March 2009 11:33   |
Eclipse User |
|
|
|
Hello Ketan.
Comments below.
Ketan Padegaonkar schrieb:
> Looking at CheckboxTableViewer#handleSelect, you'll need to call
> widget.notifyListeners() with SWT.Selection with the event details as
> needed by that method.
I just tried it with a SWT.Selection (and also with SWT.CHECK), but the
CheckStateListener of the viewer (where the model modifications are
done) is not called.
final Table table = bot.table().widget;
table.getDisplay().syncExec(new Runnable() {
@Override
public void run() {
table.getItem(1).setChecked(true);
Event event = new Event();
event.widget = table;
event.time = (int) System.currentTimeMillis();
event.display = table.getDisplay();
event.index = 1;
event.item = table.getItem(1);
table.notifyListeners(SWT.Selection, event);
table.update();
}
});
Any suggestion?
> I'd recommend filing a bug, unless you'd like to maintain this piece of
> code yourself :)
I don't think I am the right one for this job. As you can see above I
don't have any clue how SWT works on the low level (and also don't have
many time resources at the moment to dig into it more).
But when we solve this problem here together, then it should be easy to
integrate that one in SWTBot. Perhaps with something like
bot.table().check(int row) as API.
I filed a bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=268948
Best regards,
Kai
|
|
|
|
Re: CheckboxTableViewer problem [message #28241 is a reply to message #28202] |
Tue, 17 March 2009 16:46   |
Eclipse User |
|
|
|
Thanks Kay-Uwe ... that works great.
I closed the bug report.
Best regards,
Kai
Kay-Uwe Graw schrieb:
> I would recommend using SWTBotTableItem
>
> SWTBotTable table = bot.table();
>
> SWTBotTableItem tableItem = table.getTableItem(rowIndex);
>
> tableItem.check();
>
>
>
|
|
|
Re: CheckboxTableViewer problem [message #28318 is a reply to message #28202] |
Tue, 17 March 2009 17:08   |
Eclipse User |
|
|
|
Thanks for that, I was wondering where that support disappeared after
I'd intentionally added it :)
-- Ketan
On 17/3/09 21:11, Kay-Uwe Graw wrote:
> I would recommend using SWTBotTableItem
>
> SWTBotTable table = bot.table();
>
> SWTBotTableItem tableItem = table.getTableItem(rowIndex);
>
> tableItem.check();
>
>
>
|
|
|
Re: CheckboxTableViewer problem [message #550006 is a reply to message #28202] |
Wed, 28 July 2010 17:29  |
Eclipse User |
|
|
|
Hi,
This example seems to be very useful, but I receive an Exception when I try to execute it. The Exception is:
java.lang.IllegalArgumentException: The table does not have the style SWT.CHECK
I took a print screen of the application to illustrate what I'm saying.

I think that, maybe, the SWTBotTableItem is a whole row, but I need to check a cell. Am I right?
Thanks in advance.
Victor
|
|
|
Powered by
FUDForum. Page generated in 0.03524 seconds