Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Hein2015-08-25 06:33:32 -0400
committerMarcel Hein2015-08-25 06:33:32 -0400
commit8f4c37633f88cf01114246a56803678437adad91 (patch)
tree5f7c11fed07529ba65d8651bc02d026cda0640b5
parente9655b8d5190d194040ebe095c492ece4157002f (diff)
downloadorg.eclipse.jubula.core-8f4c37633f88cf01114246a56803678437adad91.tar.gz
org.eclipse.jubula.core-8f4c37633f88cf01114246a56803678437adad91.tar.xz
org.eclipse.jubula.core-8f4c37633f88cf01114246a56803678437adad91.zip
Sprint task - Allow treetable actions in JavaFX to use column values as well as integers. Corrected behavior for not equals operator
-rw-r--r--org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/TableAdapter.java156
-rw-r--r--org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/TreeTableOperationContext.java35
2 files changed, 118 insertions, 73 deletions
diff --git a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/TableAdapter.java b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/TableAdapter.java
index bbca43060..aa968bda9 100644
--- a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/TableAdapter.java
+++ b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/TableAdapter.java
@@ -17,6 +17,18 @@ import java.util.List;
import java.util.Set;
import java.util.concurrent.Callable;
+import javafx.collections.ObservableList;
+import javafx.geometry.Point2D;
+import javafx.scene.Node;
+import javafx.scene.Parent;
+import javafx.scene.control.TableCell;
+import javafx.scene.control.TableColumn;
+import javafx.scene.control.TablePosition;
+import javafx.scene.control.TableView;
+import javafx.scene.control.TextField;
+import javafx.scene.control.cell.TextFieldTableCell;
+import javafx.scene.layout.Pane;
+
import org.eclipse.jubula.rc.common.exception.RobotException;
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
import org.eclipse.jubula.rc.common.implclasses.table.Cell;
@@ -36,18 +48,6 @@ import org.eclipse.jubula.tools.internal.utils.StringParsing;
import com.sun.javafx.scene.control.skin.TableColumnHeader;
-import javafx.collections.ObservableList;
-import javafx.geometry.Point2D;
-import javafx.scene.Node;
-import javafx.scene.Parent;
-import javafx.scene.control.TableCell;
-import javafx.scene.control.TableColumn;
-import javafx.scene.control.TablePosition;
-import javafx.scene.control.TableView;
-import javafx.scene.control.TextField;
-import javafx.scene.control.cell.TextFieldTableCell;
-import javafx.scene.layout.Pane;
-
/**
* Adapter for a TableView(Table)
*
@@ -211,59 +211,12 @@ public class TableAdapter extends JavaFXComponentAdapter<TableView<?>>
@Override
public Integer call() throws Exception {
TableView table = getRealComponent();
- TableColumn<?, ?> column = null;
+
List<String> path = StringParsing.splitToList(colPath,
TestDataConstants.PATH_CHAR_DEFAULT,
TestDataConstants.ESCAPE_CHAR_DEFAULT, false);
- ObservableList<TableColumn> columns;
- if (colPath.contains("" + TestDataConstants.PATH_CHAR_DEFAULT)) { //$NON-NLS-1$
- columns = table.getColumns();
- } else {
- columns = table.getVisibleLeafColumns();
- }
- Iterator<String> pathIterator = path.iterator();
- String currCol = null;
- while (pathIterator.hasNext()) {
- try {
- currCol = pathIterator.next();
- int usrIdxCol = Integer.parseInt(currCol);
- if (usrIdxCol == 0) {
- usrIdxCol = usrIdxCol + 1;
- }
- int i = IndexConverter
- .toImplementationIndex(usrIdxCol);
- if (pathIterator.hasNext()) {
- columns = (columns.get(i)).getColumns();
- } else {
- column = columns.get(i);
- }
- } catch (NumberFormatException nfe) {
- try {
- if (path.size() <= 1) {
- columns = table.getColumns();
- }
- if (columns.size() <= 0) {
- throw new StepExecutionException(
- "No Columns", EventFactory.createActionError(//$NON-NLS-1$
- TestErrorEvent.
- NO_HEADER));
- }
- for (TableColumn c: columns) {
- String header = c.getText();
- if (MatchUtil.getInstance().match(
- header, currCol, op)) {
- column = c;
- if (pathIterator.hasNext()) {
- columns = c.getColumns();
- }
- break;
- }
- }
- } catch (IllegalArgumentException iae) {
- // do nothing here
- }
- }
- }
+ TableColumn<?, ?> column = determineColumn(colPath, op,
+ table, path);
if (column == null) {
throw new StepExecutionException("Column not found", //$NON-NLS-1$
EventFactory.createActionError(
@@ -279,6 +232,85 @@ public class TableAdapter extends JavaFXComponentAdapter<TableView<?>>
});
return result.intValue();
}
+
+ /**
+ * get column for the given path
+ * @param colPath the path
+ * @param op the operation
+ * @param table the table
+ * @param path the path as list
+ * @return the column or null if no column was found
+ */
+ private TableColumn<?, ?> determineColumn(final String colPath,
+ final String op, TableView table, List<String> path) {
+ ObservableList<TableColumn> columns;
+ if (colPath.contains("" + TestDataConstants.PATH_CHAR_DEFAULT)) { //$NON-NLS-1$
+ columns = table.getColumns();
+ } else {
+ columns = table.getVisibleLeafColumns();
+ }
+ Iterator<String> pathIterator = path.iterator();
+ String currCol = null;
+ TableColumn<?, ?> column = null;
+ while (pathIterator.hasNext()) {
+ try {
+ currCol = pathIterator.next();
+ int usrIdxCol = Integer.parseInt(currCol);
+ if (usrIdxCol == 0) {
+ usrIdxCol = usrIdxCol + 1;
+ }
+ int i = IndexConverter.toImplementationIndex(usrIdxCol);
+ if (MatchUtil.NOT_EQUALS == op) {
+ for (int j = 0; j < columns.size(); j++) {
+ if (j != i) {
+ if (pathIterator.hasNext()) {
+ columns = columns.get(j).getColumns();
+ } else {
+ column = columns.get(j);
+ }
+ }
+ }
+ } else {
+ try {
+ if (pathIterator.hasNext()) {
+ columns = columns.get(i).getColumns();
+ } else {
+ column = columns.get(i);
+ }
+ } catch (IndexOutOfBoundsException e) {
+ throw new StepExecutionException(
+ "Invalid Index: " + IndexConverter.toUserIndex(i), //$NON-NLS-1$
+ EventFactory.createActionError(
+ TestErrorEvent.INVALID_INDEX));
+ }
+ }
+ } catch (NumberFormatException nfe) {
+ try {
+ if (path.size() <= 1) {
+ columns = table.getColumns();
+ }
+ if (columns.size() <= 0) {
+ throw new StepExecutionException(
+ "No Columns", EventFactory.createActionError(//$NON-NLS-1$
+ TestErrorEvent.NO_HEADER));
+ }
+ for (TableColumn c : columns) {
+ String h = c.getText();
+ if (MatchUtil.getInstance().match(h, currCol, op)) {
+ column = c;
+ if (pathIterator.hasNext()) {
+ columns = c.getColumns();
+ }
+ break;
+ }
+ }
+ } catch (IllegalArgumentException iae) {
+ // do nothing here
+ }
+ }
+ }
+ return column;
+ }
@Override
public String getRowText(int row) {
diff --git a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/TreeTableOperationContext.java b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/TreeTableOperationContext.java
index f89f162ce..0b6aba44c 100644
--- a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/TreeTableOperationContext.java
+++ b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/adapter/TreeTableOperationContext.java
@@ -750,18 +750,31 @@ public class TreeTableOperationContext extends
usrIdxCol = usrIdxCol + 1;
}
int i = IndexConverter.toImplementationIndex(usrIdxCol);
- try {
- if (pathIterator.hasNext()) {
- columns = ((TreeTableColumn<?, ?>) columns.get(i))
- .getColumns();
- } else {
- column = (TreeTableColumn<?, ?>) columns.get(i);
+ if (MatchUtil.NOT_EQUALS == op) {
+ for (int j = 0; j < columns.size(); j++) {
+ if (j != i) {
+ if (pathIterator.hasNext()) {
+ columns = ((TreeTableColumn<?, ?>)
+ columns.get(j)).getColumns();
+ } else {
+ column = (TreeTableColumn<?, ?>) columns.get(j);
+ }
+ }
+ }
+ } else {
+ try {
+ if (pathIterator.hasNext()) {
+ columns = ((TreeTableColumn<?, ?>) columns.get(i))
+ .getColumns();
+ } else {
+ column = (TreeTableColumn<?, ?>) columns.get(i);
+ }
+ } catch (IndexOutOfBoundsException e) {
+ throw new StepExecutionException(
+ "Invalid Index: " + IndexConverter.toUserIndex(i), //$NON-NLS-1$
+ EventFactory.createActionError(
+ TestErrorEvent.INVALID_INDEX));
}
- } catch (IndexOutOfBoundsException e) {
- throw new StepExecutionException(
- "Invalid Index: " + IndexConverter.toUserIndex(i), //$NON-NLS-1$
- EventFactory.createActionError(
- TestErrorEvent.INVALID_INDEX));
}
} catch (NumberFormatException nfe) {
try {

Back to the top