use of org.drools.workbench.screens.scenariosimulation.client.widgets.ScenarioGridColumn in project drools-wb by kiegroup.
the class SetGridCellValueCommand method internalExecute.
@Override
protected void internalExecute(ScenarioSimulationContext context) {
final ScenarioSimulationContext.Status status = context.getStatus();
AbstractScesimModel<AbstractScesimData> abstractScesimModel = context.getAbstractScesimModelByGridWidget(gridWidget);
int columnIndex = status.getColumnIndex();
FactMapping factMapping = abstractScesimModel.getScesimModelDescriptor().getFactMappingByIndex(columnIndex);
ScenarioGridColumn selectedColumn = (ScenarioGridColumn) context.getAbstractScesimGridModelByGridWidget(gridWidget).getColumns().get(columnIndex);
String placeholder = ScenarioSimulationUtils.getPlaceHolder(selectedColumn.isInstanceAssigned(), selectedColumn.isPropertyAssigned(), factMapping.getFactMappingValueType(), factMapping.getClassName());
context.getAbstractScesimGridModelByGridWidget(gridWidget).setCellValue(status.getRowIndex(), columnIndex, new ScenarioGridCellValue(status.getGridCellValue(), placeholder));
context.getAbstractScesimGridModelByGridWidget(gridWidget).resetError(status.getRowIndex(), columnIndex);
}
use of org.drools.workbench.screens.scenariosimulation.client.widgets.ScenarioGridColumn in project drools-wb by kiegroup.
the class ScenarioSimulationGridHeaderUtilities method isEditableHeader.
/**
* Checks whether the edit mode can be invoked on header cell from given column on given row.
* @param column
* @param uiHeaderRowIndex
* @return true if conditions are met, false otherwise
*/
public static boolean isEditableHeader(final ScenarioGridColumn column, final Integer uiHeaderRowIndex) {
final GridColumn.HeaderMetaData headerMetaData = column.getHeaderMetaData().get(uiHeaderRowIndex);
if (!(headerMetaData instanceof ScenarioHeaderMetaData)) {
throw new IllegalStateException("Header metadata has to be an instance of ScenarioHeaderMetaData");
}
final ScenarioHeaderMetaData scenarioHeaderMetaData = (ScenarioHeaderMetaData) headerMetaData;
if (scenarioHeaderMetaData.isEditingMode() || scenarioHeaderMetaData.isReadOnly()) {
return false;
}
if (!column.isInstanceAssigned() || !column.isEditableHeaders()) {
return false;
}
return scenarioHeaderMetaData.isInstanceHeader() || (scenarioHeaderMetaData.isPropertyHeader() && column.isPropertyAssigned());
}
Aggregations