Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Struckmann2015-08-24 05:10:51 -0400
committerSebastian Struckmann2015-08-25 10:14:56 -0400
commit5349730d91bad257bae7a3b1102dc524adfc1f17 (patch)
treea50fc406990521ccc6deda3d58cd0602e154b641
parent9b55d0c43c664d5a9ca917613f9119bbc921e844 (diff)
downloadorg.eclipse.jubula.core-5349730d91bad257bae7a3b1102dc524adfc1f17.tar.gz
org.eclipse.jubula.core-5349730d91bad257bae7a3b1102dc524adfc1f17.tar.xz
org.eclipse.jubula.core-5349730d91bad257bae7a3b1102dc524adfc1f17.zip
Sprint task - SWT - check property at mouse position in table
-rw-r--r--org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/components/SWTCell.java129
-rw-r--r--org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/tester/TableTester.java7
-rw-r--r--org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/tester/adapter/TableAdapter.java10
3 files changed, 140 insertions, 6 deletions
diff --git a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/components/SWTCell.java b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/components/SWTCell.java
new file mode 100644
index 000000000..4ca5d4fd2
--- /dev/null
+++ b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/components/SWTCell.java
@@ -0,0 +1,129 @@
+package org.eclipse.jubula.rc.swt.components;
+
+import org.apache.commons.beanutils.BasicDynaClass;
+import org.apache.commons.beanutils.DynaBean;
+import org.apache.commons.beanutils.DynaClass;
+import org.apache.commons.beanutils.DynaProperty;
+import org.eclipse.jubula.rc.common.implclasses.table.Cell;
+import org.eclipse.jubula.rc.common.logger.AutServerLogger;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.TableItem;
+
+/**
+ * This class represents a cell in a SWT Table.
+ * @author BREDEX GmbH
+ * @created 21.08.2015
+ */
+public class SWTCell extends Cell implements DynaBean {
+
+ /** the logger */
+ private static AutServerLogger log = new AutServerLogger(
+ SWTCell.class);
+
+ /** constant for background property */
+ private static final String BACKGROUND = "background"; //$NON-NLS-1$
+ /** constant for bounds property */
+ private static final String BOUNDS = "bounds"; //$NON-NLS-1$
+ /** constant for font property */
+ private static final String FONT = "font"; //$NON-NLS-1$
+ /** constant for foreground property */
+ private static final String FOREGROUND = "foreground"; //$NON-NLS-1$
+ /** constant for grayed property */
+ private static final String GRAYED = "grayed"; //$NON-NLS-1$
+ /** constant for image property */
+ private static final String IMAGE = "image"; //$NON-NLS-1$
+ /** constant for style property */
+ private static final String STYLE = "style"; //$NON-NLS-1$
+ /** constant for text property */
+ private static final String TEXT = "text"; //$NON-NLS-1$
+
+ /** the dynamic bean */
+ private DynaBean m_bean;
+
+ /** the properties */
+ private DynaProperty[] m_properties = new DynaProperty[] {
+ new DynaProperty(BACKGROUND, Color.class),
+ new DynaProperty(BOUNDS, Rectangle.class),
+ new DynaProperty(FONT, Font.class),
+ new DynaProperty(FOREGROUND, Color.class),
+ new DynaProperty(GRAYED, Boolean.class),
+ new DynaProperty(IMAGE, Image.class),
+ new DynaProperty(STYLE, Integer.class),
+ new DynaProperty(TEXT, String.class)
+ };
+
+
+ /**
+ * Creates a new Cell instance.
+ * @param row The zero based row of the cell.
+ * @param col The zero based column of the cell.
+ * @param item The table item containing the actual cell
+ */
+ public SWTCell(int row, int col, TableItem item) {
+ super(row, col);
+ try {
+ m_bean = new BasicDynaClass("cell", null, m_properties).newInstance(); //$NON-NLS-1$
+ set(BACKGROUND, item.getBackground(col));
+ set(BOUNDS, item.getBounds(col));
+ set(FONT, item.getFont(col));
+ set(FOREGROUND, item.getForeground(col));
+ set(GRAYED, item.getGrayed());
+ set(IMAGE, item.getImage(col));
+ set(STYLE, item.getStyle());
+ set(TEXT, item.getText(col));
+ } catch (IllegalAccessException e) {
+ log.error("Error while creating instance of SWT table cell", e); //$NON-NLS-1$
+ } catch (InstantiationException e) {
+ log.error("Error while creating instance of SWT table cell", e); //$NON-NLS-1$
+ }
+ }
+
+ /** {@inheritDoc} */
+ public boolean contains(String name, String key) {
+ return m_bean.contains(name, key);
+ }
+
+ /** {@inheritDoc} */
+ public Object get(String name) {
+ return m_bean.get(name);
+ }
+
+ /** {@inheritDoc} */
+ public Object get(String name, int index) {
+ return m_bean.get(name, index);
+ }
+
+ /** {@inheritDoc} */
+ public Object get(String name, String key) {
+ return m_bean.get(name, key);
+ }
+
+ /** {@inheritDoc} */
+ public DynaClass getDynaClass() {
+ return m_bean.getDynaClass();
+ }
+
+ /** {@inheritDoc} */
+ public void remove(String name, String key) {
+ m_bean.remove(name, key);
+ }
+
+ /** {@inheritDoc} */
+ public void set(String name, Object value) {
+ m_bean.set(name, value);
+ }
+
+ /** {@inheritDoc} */
+ public void set(String name, int index, Object value) {
+ m_bean.set(name, index, value);
+ }
+
+ /** {@inheritDoc} */
+ public void set(String name, String key, Object value) {
+ m_bean.set(name, key, value);
+ }
+
+}
diff --git a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/tester/TableTester.java b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/tester/TableTester.java
index a62e1d692..0059ca379 100644
--- a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/tester/TableTester.java
+++ b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/tester/TableTester.java
@@ -23,6 +23,7 @@ import org.eclipse.jubula.rc.common.tester.AbstractTableTester;
import org.eclipse.jubula.rc.common.tester.adapter.interfaces.ITableComponent;
import org.eclipse.jubula.rc.common.tester.adapter.interfaces.ITextInputComponent;
import org.eclipse.jubula.rc.common.util.Verifier;
+import org.eclipse.jubula.rc.swt.components.SWTCell;
import org.eclipse.jubula.rc.swt.driver.DragAndDropHelperSwt;
import org.eclipse.jubula.rc.swt.tester.adapter.StyledTextAdapter;
import org.eclipse.jubula.rc.swt.tester.adapter.TableAdapter;
@@ -151,7 +152,8 @@ public class TableTester extends AbstractTableTester {
itemBounds.width,
itemBounds.height);
if (absRect.contains(awtMousePos)) {
- cell = new Cell(rowCount, col);
+ cell = new SWTCell(rowCount, col,
+ table.getItem(rowCount));
break;
}
}
@@ -770,7 +772,6 @@ public class TableTester extends AbstractTableTester {
/** {@inheritDoc} */
protected Object getNodeAtMousePosition() throws StepExecutionException {
- StepExecutionException.throwUnsupportedAction();
- return null;
+ return getCellAtMousePosition();
}
}
diff --git a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/tester/adapter/TableAdapter.java b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/tester/adapter/TableAdapter.java
index 9f507a7e7..3e6c77fda 100644
--- a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/tester/adapter/TableAdapter.java
+++ b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/tester/adapter/TableAdapter.java
@@ -471,8 +471,12 @@ public class TableAdapter extends ControlAdapter implements ITableComponent {
/**
* {@inheritDoc}
*/
- public String getPropertyValueOfCell(String name, Object cell) {
- StepExecutionException.throwUnsupportedAction();
- return null;
+ public String getPropertyValueOfCell(final String name, final Object cell) {
+ return getEventThreadQueuer().invokeAndWait(
+ "getPropertyValueOfCell", new IRunnable<String>() { //$NON-NLS-1$
+ public String run() {
+ return getRobot().getPropertyValue(cell, name);
+ }
+ });
}
}

Back to the top