|
Lines 23-28
import org.eclipse.jubula.rc.common.implclasses.table.Cell;
Link Here
|
| 23 |
import org.eclipse.jubula.rc.common.tester.AbstractTableTester; |
23 |
import org.eclipse.jubula.rc.common.tester.AbstractTableTester; |
| 24 |
import org.eclipse.jubula.rc.common.tester.adapter.interfaces.ITableComponent; |
24 |
import org.eclipse.jubula.rc.common.tester.adapter.interfaces.ITableComponent; |
| 25 |
import org.eclipse.jubula.rc.common.tester.adapter.interfaces.ITextInputComponent; |
25 |
import org.eclipse.jubula.rc.common.tester.adapter.interfaces.ITextInputComponent; |
|
|
26 |
import org.eclipse.jubula.rc.common.util.Verifier; |
| 26 |
import org.eclipse.jubula.rc.swt.driver.DragAndDropHelperSwt; |
27 |
import org.eclipse.jubula.rc.swt.driver.DragAndDropHelperSwt; |
| 27 |
import org.eclipse.jubula.rc.swt.tester.adapter.StyledTextAdapter; |
28 |
import org.eclipse.jubula.rc.swt.tester.adapter.StyledTextAdapter; |
| 28 |
import org.eclipse.jubula.rc.swt.tester.adapter.TableAdapter; |
29 |
import org.eclipse.jubula.rc.swt.tester.adapter.TableAdapter; |
|
Lines 306-312
public class TableTester extends AbstractTableTester {
Link Here
|
| 306 |
"getCellBounds", //$NON-NLS-1$ |
307 |
"getCellBounds", //$NON-NLS-1$ |
| 307 |
new IRunnable() { |
308 |
new IRunnable() { |
| 308 |
public Object run() { |
309 |
public Object run() { |
| 309 |
TableItem ti = table.getItem(row); |
310 |
TableItem ti = table.getItem(row); |
| 310 |
int column = (table.getColumnCount() > 0 || col > 0) |
311 |
int column = (table.getColumnCount() > 0 || col > 0) |
| 311 |
? col : 0; |
312 |
? col : 0; |
| 312 |
org.eclipse.swt.graphics.Rectangle r = |
313 |
org.eclipse.swt.graphics.Rectangle r = |
|
Lines 661-664
public class TableTester extends AbstractTableTester {
Link Here
|
| 661 |
pressOrReleaseModifiers(dndHelper.getModifier(), false); |
662 |
pressOrReleaseModifiers(dndHelper.getModifier(), false); |
| 662 |
} |
663 |
} |
| 663 |
} |
664 |
} |
|
|
665 |
|
| 666 |
/** |
| 667 |
* Verifies whether the checkbox in the row of the selected cell |
| 668 |
* is checked |
| 669 |
* |
| 670 |
* @param checked true if checkbox in cell should be selected, false otherwise |
| 671 |
* @throws StepExecutionException If no cell is selected or the verification fails. |
| 672 |
*/ |
| 673 |
public void rcVerifyCheckboxInSelectedRow(boolean checked) |
| 674 |
throws StepExecutionException { |
| 675 |
int row = ((ITableComponent) getComponent()).getSelectedCell().getRow(); |
| 676 |
verifyCheckboxInRow(checked, row); |
| 677 |
} |
| 678 |
|
| 679 |
/** |
| 680 |
* Verifies whether the checkbox in the row under the mouse pointer is checked |
| 681 |
* |
| 682 |
* @param checked true if checkbox in cell is selected, false otherwise |
| 683 |
*/ |
| 684 |
public void rcVerifyCheckboxInRowAtMousePosition(boolean checked) { |
| 685 |
int row = getCellAtMousePosition().getRow(); |
| 686 |
verifyCheckboxInRow(checked, row); |
| 687 |
} |
| 688 |
|
| 689 |
/** |
| 690 |
* Verifies whether the checkbox in the row with the given |
| 691 |
* <code>index</code> is checked |
| 692 |
* |
| 693 |
* @param checked true if checkbox in cell is selected, false otherwise |
| 694 |
* @param row the row-index of the cell in which the checkbox-state should be verified |
| 695 |
*/ |
| 696 |
private void verifyCheckboxInRow(boolean checked, final int row) { |
| 697 |
Boolean checkIndex = ((Boolean)getEventThreadQueuer().invokeAndWait( |
| 698 |
"rcVerifyTableCheckboxIndex", new IRunnable() { //$NON-NLS-1$ |
| 699 |
public Object run() throws StepExecutionException { |
| 700 |
Table table = getTable(); |
| 701 |
if ((table.getStyle() & SWT.CHECK) == 0) { |
| 702 |
throw new StepExecutionException( |
| 703 |
"No checkbox found", //$NON-NLS-1$ |
| 704 |
EventFactory.createActionError( |
| 705 |
TestErrorEvent.CHECKBOX_NOT_FOUND)); |
| 706 |
} |
| 707 |
return new Boolean(table.getItem(row). |
| 708 |
getChecked()); |
| 709 |
} |
| 710 |
})); |
| 711 |
Verifier.equals(checked, checkIndex.booleanValue()); |
| 712 |
} |
| 713 |
|
| 714 |
/** |
| 715 |
* Toggles the checkbox in the row under the Mouse Pointer |
| 716 |
*/ |
| 717 |
public void rcToggleCheckboxInRowAtMousePosition() { |
| 718 |
toggleCheckboxInRow(getCellAtMousePosition().getRow()); |
| 719 |
} |
| 720 |
|
| 721 |
/** |
| 722 |
* Toggles the checkbox in the selected row |
| 723 |
*/ |
| 724 |
public void rcToggleCheckboxInSelectedRow() { |
| 725 |
int row = ((Integer) getEventThreadQueuer().invokeAndWait( |
| 726 |
"get Selection index", new IRunnable() { //$NON-NLS-1$ |
| 727 |
public Object run() throws StepExecutionException { |
| 728 |
return new Integer(getTable().getSelectionIndex()); |
| 729 |
} |
| 730 |
})).intValue(); |
| 731 |
toggleCheckboxInRow(row); |
| 732 |
} |
| 733 |
|
| 734 |
/** |
| 735 |
* Toggles the checkbox in the row with the given index |
| 736 |
* @param row the index |
| 737 |
*/ |
| 738 |
private void toggleCheckboxInRow(final int row) { |
| 739 |
|
| 740 |
if (row == -1) { |
| 741 |
getEventThreadQueuer().invokeAndWait( |
| 742 |
"No Selection", new IRunnable() { //$NON-NLS-1$ |
| 743 |
public Object run() throws StepExecutionException { |
| 744 |
throw new StepExecutionException( |
| 745 |
"No Selection found ", //$NON-NLS-1$ |
| 746 |
EventFactory.createActionError( |
| 747 |
TestErrorEvent.NO_SELECTION)); |
| 748 |
} |
| 749 |
}); |
| 750 |
} |
| 751 |
|
| 752 |
((ITableComponent) getComponent()).scrollCellToVisible(row, 0); |
| 753 |
|
| 754 |
final Table table = getTable(); |
| 755 |
|
| 756 |
org.eclipse.swt.graphics.Rectangle itemBounds = |
| 757 |
(org.eclipse.swt.graphics.Rectangle) getEventThreadQueuer(). |
| 758 |
invokeAndWait( |
| 759 |
"getTableItem", //$NON-NLS-1$ |
| 760 |
new IRunnable() { |
| 761 |
public Object run() throws StepExecutionException { |
| 762 |
return table.getItem(row).getBounds(); |
| 763 |
} |
| 764 |
}); |
| 765 |
|
| 766 |
int itemHeight = itemBounds.height; |
| 767 |
|
| 768 |
// Creates a Rectangle with bounds around the checkbox of the row |
| 769 |
org.eclipse.swt.graphics.Rectangle cbxBounds = |
| 770 |
new org.eclipse.swt.graphics.Rectangle(0, |
| 771 |
itemBounds.y, itemBounds.x, itemHeight); |
| 772 |
|
| 773 |
// Performs a click in the middle of the Rectangle |
| 774 |
getRobot().click(table, cbxBounds, ClickOptions.create().left(). |
| 775 |
setScrollToVisible(false), |
| 776 |
itemBounds.x / 2, true, itemHeight / 2, true); |
| 777 |
} |
| 664 |
} |
778 |
} |