|
|
Re: How can you enable a cell editor in a tree viewer with multiple columns? [message #489760 is a reply to message #489753] |
Mon, 05 October 2009 15:29  |
Eclipse User |
|
|
|
Thanks for the response. I actually figured out over the weekend that there is a TreeItem api to get the bounds for a particular Cell. Here is what I implemented:
/**
*
*/
package com.............
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundExcep tion;
import org.eclipse.swtbot.swt.finder.results.Result;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
/**
* @author doconnor
*
*/
public class SWTBotTreeItemExt extends SWTBotTreeItem {
/**
*
* @param treeItem - A SWTBotTreeItem object from which we can get a TreeItem widget
* @throws WidgetNotFoundException
*/
public SWTBotTreeItemExt(SWTBotTreeItem treeItem)
throws WidgetNotFoundException {
super(treeItem.widget);
}
/**
* Overrides the behavior of {@link SWTBotTreeItem#click()} such that this method now
* calls {@link SWTBotTreeItemExt#click(int)} with an index of 0
* This method will click on the first column cell
*/
@Override
public SWTBotTreeItem click() {
return click(0);
}
/**
* @param column - Index of the column on which the caller wants to click
* @return
*
* Clicks on the current TreeItem in the column specified by <code>column</code>
*/
public SWTBotTreeItem click(final int column){
assertEnabled();
Rectangle cellBounds = syncExec(new Result<Rectangle>() {
public Rectangle run() {
Rectangle r = widget.getBounds(column);
return r;
}
});
int x = (cellBounds.width / 2);
clickXY(cellBounds.x + x, cellBounds.y + (cellBounds.height / 2));
return this;
}
public String getText(int column){
return cell(column);
}
}
This seems to work fine. It is then up to the caller to find the editor that is created
|
|
|
Powered by
FUDForum. Page generated in 0.04486 seconds