Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » CheckboxTableViewer problem
CheckboxTableViewer problem [message #27968] Tue, 17 March 2009 01:45 Go to next message
Kai Schlamp is currently offline Kai SchlampFriend
Messages: 344
Registered: July 2009
Senior Member
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 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
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 Go to previous messageGo to next message
Kai Schlamp is currently offline Kai SchlampFriend
Messages: 344
Registered: July 2009
Senior Member
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 #28202 is a reply to message #28126] Tue, 17 March 2009 15:41 Go to previous messageGo to next message
Kay-Uwe Graw is currently offline Kay-Uwe GrawFriend
Messages: 24
Registered: July 2009
Junior Member
I would recommend using SWTBotTableItem

SWTBotTable table = bot.table();

SWTBotTableItem tableItem = table.getTableItem(rowIndex);

tableItem.check();
Re: CheckboxTableViewer problem [message #28241 is a reply to message #28202] Tue, 17 March 2009 16:46 Go to previous messageGo to next message
Kai Schlamp is currently offline Kai SchlampFriend
Messages: 344
Registered: July 2009
Senior Member
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 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
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 Go to previous message
Victor  is currently offline Victor Friend
Messages: 16
Registered: June 2010
Junior Member
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.

http://www.students.ic.unicamp.br/~ra064940/table.JPG

I think that, maybe, the SWTBotTableItem is a whole row, but I need to check a cell. Am I right?

Thanks in advance.

Victor
Previous Topic:How can I get a TableItem's text?
Next Topic:view the result in HTML format
Goto Forum:
  


Current Time: Thu Dec 12 14:41:32 GMT 2024

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

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

Back to the top