use of org.drools.workbench.screens.scenariosimulation.client.values.ScenarioGridCellValue in project drools-wb by kiegroup.
the class ScenarioGridModel method insertRowGridOnly.
/**
* This method <i>insert</i> a row to the grid and populate it with values taken from given <code>Scenario</code>
* @param row
*/
@Override
public void insertRowGridOnly(final int rowIndex, final GridRow row, final Scenario scenario) {
insertRowGridOnly(rowIndex, row);
scenario.getUnmodifiableFactMappingValues().forEach(value -> {
FactIdentifier factIdentifier = value.getFactIdentifier();
ExpressionIdentifier expressionIdentifier = value.getExpressionIdentifier();
if (value.getRawValue() == null || value.getRawValue() instanceof String) {
// Let' put a placeholder
String stringValue = (String) value.getRawValue();
int columnIndex = abstractScesimModel.getScesimModelDescriptor().getIndexByIdentifier(factIdentifier, expressionIdentifier);
final FactMapping factMappingByIndex = abstractScesimModel.getScesimModelDescriptor().getFactMappingByIndex(columnIndex);
String placeHolder = ((ScenarioGridColumn) columns.get(columnIndex)).getPlaceHolder();
setCell(rowIndex, columnIndex, () -> {
ScenarioGridCell newCell = new ScenarioGridCell(new ScenarioGridCellValue(stringValue, placeHolder));
if (ScenarioSimulationSharedUtils.isCollectionOrMap((factMappingByIndex.getClassName()))) {
newCell.setListMap(ScenarioSimulationSharedUtils.isList((factMappingByIndex.getClassName())));
}
return newCell;
});
} else {
throw new UnsupportedOperationException("Only string is supported at the moment");
}
});
updateIndexColumn();
}
use of org.drools.workbench.screens.scenariosimulation.client.values.ScenarioGridCellValue in project drools-wb by kiegroup.
the class BackgroundGridModel method insertRowGridOnly.
/**
* This method <i>insert</i> a row to the grid and populate it with values taken from given <code>Scenario</code>
* @param row
*/
@Override
public void insertRowGridOnly(final int rowIndex, final GridRow row, final BackgroundData abstractScesimData) {
insertRowGridOnly(rowIndex, row);
abstractScesimData.getUnmodifiableFactMappingValues().forEach(value -> {
FactIdentifier factIdentifier = value.getFactIdentifier();
ExpressionIdentifier expressionIdentifier = value.getExpressionIdentifier();
if (value.getRawValue() == null || value.getRawValue() instanceof String) {
String stringValue = (String) value.getRawValue();
int columnIndex = abstractScesimModel.getScesimModelDescriptor().getIndexByIdentifier(factIdentifier, expressionIdentifier);
final FactMapping factMappingByIndex = abstractScesimModel.getScesimModelDescriptor().getFactMappingByIndex(columnIndex);
String placeHolder = ((ScenarioGridColumn) columns.get(columnIndex)).getPlaceHolder();
setCell(rowIndex, columnIndex, () -> {
ScenarioGridCell newCell = new ScenarioGridCell(new ScenarioGridCellValue(stringValue, placeHolder));
if (ScenarioSimulationSharedUtils.isCollectionOrMap((factMappingByIndex.getClassName()))) {
newCell.setListMap(ScenarioSimulationSharedUtils.isList((factMappingByIndex.getClassName())));
}
return newCell;
});
} else {
throw new UnsupportedOperationException("Only string is supported at the moment");
}
});
}
use of org.drools.workbench.screens.scenariosimulation.client.values.ScenarioGridCellValue 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);
}
Aggregations