Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » How to access Sirius edition table's cell editor from SWTBot?
How to access Sirius edition table's cell editor from SWTBot? [message #1836885] Sun, 17 January 2021 16:44 Go to next message
Yufei Zhou is currently offline Yufei ZhouFriend
Messages: 44
Registered: March 2020
Member
Hi,

I am trying to use SWTBot to test my sirius rcp application. There are some edition tables in my app, and I want to automatically test the cell editors in those edition tables. However, I've met a problem. The cells in the edition table can be double clicked and then user can edit directly in it. My problem is that I cannot find a way to trigger the double click action for a selected cell using SWTBot.

I've tried SWTBotTreeItem.dobleClick, but that method cannot locate to a specified cell(column). I then tried the AbstractSWTBotTreeItem.doubleClickXY method, but the method seems doesn't work at all.

Is there any way to trigger the double click action in the specified edition table cell using SWTBot? Any advice helps.

Thanks.
Yufei Zhou
Re: How to access Sirius edition table's cell editor from SWTBot? [message #1836896 is a reply to message #1836885] Mon, 18 January 2021 09:10 Go to previous messageGo to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 391
Registered: December 2015
Senior Member
Did you check sirius own swtbot tests? Maybe you can find something there.
Re: How to access Sirius edition table's cell editor from SWTBot? [message #1836902 is a reply to message #1836896] Mon, 18 January 2021 10:56 Go to previous messageGo to next message
Steve Monnier is currently offline Steve MonnierFriend
Messages: 508
Registered: May 2011
Senior Member
Hello,

Indeed, you can look at the method org.eclipse.sirius.tests.swtbot.ManualAirdModificationTest.directEditLabel(SWTBotEditor, String, char) or org.eclipse.sirius.tests.swtbot.table.CellEditionTest.testEditBooleanCellWithOtherColumnOnSameFeatureName() for examples on how we proceed to edit a table cell.

For SWTBot, a table is handled as a tree where a treeItem is a line of cells. Therefore, if you want to modify a cell, you will first navigate to its line. You can access it by its index or by the current value of one of its cell.

By index:
SWTBotTreeItem[] items = table.getTable().getAllItems();
items[1].select();

By value:
SWTBotTreeItem tableItem = editor.bot().tree().getTreeItem(oldValue);
tableItem.select();

Now that you have the line, you can click on the cell you want to edit by its index, for instance: tableItem.click(2);

This will set focus on the cell you want to edit. After that, as a user you would only need to "press the keyboard keys", that's why we added this helper: SWTBotUtils.directEditWithKeyboard(tableTree.widget, newValue);

Best regards,
Steve


Steve Monnier - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: How to access Sirius edition table's cell editor from SWTBot? [message #1836917 is a reply to message #1836902] Mon, 18 January 2021 15:52 Go to previous messageGo to next message
Yufei Zhou is currently offline Yufei ZhouFriend
Messages: 44
Registered: March 2020
Member
Thank you very much for the guide. However, the real problem I'm facing is that I obtained the edition table's viewer and added a double click listener on it, but I cannot simulate the double click action in SWTBot. I guessed that editing table by double clicking has something similar with my custom double click event, but it seems that the method for testing table editor doesn't work on my custom event. Do you have any idea how to simulate my own double click listener( added from table's viewer.addDoubleClickListener) using SWTBot?
Re: How to access Sirius edition table's cell editor from SWTBot? [message #1836936 is a reply to message #1836917] Tue, 19 January 2021 10:06 Go to previous message
Steve Monnier is currently offline Steve MonnierFriend
Messages: 508
Registered: May 2011
Senior Member
Hello,

Ok I see. You should look at the method org.eclipse.swtbot.swt.finder.widgets.SiriusSWTBotTableItem.doubleClick(). I have not found a test using it, but you can look at all the event it is notifying the table in order to process the double click.

Best regards,
Steve


Steve Monnier - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Previous Topic:Help with Edge creation tool
Next Topic:Upload my own odesign file to Sirius Web
Goto Forum:
  


Current Time: Thu Apr 15 03:18:06 GMT 2021

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

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

Back to the top