/** * Update an ActionSetFieldCol column * * @param origCol The existing column in the grid * @param editColumn A copy (not clone) of the original column containing the modified values */ public void updateColumn(final ActionSetFieldCol origColumn, final ActionSetFieldCol editColumn) { if (origColumn == null) { throw new IllegalArgumentException("origColumn cannot be null"); } if (editColumn == null) { throw new IllegalArgumentException("editColumn cannot be null"); } boolean bRedrawColumn = false; boolean bRedrawHeader = false; DynamicColumn<DTColumnConfig> column = getDynamicColumn(origColumn); // Update column's visibility if (origColumn.isHideColumn() != editColumn.isHideColumn()) { setColumnVisibility(origColumn, !editColumn.isHideColumn()); } // Change in column's binding forces an update and redraw if FactField // is different; otherwise only need to update and redraw if the // FieldType has changed if (!isEqualOrNull(origColumn.getBoundName(), editColumn.getBoundName())) { if (!isEqualOrNull(origColumn.getFactField(), editColumn.getFactField())) { bRedrawColumn = true; updateCellsForDataType(editColumn, column); } } else if (!isEqualOrNull(origColumn.getFactField(), editColumn.getFactField())) { bRedrawColumn = true; updateCellsForDataType(editColumn, column); } // Update column's cell content if the Optional Value list has changed if (!isEqualOrNull(origColumn.getValueList(), editColumn.getValueList())) { bRedrawColumn = updateCellsForOptionValueList(editColumn, column); } // Update column header in Header Widget if (!origColumn.getHeader().equals(editColumn.getHeader())) { bRedrawHeader = true; } // Copy new values into original column definition populateModelColumn(origColumn, editColumn); if (bRedrawColumn) { int maxColumnIndex = widget.getGridWidget().getColumns().size() - 1; widget.getGridWidget().redrawColumns(column.getColumnIndex(), maxColumnIndex); } if (bRedrawHeader) { // Schedule redraw event after column has been redrawn Scheduler.get() .scheduleFinally( new ScheduledCommand() { public void execute() { widget.getHeaderWidget().redraw(); } }); } }
// Copy values from one (transient) model column into another private void populateModelColumn( final ActionSetFieldCol col, final ActionSetFieldCol editingCol) { col.setBoundName(editingCol.getBoundName()); col.setType(editingCol.getType()); col.setFactField(editingCol.getFactField()); col.setHeader(editingCol.getHeader()); col.setValueList(editingCol.getValueList()); col.setDefaultValue(editingCol.getDefaultValue()); col.setHideColumn(editingCol.isHideColumn()); col.setUpdate(editingCol.isUpdate()); }