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 11:28 Go to next message
Mikel Ugarte is currently offline Mikel Ugarte
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 10:49 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan Padegaonkar
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 10:19 Go to previous message
Mikel Ugarte is currently offline Mikel Ugarte
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: Thu Apr 24 11:33:08 EDT 2014

Powered by FUDForum. Page generated in 0.02504 seconds