Home » Eclipse Projects » SWTBot » How to handle NatTable?
|
Re: How to handle NatTable? [message #664251 is a reply to message #664247] |
Fri, 08 April 2011 03:46 |
Felix Lu Messages: 12 Registered: April 2011 |
Junior Member |
|
|
http://wiki.eclipse.org/SWTBot/Testing_Custom_Controls
According to the above page, I've also tried to make a wrapper as below:
package org.felix.test;
import net.sourceforge.nattable.NatTable;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.results.VoidResult;
import org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot;
import org.hamcrest.SelfDescribing;
public class SWTBotNatTable extends AbstractSWTBot<NatTable> {
public SWTBotNatTable(NatTable w) throws WidgetNotFoundException {
this(w, null);
}
public SWTBotNatTable(NatTable w, SelfDescribing description) throws WidgetNotFoundException {
super(w, description);
}
public void setSelectionItem() {
asyncExec(new VoidResult() {
public void run() {
widget.setSelectedItem();
}
});
}
}
And there is an error in the last line widget.setSelectedItem()
I'm a tester and not familiar with coding, so I don't know how to solve this problem. Please advise, thanks.
[Updated on: Fri, 08 April 2011 03:47] Report message to a moderator
|
|
| |
Re: How to handle NatTable? [message #664822 is a reply to message #664796] |
Tue, 12 April 2011 08:18 |
Felix Lu Messages: 12 Registered: April 2011 |
Junior Member |
|
|
Almost resolved. The above code works fine now.
I wrongly added net.sourceforge.nattable.core-2.2.0.jar to Build Path and Runtime Classpath (as an External JAR).
The right way is to add it to plug-in dependencies (nattable core has been installed as a plugin in the target platform of our product).
There is one thing rest - complete the methods I need in SWTBotNatTable.class.
[Updated on: Tue, 12 April 2011 15:29] Report message to a moderator
|
|
| | |
Re: How to handle NatTable? [message #667748 is a reply to message #667241] |
Mon, 02 May 2011 03:53 |
Felix Lu Messages: 12 Registered: April 2011 |
Junior Member |
|
|
Hi Nicolas,
Thank you very much for the useful information.
I've managed to make the Double Click work too. I just changed the AbstractSWTBot's original notify(SWT.Selection, createSelectionEvent(SWT.BUTTON1)); to notify(SWT.MouseDown, createMouseEvent(x, y, 1, SWT.NONE, 1));
Now it is:
public void doubleClick(final int rowPosition, final int columnPosition) {
assertIsLegalCell(rowPosition, columnPosition);
asyncExec(new VoidResult() {
public void run() {
Rectangle cellBounds = widget.getBoundsByPosition(columnPosition, rowPosition);
doubleClickXY(cellBounds.x + (cellBounds.width / 2), cellBounds.y + (cellBounds.height / 2));
}
});
}
protected void doubleClickXY(int x, int y) {
log.debug(MessageFormat.format("Double-clicking on {0}", widget)); //$NON-NLS-1$
notify(SWT.MouseEnter);
notify(SWT.MouseMove);
notify(SWT.Activate);
notify(SWT.FocusIn);
notify(SWT.MouseDown, createMouseEvent(x, y, 1, SWT.NONE, 1));
notify(SWT.MouseUp, createMouseEvent(x, y, 1, SWT.BUTTON1, 1));
notify(SWT.MouseDown, createMouseEvent(x, y, 1, SWT.NONE, 1));
notify(SWT.MouseDoubleClick, createMouseEvent(x, y, 1, SWT.BUTTON1, 2));
notify(SWT.MouseHover);
notify(SWT.MouseMove);
notify(SWT.MouseExit);
notify(SWT.Deactivate);
notify(SWT.FocusOut);
log.debug(MessageFormat.format("Double-clicked on {0}", widget)); //$NON-NLS-1$
}
I'll try the context menu. Thanks again!
|
|
| | | | | |
Goto Forum:
Current Time: Wed Feb 05 16:58:38 GMT 2025
Powered by FUDForum. Page generated in 0.04796 seconds
|