Class BaseGrid

java.lang.Object
com.onenetwork.platform.tools.test.ui.components.ext.base.BaseGrid
Direct Known Subclasses:
GridIE

public class BaseGrid
extends java.lang.Object
Base class for Grid component.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected org.json.JSONArray columnsArray  
    protected java.util.Map<java.lang.String,​org.json.JSONObject> columnsByHeader  
    protected Component currentEditor  
    protected static java.lang.String DISABLE_BULK_EDIT  
    protected static java.lang.String ENABLE_BULK_EDIT  
    protected static java.lang.String REQUIREDNESS_CHAR  
    protected static java.lang.String REQUIREDNESS_PATTERN  
  • Constructor Summary

    Constructors 
    Constructor Description
    BaseGrid​(UIContext context, org.openqa.selenium.WebElement gridEl, Grid grid)  
  • Method Summary

    Modifier and Type Method Description
    void addColumn​(java.lang.String columnName)
    Add (show) a column in the Grid
    void addColumns​(java.lang.String[] columnNames)
    Add (show) provided columns in the grid
    void advancedSort​(java.lang.String firstColumnName, java.lang.String firstSortOrder, java.lang.String secondColmnName, java.lang.String secondSortOrder)
    Perform an advanced search using the cell header context menu
    void checkAllRows()
    Checks the checkbox in the top-left-most cell to check/uncheck all Grid rows.
    void checkRow​(int rowIndex)
    Select the desired row
    void clickColumnHeaderToSort​(java.lang.String headerName)
    Sort the data according to the header column
    protected void clickRowChecker​(org.openqa.selenium.WebElement checkBox)  
    void copyColumns​(int rowIndex, java.lang.String... columnNames)  
    void disableBulkEdit()  
    void dragRoleFromAvailToSelected​(java.lang.String roleName, Grid targetGrid)
    Drag a Role from one Grid to another Grid
    void enableBulkEdit()  
    protected org.json.JSONObject findColumn​(java.lang.String header)  
    protected org.json.JSONObject findColumnById​(java.lang.String id)  
    org.openqa.selenium.WebElement getCell​(int rowNum, int colIndex)
    Gets cell WebElement
    org.openqa.selenium.WebElement getCell​(int rowNum, java.lang.String header)
    Gets cell WebElement
    java.lang.String getCellValue​(int rowNum, java.lang.String header)
    Fetch the cell value by row number and header label or field name
    int getColumnCount()
    Get the header columns count including hidden.
    Component getEditor()
    Returns the current grid editor.
    java.lang.String getErrorMessage​(int rowNum)
    Returns error message for first found error icon in the specified row.
    java.lang.String getErrorMessage​(int rowNum, java.lang.String columnName)
    Checks whether the cell has some error icon, if yes then returns error message for that icon
    int getGridColumnIndexByName​(java.lang.String dataIndex)
    Get the index of the column in Grid
    protected java.util.List<org.openqa.selenium.WebElement> getHeaderCellList()  
    java.util.List<java.lang.String> getHeaderColumnNames()
    Get the list of labelled Column header names.
    int getRowCount()  
    java.util.List<org.openqa.selenium.WebElement> getRows()  
    protected void initializeColumnsArray()  
    boolean isEditable​(java.lang.String headerName)
    Checks whether the column is editable or not
    boolean isErrorIcon​(int rowIndex, java.lang.String columnName)
    Checks whether the cell has some error icon or not
    boolean isRequired​(java.lang.String headerName)
    Checks whether the value to the column is required or not
    void openAuditTrail​(int rowIndex)
    Opens child audit trail from grid of model form
    void openCellHeaderContextMenu​(java.lang.String headerName)
    Open the right-click context menu for a cell header
    void pasteToAllRows()  
    void pasteToRow​(int rowIndex)  
    void removeColumn​(java.lang.String columnName)
    Remove (hide) a column from Grid
    void removeRow​(int rowIndex)
    Removes row from grid of model form
    void selectCellHeaderMenuItem​(java.lang.String itemName)
    Select options from context menu except Advanced Sorting and Columns
    protected void setCurrentEditor​(java.lang.String xtype)  
    Grid startEditing​(int rowNum, java.lang.String header)
    Starts editing at the provided row index and column header.
    Grid startEditing​(int rowNum, java.lang.String header, java.lang.String xtype)
    Variation of startEditing(int, String) which allows you to explicitly specify the xtype for the cell editor.
    void stopEditing()
    Stops any grid editing.
    void unselectCopiedColumns​(int rowIndex, java.lang.String... columnNames)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • getRowCount

      public int getRowCount()
    • getRows

      public java.util.List<org.openqa.selenium.WebElement> getRows()
    • startEditing

      public Grid startEditing​(int rowNum, java.lang.String header)
      Starts editing at the provided row index and column header. You can then call getEditor() to return the Component instance of the grid editor. This method returns this (the Grid) instance so that it can be chained with getEditor().
      Parameters:
      rowNum -
      header -
      Returns:
    • startEditing

      public Grid startEditing​(int rowNum, java.lang.String header, java.lang.String xtype)
      Variation of startEditing(int, String) which allows you to explicitly specify the xtype for the cell editor. You should only need to use this if the other method throws an exception stating that it cannot find the xtype within the grid's column model config.
      Parameters:
      rowNum -
      header -
      xtype -
      Returns:
    • setCurrentEditor

      protected void setCurrentEditor​(java.lang.String xtype)
    • getEditor

      public Component getEditor()
      Returns the current grid editor. This method is intended to be called immediately after startEditing(int, String), and because that method returns this Grid, they can be chained together. If this method is called and no cell is being edited, it will return null.
      Returns:
    • stopEditing

      public void stopEditing()
      Stops any grid editing. Any changes made within the grid editor are accepted (assuming they are valid).
    • getCell

      public org.openqa.selenium.WebElement getCell​(int rowNum, java.lang.String header)
      Gets cell WebElement
      Parameters:
      rowNum - row number
      header - column header label
      Returns:
      WebElement of the cell
    • getCell

      public org.openqa.selenium.WebElement getCell​(int rowNum, int colIndex)
      Gets cell WebElement
      Parameters:
      rowNum - row number
      colIndex - column index
      Returns:
      WebElement of the cell
    • getCellValue

      public java.lang.String getCellValue​(int rowNum, java.lang.String header)
      Fetch the cell value by row number and header label or field name
      Parameters:
      rowNum - row number (starting from zero)
      header - column label or column id
      Returns:
      text value of the given cell
    • findColumn

      protected org.json.JSONObject findColumn​(java.lang.String header)
    • findColumnById

      protected org.json.JSONObject findColumnById​(java.lang.String id)
    • getHeaderCellList

      protected java.util.List<org.openqa.selenium.WebElement> getHeaderCellList()
    • initializeColumnsArray

      protected void initializeColumnsArray()
    • getGridColumnIndexByName

      public int getGridColumnIndexByName​(java.lang.String dataIndex)
      Get the index of the column in Grid
      Parameters:
      dataIndex - name of the ext "data index" in the grid store
      Returns:
    • checkRow

      public void checkRow​(int rowIndex)
      Select the desired row
      Parameters:
      rowIndex - (starts from 0)
    • clickRowChecker

      protected void clickRowChecker​(org.openqa.selenium.WebElement checkBox)
    • checkAllRows

      public void checkAllRows()
      Checks the checkbox in the top-left-most cell to check/uncheck all Grid rows.
    • clickColumnHeaderToSort

      public void clickColumnHeaderToSort​(java.lang.String headerName)
      Sort the data according to the header column
      Parameters:
      headerName -
    • openCellHeaderContextMenu

      public void openCellHeaderContextMenu​(java.lang.String headerName)
      Open the right-click context menu for a cell header
      Parameters:
      headerName - cell header label
    • selectCellHeaderMenuItem

      public void selectCellHeaderMenuItem​(java.lang.String itemName)
      Select options from context menu except Advanced Sorting and Columns
      Parameters:
      itemName - menu item name
    • advancedSort

      public void advancedSort​(java.lang.String firstColumnName, java.lang.String firstSortOrder, java.lang.String secondColmnName, java.lang.String secondSortOrder)
      Perform an advanced search using the cell header context menu
      Parameters:
      firstColumnName - first column to sort
      firstSortOrder - first column's sort order
      secondColumnName - second column to sort
      secondSortOrder - second column's sort order
    • removeColumn

      public void removeColumn​(java.lang.String columnName)
      Remove (hide) a column from Grid
      Parameters:
      cloumnName - column header label
    • addColumn

      public void addColumn​(java.lang.String columnName)
      Add (show) a column in the Grid
      Parameters:
      columnName - column header label
    • addColumns

      public void addColumns​(java.lang.String[] columnNames)
      Add (show) provided columns in the grid
      Parameters:
      columnNames - column headers label
    • getHeaderColumnNames

      public java.util.List<java.lang.String> getHeaderColumnNames()
      Get the list of labelled Column header names.
      Returns:
    • getColumnCount

      public int getColumnCount()
      Get the header columns count including hidden.
      Returns:
    • isEditable

      public boolean isEditable​(java.lang.String headerName)
      Checks whether the column is editable or not
      Parameters:
      headerName -
      Returns:
    • isRequired

      public boolean isRequired​(java.lang.String headerName)
      Checks whether the value to the column is required or not
      Parameters:
      headerName -
      Returns:
    • isErrorIcon

      public boolean isErrorIcon​(int rowIndex, java.lang.String columnName)
      Checks whether the cell has some error icon or not
      Parameters:
      rowIndex -
      columnName -
      Returns:
    • getErrorMessage

      public java.lang.String getErrorMessage​(int rowNum, java.lang.String columnName)
      Checks whether the cell has some error icon, if yes then returns error message for that icon
      Parameters:
      rowNum -
      columnName -
      Returns:
    • getErrorMessage

      public java.lang.String getErrorMessage​(int rowNum)
      Returns error message for first found error icon in the specified row.
      Parameters:
      rowNum -
      Returns:
    • dragRoleFromAvailToSelected

      public void dragRoleFromAvailToSelected​(java.lang.String roleName, Grid targetGrid)
      Drag a Role from one Grid to another Grid
      Parameters:
      roleName -
      targetGrid -
    • enableBulkEdit

      public void enableBulkEdit()
    • disableBulkEdit

      public void disableBulkEdit()
    • pasteToAllRows

      public void pasteToAllRows()
    • copyColumns

      public void copyColumns​(int rowIndex, java.lang.String... columnNames)
      Parameters:
      roleIndex - - provide index of row from which we copy column content
      columnName - - this parameter accept value as - Select all editable columns [If we have to Select all editable columns] or mention list of columns
    • unselectCopiedColumns

      public void unselectCopiedColumns​(int rowIndex, java.lang.String... columnNames)
      Parameters:
      roleIndex - - provide index of row from which we have to unselect copied column content
      columnName - - this parameter accept value as - Unselect all editable columns [If we have to Unselect all editable columns] or mention list of columns
    • pasteToRow

      public void pasteToRow​(int rowIndex)
      Parameters:
      roleIndex - - provide index of row to which we have to paste copied column content
    • removeRow

      public void removeRow​(int rowIndex)
      Removes row from grid of model form
      Parameters:
      rowIndex -
    • openAuditTrail

      public void openAuditTrail​(int rowIndex)
      Opens child audit trail from grid of model form
      Parameters:
      rowIndex -