use of org.drools.workbench.screens.scenariosimulation.client.events.ReloadTestToolsEvent in project drools-wb by kiegroup.
the class ScenarioGrid method signalTestToolsHeaderCellSelected.
protected void signalTestToolsHeaderCellSelected(final ScenarioGridColumn scenarioGridColumn, final GridData.SelectedCell selectedHeaderCell, final int uiColumnIndex) {
final ScenarioHeaderMetaData scenarioHeaderMetaData = getColumnScenarioHeaderMetaData(scenarioGridColumn, selectedHeaderCell.getRowIndex());
if (scenarioGridColumn.isInstanceAssigned() && scenarioHeaderMetaData.getMetadataType().equals(ScenarioHeaderMetaData.MetadataType.INSTANCE)) {
eventBus.fireEvent(new ReloadTestToolsEvent(true, true));
} else {
String group = ScenarioSimulationUtils.getOriginalColumnGroup(scenarioHeaderMetaData.getColumnGroup());
final EnableTestToolsEvent enableTestToolsEvent = getEnableTestToolsEvent(this, scenarioGridColumn, scenarioHeaderMetaData, uiColumnIndex, group);
eventBus.fireEvent(enableTestToolsEvent);
}
}
use of org.drools.workbench.screens.scenariosimulation.client.events.ReloadTestToolsEvent in project drools-wb by kiegroup.
the class AbstractScesimGridModel method updateHeader.
public void updateHeader(int columnIndex, int headerRowIndex, String headerCellValue) {
final ScenarioHeaderMetaData editedMetadata = (ScenarioHeaderMetaData) getColumns().get(columnIndex).getHeaderMetaData().get(headerRowIndex);
// do not update if old and new value are the same
if (Objects.equals(editedMetadata.getTitle(), headerCellValue)) {
return;
}
ScesimModelDescriptor simulationDescriptor = abstractScesimModel.getScesimModelDescriptor();
FactMapping factMappingToEdit = simulationDescriptor.getFactMappingByIndex(columnIndex);
ScenarioHeaderMetaData.MetadataType metadataType = editedMetadata.getMetadataType();
IntStream.range(0, getColumnCount()).forEach(index -> updateFactMapping(simulationDescriptor, factMappingToEdit, index, headerCellValue, metadataType));
if (editedMetadata.getMetadataType().equals(ScenarioHeaderMetaData.MetadataType.INSTANCE)) {
eventBus.fireEvent(new ReloadTestToolsEvent(false));
}
}
use of org.drools.workbench.screens.scenariosimulation.client.events.ReloadTestToolsEvent in project drools-wb by kiegroup.
the class ScenarioHeaderTextAreaDOMElement method internalFlush.
@Override
protected void internalFlush(final String value) {
final int rowIndex = context.getRowIndex();
final int columnIndex = context.getColumnIndex();
try {
boolean isInstanceHeader = scenarioHeaderMetaData != null && Objects.equals(scenarioHeaderMetaData.getMetadataType(), ScenarioHeaderMetaData.MetadataType.INSTANCE);
boolean isPropertyHeader = scenarioHeaderMetaData != null && Objects.equals(scenarioHeaderMetaData.getMetadataType(), ScenarioHeaderMetaData.MetadataType.PROPERTY);
((ScenarioGrid) gridWidget).getEventBus().fireEvent(new SetHeaderCellValueEvent(((ScenarioGrid) gridWidget).getGridWidget(), rowIndex, columnIndex, value, isInstanceHeader, isPropertyHeader));
((ScenarioGrid) gridWidget).getEventBus().fireEvent(new ReloadTestToolsEvent(true));
} catch (Exception e) {
throw new IllegalArgumentException(new StringBuilder().append("Impossible to update header (").append(rowIndex).append(") of column ").append(columnIndex).toString(), e);
}
}
use of org.drools.workbench.screens.scenariosimulation.client.events.ReloadTestToolsEvent in project drools-wb by kiegroup.
the class ScenarioSimulationMainGridPanelClickHandler method manageGivenExpectHeaderCoordinates.
/**
* This method manage the click happened on an <i>GIVEN</i> or <i>EXPECT</i> header, starting editing it if not already did.
* @param clickedScenarioHeaderMetadata
* @param scenarioGridColumn
* @param group
* @param uiColumnIndex
* @return
*/
@Override
protected boolean manageGivenExpectHeaderCoordinates(ScenarioHeaderMetaData clickedScenarioHeaderMetadata, ScenarioGridColumn scenarioGridColumn, String group, Integer uiColumnIndex) {
scenarioGrid.setSelectedColumn(uiColumnIndex);
if (scenarioGridColumn.isInstanceAssigned() && clickedScenarioHeaderMetadata.getMetadataType().equals(ScenarioHeaderMetaData.MetadataType.INSTANCE)) {
eventBus.fireEvent(new ReloadTestToolsEvent(true, true));
} else {
EnableTestToolsEvent toFire = getEnableTestToolsEvent(scenarioGrid, scenarioGridColumn, clickedScenarioHeaderMetadata, uiColumnIndex, group);
eventBus.fireEvent(toFire);
}
return true;
}
use of org.drools.workbench.screens.scenariosimulation.client.events.ReloadTestToolsEvent in project drools-wb by kiegroup.
the class ScenarioSimulationEventHandlerTest method onReloadTestToolsEvent.
@Test
public void onReloadTestToolsEvent() {
ReloadTestToolsEvent event = new ReloadTestToolsEvent(true);
scenarioSimulationEventHandler.onEvent(event);
verify(scenarioSimulationEventHandler).commonExecution(isA(ReloadTestToolsCommand.class), eq(false));
}
Aggregations