Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [swtbot-dev] Bug 282408

CC'ing Mariot since he may not be on the group.

On 25/08/09 7:32 PM, Pascal Gelinas wrote:

Those class would present a functional view of a cell editor, i.e.
how a user uses a cell editor normally. I don't think usual mock-up
methods would work here (such as #setText(String)) since a cell
editor is a JFace component that adds listeners to the widget it is
attached on

The problem is see right now is how to find those cell editors...
would something like:

More on this problem later.

public AbstractCellEditor<T extends Widget> cellEditor(Widget widget)
{
if (widget instanceof Text)
{
return textCellEditor((Text) widget);
}
}

This may not work in cases when people implement their own cell editors. Also goes against the open-close principle[1] which SWTBot takes to heart :)

or
SWTBotText class:
public TextCellEditor textCellEditor()
{
return new TextCellEditor(widget);
}

This seems like a better idea. Support for new CellEditors is just adding one class (and not having to modify the factory, and a messy type check). This is also useful when users have custom cell editors that are not general purpose like the ones provided by eclipse.

be appropriate? This has the inconvenient of creating an adapter of a
cell editor where it might not be one. It has the advantage of being
really easy to implement.

Or let the bot do some obscure search:

You are correct in pointing out that cell editors are just some intelligent listeners to swt widgets.

Coming back to your original problem of finding cell editors (which I *think* is the real problem):

You may possibly have an implementation where the user specifies what kind of cell editor it is, alebit in a non-intrusive way that does not obscure the readability[2] :) Sometimes the simplest thing to do is to do nothing at all[3] :P

public void doubleClickOnCell() throws Exception{
  table.doubleClick(0, 0);
  bot.text("Column 1 => Item 0", 0).setText("foo");
}

Thoughts, brickbats ?

[1] - http://www.c2.com/cgi/wiki?OpenClosedPrinciple
[1] - http://www.objectmentor.com/resources/articles/ocp.pdf

[2] - http://github.com/ketan/swtbot/blob/master/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotTableDoubleClickTest.java#L35

[3] - http://acc6.its.brooklyn.cuny.edu/~phalsall/texts/taote-v3.html#3

--
Ketan
http://studios.thoughtworks.com/twist | http://twitter.com/ketanpkr


Back to the top