use of org.drools.workbench.screens.scenariosimulation.client.events.ScenarioGridReloadEvent in project drools-wb by kiegroup.
the class ScenarioSimulationEventHandlerTest method onScenarioGridReloadEventBACKGROUND.
@Test
public void onScenarioGridReloadEventBACKGROUND() {
ScenarioGridReloadEvent event = new ScenarioGridReloadEvent(GridWidget.BACKGROUND);
scenarioSimulationEventHandler.onEvent(event);
verify(backgroundGridPanelMock, times(1)).onResize();
}
use of org.drools.workbench.screens.scenariosimulation.client.events.ScenarioGridReloadEvent in project drools-wb by kiegroup.
the class AbstractScesimGridModel method setCell.
/**
* This method <i>set</i> a cell value to the grid <b>and</b> to the underlying model
* @param rowIndex
* @param columnIndex
* @param cellSupplier
*/
@Override
public Range setCell(int rowIndex, int columnIndex, Supplier<GridCell<?>> cellSupplier) {
checkSimulation();
Range toReturn = super.setCell(rowIndex, columnIndex, cellSupplier);
try {
Optional<?> optionalValue = getCellValue(getCell(rowIndex, columnIndex));
Object rawValue = optionalValue.orElse(null);
String cellValue = (rawValue instanceof String) ? (String) rawValue : null;
E scenarioByIndex = abstractScesimModel.getDataByIndex(rowIndex);
FactMapping factMappingByIndex = abstractScesimModel.getScesimModelDescriptor().getFactMappingByIndex(columnIndex);
FactIdentifier factIdentifier = factMappingByIndex.getFactIdentifier();
ExpressionIdentifier expressionIdentifier = factMappingByIndex.getExpressionIdentifier();
scenarioByIndex.addOrUpdateMappingValue(factIdentifier, expressionIdentifier, cellValue);
} catch (Exception e) {
toReturn = super.deleteCell(rowIndex, columnIndex);
eventBus.fireEvent(new ScenarioGridReloadEvent(getGridWidget()));
}
return toReturn;
}
use of org.drools.workbench.screens.scenariosimulation.client.events.ScenarioGridReloadEvent in project drools-wb by kiegroup.
the class AbstractScesimGridModel method commonAddColumn.
/**
* This method <i>add</i> or <i>insert</i> a new column to the grid <b>and</b> to the underlying model, depending on the index value.
* If index == -1 -> add, otherwise insert.
* @param index
* @param column
* @param ei
*/
protected void commonAddColumn(final int index, final GridColumn<?> column, ExpressionIdentifier ei) {
ScesimModelDescriptor simulationDescriptor = abstractScesimModel.getScesimModelDescriptor();
String instanceTitle = ((ScenarioGridColumn) column).getInformationHeaderMetaData().getTitle();
String propertyTitle = ((ScenarioGridColumn) column).getPropertyHeaderMetaData().getTitle();
final int columnIndex = index == -1 ? getColumnCount() : index;
try {
final FactMapping createdFactMapping = simulationDescriptor.addFactMapping(columnIndex, instanceTitle, ((ScenarioGridColumn) column).getFactIdentifier(), ei);
createdFactMapping.setExpressionAlias(propertyTitle);
if (index == -1) {
// This is actually an append
super.appendColumn(column);
} else {
super.insertColumn(index, column);
}
final Range instanceLimits = getInstanceLimits(columnIndex);
IntStream.range(instanceLimits.getMinRowIndex(), instanceLimits.getMaxRowIndex() + 1).filter(currentIndex -> currentIndex != columnIndex).forEach(currentIndex -> simulationDescriptor.getFactMappingByIndex(currentIndex).setFactAlias(createdFactMapping.getFactAlias()));
} catch (Exception e) {
eventBus.fireEvent(new ScenarioNotificationEvent("Error during column creation: " + e.getMessage(), NotificationEvent.NotificationType.ERROR));
eventBus.fireEvent(new ScenarioGridReloadEvent(getGridWidget()));
return;
}
final List<E> unmodifiableScesimData = abstractScesimModel.getUnmodifiableData();
String placeHolder = ((ScenarioGridColumn) column).getPlaceHolder();
IntStream.range(0, unmodifiableScesimData.size()).forEach(rowIndex -> setCell(rowIndex, columnIndex, () -> new ScenarioGridCell(new ScenarioGridCellValue(null, placeHolder))));
}
use of org.drools.workbench.screens.scenariosimulation.client.events.ScenarioGridReloadEvent in project drools-wb by kiegroup.
the class ScenarioSimulationEventHandlerTest method onScenarioGridReloadEventSIMULATION.
@Test
public void onScenarioGridReloadEventSIMULATION() {
ScenarioGridReloadEvent event = new ScenarioGridReloadEvent(GridWidget.SIMULATION);
scenarioSimulationEventHandler.onEvent(event);
verify(scenarioGridPanelMock, times(1)).onResize();
}
Aggregations