Example #1
0
 /**
  * @param mode current edit grid mode
  * @param rowNumber TableModel row index
  * @param colIndex TableModel column index
  * @return <code>true</code> means that the cell having the specified row and column index is
  *     editable, <code>false</code> otherwise
  */
 public final boolean isFieldEditable(int mode, int rowNumber, int colIndex) {
   if (colIndex < colProperties.length) {
     if (mode == Consts.INSERT) return colProperties[colIndex].isEditableOnInsert();
     else if (mode == Consts.EDIT) {
       if (grids != null
           && grids.isAllowInsertInEdit()
           && grids.getCurrentNumberOfNewRows() > 0
           && rowNumber
               >= grids.getVOListTableModel().getRowCount() - grids.getCurrentNumberOfNewRows())
         return colProperties[colIndex].isEditableOnInsert();
       else if (grids != null
           && grids.isEditOnSingleRow()
           && rowNumber != grids.getCurrentEditingRow()) return false;
       else return colProperties[colIndex].isEditableOnEdit();
     } else {
       //        if (colProperties[colIndex].getColumnType()==Column.TYPE_FILE)
       //          return true;
       //        else
       if (colProperties[colIndex].getColumnType() == Column.TYPE_BUTTON
           && ((ButtonColumn) colProperties[colIndex]).isEnableInReadOnlyMode()) return true;
       else if (colProperties[colIndex].getColumnType() == Column.TYPE_LINK) return true;
       else if (colProperties[colIndex].getColumnType() == Column.TYPE_CHECK
           && ((CheckBoxColumn) colProperties[colIndex]).isEnableInReadOnlyMode()) return true;
       return false;
     }
   } else if (mode == Consts.INSERT || mode == Consts.EDIT)
     // if the column index is related to an attribute not mapped with a grid column,
     // then it assumed that it's editable (if the the grid is on INSERT/EDIT mode...)
     return true;
   else return false;
 }