Ejemplo n.º 1
0
  /**
   * Selects the cell of the Table.<br>
   * With the xPos, yPos, xUnits and yUnits the click position inside the cell can be defined.
   *
   * @param row The row of the cell.
   * @param rowOperator The row header operator
   * @param col The column of the cell.
   * @param colOperator The column header operator
   * @param clickCount The number of clicks with the right mouse button
   * @param xPos what x position
   * @param xUnits should x position be pixel or percent values
   * @param yPos what y position
   * @param yUnits should y position be pixel or percent values
   * @param extendSelection Should this selection be part of a multiple selection
   * @param button what mouse button should be used
   * @throws StepExecutionException If the row or the column is invalid
   */
  public void rcSelectCell(
      final String row,
      final String rowOperator,
      final String col,
      final String colOperator,
      final int clickCount,
      final int xPos,
      final String xUnits,
      final int yPos,
      final String yUnits,
      final String extendSelection,
      int button)
      throws StepExecutionException {
    TreeTableOperationContext adapter = getContext();
    final int implRow = adapter.getRowFromString(row, rowOperator);
    final int implCol = adapter.getColumnFromString(col, colOperator, implRow != -1);
    final boolean isExtendSelection = extendSelection.equals(ValueSets.BinaryChoice.yes.rcValue());
    if (log.isDebugEnabled()) {
      log.debug("Selecting row, col: " + row + ", " + col); // $NON-NLS-1$//$NON-NLS-2$
    }

    Rectangle cellBounds;
    Object source = getRealComponent();
    // if row is header and col is existing
    if (implRow == -1 && implCol > -1) {
      cellBounds = adapter.getHeaderBounds(implCol);
      source = adapter.getTableHeader();
    } else {
      cellBounds = adapter.scrollCellToVisible(implRow, implCol);
    }
    ClickOptions clickOptions = ClickOptions.create();
    clickOptions.setClickCount(clickCount).setScrollToVisible(false);
    clickOptions.setMouseButton(button);
    try {
      if (isExtendSelection) {
        getRobot().keyPress(getRealComponent(), getExtendSelectionModifier());
      }
      getRobot()
          .click(
              source,
              cellBounds,
              clickOptions,
              xPos,
              xUnits.equalsIgnoreCase(ValueSets.Unit.pixel.rcValue()),
              yPos,
              yUnits.equalsIgnoreCase(ValueSets.Unit.pixel.rcValue()));
    } finally {
      if (isExtendSelection) {
        getRobot().keyRelease(getRealComponent(), getExtendSelectionModifier());
      }
    }
  }