/** * Will calculate the new value after tick update processing for the cell at the given * coordinates, trying to update the value represented by that cell. The update will only be * processed if the new value is valid. * * @param command The command to process * @param selectedPosition The coordinates of the cell on which the tick update should be executed */ private void updateSingleCell(TickUpdateCommand command, PositionCoordinate selectedPosition) { ILayerCell cell = selectionLayer.getCellByPosition( selectedPosition.columnPosition, selectedPosition.rowPosition); IConfigRegistry configRegistry = command.getConfigRegistry(); IEditableRule editableRule = configRegistry.getConfigAttribute( EditConfigAttributes.CELL_EDITABLE_RULE, DisplayMode.EDIT, cell.getConfigLabels().getLabels()); IDataValidator validator = configRegistry.getConfigAttribute( EditConfigAttributes.DATA_VALIDATOR, DisplayMode.EDIT, cell.getConfigLabels().getLabels()); if (editableRule.isEditable(cell, configRegistry)) { // process the tick update Object newValue = getNewCellValue(command, cell); // validate the value try { if (validator == null || validator.validate(cell, configRegistry, newValue)) { selectionLayer.doCommand( new UpdateDataCommand( selectionLayer, selectedPosition.columnPosition, selectedPosition.rowPosition, newValue)); } else { log.warn( "Tick update failed for cell at " + selectedPosition + " and value " + newValue //$NON-NLS-1$ //$NON-NLS-2$ + ". New value is not valid!"); //$NON-NLS-1$ } } catch (Exception e) { log.warn( "Tick update failed for cell at " + selectedPosition + " and value " + newValue //$NON-NLS-1$ //$NON-NLS-2$ + ". " + e.getLocalizedMessage()); // $NON-NLS-1$ } } }
protected ExecutionStatusKind doCommand(EditCellCommand command) { ILayerCell cell = command.getCell(); Composite parent = command.getParent(); IConfigRegistry configRegistry = command.getConfigRegistry(); IEditableRule rule = (IEditableRule) configRegistry.getConfigAttribute( EditConfigAttributes.CELL_EDITABLE_RULE, DisplayMode.EDIT, cell.getConfigLabels().getLabels()); if (rule.isEditable(cell, configRegistry)) { return editCell(cell, parent, cell.getDataValue(), configRegistry); } return ExecutionStatusKind.FAIL_ROLLBACK; }