// Note: this works because previous to calling this method it is
// checked
// if all cells have the same editor configured. Otherwise this
// method
// will have serious issues further on.
ICellEditor cellEditor = configRegistry.getConfigAttribute(
EditConfigAttributes.CELL_EDITOR, DisplayMode.EDIT, cells
.iterator().next().getConfigLabels().getLabels());
if (cells.size() == 1
|| (cells.size() > 1 && supportMultiEdit(cells, cellEditor,
configRegistry))) {
if (cellEditor.openMultiEditDialog()) {
// as the EditSelectionCommandHandler already ensured that
// all cells have the same
// configuration, we can simply use any cell for multi cell
// edit handling
ICellEditDialog dialog = CellEditDialogFactory
.createCellEditDialog(
parent != null ? parent.getShell() : null,
initialCanonicalValue, cells.iterator()
.next(), cellEditor, configRegistry);
int returnValue = dialog.open();
if (returnValue == Window.OK) {
for (ILayerCell selectedCell : cells) {
Object editorValue = dialog.getCommittedValue();
if (!(dialog.getEditType() == EditTypeEnum.SET)) {
editorValue = dialog.calculateValue(
selectedCell.getDataValue(),
editorValue);
}
ILayer layer = selectedCell.getLayer();
layer.doCommand(new UpdateDataCommand(layer,
selectedCell.getColumnPosition(),
selectedCell.getRowPosition(), editorValue));
}
}
} else {
// if the editor is configured to do not open a multi edit
// dialog for
// multi editing, we simply activate all editors for cells
// that are
// selected for multi editing
// this only works for editors that have no interactive
// control for
// editing, like for example the CheckBoxCellEditor that
// directly
// changes the value and closes right away.
for (ILayerCell cell : cells) {
ICellEditHandler editHandler = new InlineEditHandler(
cell.getLayer(), cell.getColumnPosition(),
cell.getRowPosition());
cellEditor.activateCell(parent, initialCanonicalValue,
EditModeEnum.INLINE, editHandler, cell,
configRegistry);
}
}
}