// Find the right-most index for a Condition column
 private int findConditionColumnIndex(ConditionCol col) {
   int index = 0;
   boolean bMatched = false;
   List<DynamicColumn<DTColumnConfig>> columns = widget.getGridWidget().getColumns();
   for (int iCol = 0; iCol < columns.size(); iCol++) {
     DynamicColumn<DTColumnConfig> column = columns.get(iCol);
     DTColumnConfig modelColumn = column.getModelColumn();
     if (modelColumn instanceof RowNumberCol) {
       index = iCol;
     } else if (modelColumn instanceof DescriptionCol) {
       index = iCol;
     } else if (modelColumn instanceof MetadataCol) {
       index = iCol;
     } else if (modelColumn instanceof AttributeCol) {
       index = iCol;
     } else if (modelColumn instanceof ConditionCol) {
       if (isEquivalentConditionColumn((ConditionCol) modelColumn, col)) {
         index = iCol;
         bMatched = true;
       } else if (!bMatched) {
         index = iCol;
       }
     }
   }
   return index;
 }
  public void updateSystemControlledColumnValues() {

    final DynamicData data = widget.getGridWidget().getData();
    final List<DynamicColumn<DTColumnConfig>> columns = widget.getGridWidget().getColumns();

    for (DynamicColumn<DTColumnConfig> col : columns) {

      DTColumnConfig modelColumn = col.getModelColumn();

      if (modelColumn instanceof RowNumberCol) {
        updateRowNumberColumnValues(data, col.getColumnIndex());

      } else if (modelColumn instanceof AttributeCol) {

        // Update Salience values
        AttributeCol attrCol = (AttributeCol) modelColumn;
        if (attrCol.getAttribute().equals(RuleAttributeWidget.SALIENCE_ATTR)) {
          if (attrCol.isUseRowNumber()) {
            updateSalienceColumnValues(data, col.getColumnIndex(), attrCol.isReverseOrder());
          }

          // Ensure Salience cells are rendered with the correct Cell
          col.setCell(cellFactory.getCell(attrCol));
          col.setSystemControlled(attrCol.isUseRowNumber());
          col.setSortable(!attrCol.isUseRowNumber());
        }
      }
    }
  }
 // Retrieves the DynamicColumn relating to the Model column or null if it
 // cannot be found
 private DynamicColumn<DTColumnConfig> getDynamicColumn(DTColumnConfig modelCol) {
   DynamicColumn<DTColumnConfig> column = null;
   List<DynamicColumn<DTColumnConfig>> columns = widget.getGridWidget().getColumns();
   for (DynamicColumn<DTColumnConfig> dc : columns) {
     if (dc.getModelColumn().equals(modelCol)) {
       column = dc;
       break;
     }
   }
   return column;
 }
 // Find the right-most index for a Metadata column
 private int findMetadataColumnIndex() {
   int index = 0;
   List<DynamicColumn<DTColumnConfig>> columns = widget.getGridWidget().getColumns();
   for (int iCol = 0; iCol < columns.size(); iCol++) {
     DynamicColumn<DTColumnConfig> column = columns.get(iCol);
     DTColumnConfig modelColumn = column.getModelColumn();
     if (modelColumn instanceof RowNumberCol) {
       index = iCol;
     } else if (modelColumn instanceof DescriptionCol) {
       index = iCol;
     } else if (modelColumn instanceof MetadataCol) {
       index = iCol;
     }
   }
   return index;
 }
  /**
   * Update the Decision Table model with the columns contained in the grid. The Decision Table
   * controls indexing of new columns to preserve grouping of column types. If the order of columns
   * is important to client-code this can be called to ensure columns within the model are
   * synchronised with the Decision Table.
   */
  public void scrapeColumns() {

    // Clear existing definition
    model.getMetadataCols().clear();
    model.getAttributeCols().clear();
    model.getConditionCols().clear();
    model.getActionCols().clear();

    RowNumberCol rnCol = null;
    DescriptionCol descCol = null;

    // Extract column information
    for (DynamicColumn<DTColumnConfig> column : widget.getGridWidget().getColumns()) {
      DTColumnConfig modelCol = column.getModelColumn();
      if (modelCol instanceof RowNumberCol) {
        rnCol = (RowNumberCol) modelCol;
        model.setRowNumberCol(rnCol);

      } else if (modelCol instanceof DescriptionCol) {
        descCol = (DescriptionCol) modelCol;
        model.setDescriptionCol(descCol);

      } else if (modelCol instanceof MetadataCol) {
        MetadataCol tc = (MetadataCol) modelCol;
        model.getMetadataCols().add(tc);

      } else if (modelCol instanceof AttributeCol) {
        AttributeCol tc = (AttributeCol) modelCol;
        model.getAttributeCols().add(tc);

      } else if (modelCol instanceof ConditionCol) {
        ConditionCol tc = (ConditionCol) modelCol;
        model.getConditionCols().add(tc);

      } else if (modelCol instanceof ActionCol) {
        ActionCol tc = (ActionCol) modelCol;
        model.getActionCols().add(tc);
      }
      modelCol.setWidth(column.getWidth());
      modelCol.setHideColumn(!column.isVisible());
    }
  }
 /**
  * Check whether the given Cell can accept "otherwise" values
  *
  * @param cell
  * @return true if the Cell can accept "otherwise" values
  */
 protected boolean canAcceptOtherwiseValues(CellValue<?> cell) {
   Coordinate c = cell.getCoordinate();
   MergableGridWidget<DTColumnConfig> grid = widget.getGridWidget();
   DynamicColumn<DTColumnConfig> column = grid.getColumns().get(c.getCol());
   return canAcceptOtherwiseValues(column.getModelColumn());
 }