Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » How to access to a SWTBotTreeItem CellRenderer?
How to access to a SWTBotTreeItem CellRenderer? [message #719974] Mon, 29 August 2011 15:28 Go to next message
Mikel Ugarte is currently offline Mikel UgarteFriend
Messages: 2
Registered: August 2011
Junior Member
Hi,

I'm doing some tests with SWTBot, and I need to set a value in a tree cell which renderer is a ComboBox ?

Does anyone already do that ?

Can we get the tree item's cell renderer ?

Thanks
(no subject) [message #720422 is a reply to message #719974] Tue, 30 August 2011 14:49 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
On 8/29/11 8:28 AM, Mikel Ugarte wrote:
> Hi,
>
> I'm doing some tests with SWTBot, and I need to set a value in a tree
> cell which renderer is a ComboBox ?
> Does anyone already do that ?
> Can we get the tree item's cell renderer ?
> Thanks


There's a test (http://goo.gl/r2757) in SWTBot that clicks on a cell and
edits the contents of a textbox in that tablecell. You'd need something
similar for combobox.

- Ketan
Re: (no subject) [message #722369 is a reply to message #720422] Mon, 05 September 2011 14:19 Go to previous message
Mikel Ugarte is currently offline Mikel UgarteFriend
Messages: 2
Registered: August 2011
Junior Member
Hi,

Thansk for the reply,

I found an answer to my question on the patch proposed in this eclipse's bug :
[HTTPS]bugs[dot]eclipse[dot]org/bugs/show_bug[dot]cgi?id=282408

/**
* Return the cell editor control associated to the TreeItem.
*
* @param item the tree item
* @param clazz Text or CCombo are the only one supported for now
* @return The associated SWTBot adapter for the control.
*/
public static AbstractSWTBot< ? extends Widget > getCellEditor(final SWTBotTreeItem item,
final Class< ? extends Widget > clazz) {
return UIThreadRunnable.syncExec(item.display, new Result< AbstractSWTBot< ? extends Widget > >() {
@Override
public AbstractSWTBot< ? extends Widget > run() {

if (!clazz.equals(Text.class) && !clazz.equals(CCombo.class)) {
throw new IllegalArgumentException("The class " + clazz.toString() + " is not supported yet!");
}
AbstractSWTBot< ? extends Widget > botEditorWidget;
final SWTBot bot = new SWTBot(item.widget.getParent());
final Matcher< ? extends Widget > matcher = widgetOfType(clazz);
final Widget editorWidget = bot.widget(matcher);
botEditorWidget = null;
if (clazz.equals(Text.class)) {
botEditorWidget = new SWTBotText((Text) editorWidget, matcher);
} else if (clazz.equals(CCombo.class)) {
botEditorWidget = new SWTBotCCombo((CCombo) editorWidget, matcher);
}
return botEditorWidget;
}
});
}

The method only works for cCombo and Text fields, but it covers my needs Smile

- Mikel
Previous Topic:How to determine button is available or not
Next Topic:Problem with RadioGroupFieldEditor
Goto Forum:
  


Current Time: Fri Apr 26 05:24:53 GMT 2024

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

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

Back to the top