Search in sources :

Example 1 with ReloadTestToolsEvent

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);
    }
}
Also used : ReloadTestToolsEvent(org.drools.workbench.screens.scenariosimulation.client.events.ReloadTestToolsEvent) ScenarioHeaderMetaData(org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData) EnableTestToolsEvent(org.drools.workbench.screens.scenariosimulation.client.events.EnableTestToolsEvent)

Example 2 with ReloadTestToolsEvent

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));
    }
}
Also used : ScesimModelDescriptor(org.drools.scenariosimulation.api.model.ScesimModelDescriptor) ReloadTestToolsEvent(org.drools.workbench.screens.scenariosimulation.client.events.ReloadTestToolsEvent) FactMapping(org.drools.scenariosimulation.api.model.FactMapping) ScenarioHeaderMetaData(org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData)

Example 3 with ReloadTestToolsEvent

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);
    }
}
Also used : ReloadTestToolsEvent(org.drools.workbench.screens.scenariosimulation.client.events.ReloadTestToolsEvent) ScenarioGrid(org.drools.workbench.screens.scenariosimulation.client.widgets.ScenarioGrid) SetHeaderCellValueEvent(org.drools.workbench.screens.scenariosimulation.client.events.SetHeaderCellValueEvent)

Example 4 with ReloadTestToolsEvent

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;
}
Also used : ReloadTestToolsEvent(org.drools.workbench.screens.scenariosimulation.client.events.ReloadTestToolsEvent) EnableTestToolsEvent(org.drools.workbench.screens.scenariosimulation.client.events.EnableTestToolsEvent) ScenarioSimulationGridHeaderUtilities.getEnableTestToolsEvent(org.drools.workbench.screens.scenariosimulation.client.utils.ScenarioSimulationGridHeaderUtilities.getEnableTestToolsEvent)

Example 5 with ReloadTestToolsEvent

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));
}
Also used : ReloadTestToolsEvent(org.drools.workbench.screens.scenariosimulation.client.events.ReloadTestToolsEvent) ReloadTestToolsCommand(org.drools.workbench.screens.scenariosimulation.client.commands.actualcommands.ReloadTestToolsCommand) Test(org.junit.Test) AbstractScenarioSimulationTest(org.drools.workbench.screens.scenariosimulation.client.AbstractScenarioSimulationTest)

Aggregations

ReloadTestToolsEvent (org.drools.workbench.screens.scenariosimulation.client.events.ReloadTestToolsEvent)5 EnableTestToolsEvent (org.drools.workbench.screens.scenariosimulation.client.events.EnableTestToolsEvent)2 ScenarioHeaderMetaData (org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData)2 FactMapping (org.drools.scenariosimulation.api.model.FactMapping)1 ScesimModelDescriptor (org.drools.scenariosimulation.api.model.ScesimModelDescriptor)1 AbstractScenarioSimulationTest (org.drools.workbench.screens.scenariosimulation.client.AbstractScenarioSimulationTest)1 ReloadTestToolsCommand (org.drools.workbench.screens.scenariosimulation.client.commands.actualcommands.ReloadTestToolsCommand)1 SetHeaderCellValueEvent (org.drools.workbench.screens.scenariosimulation.client.events.SetHeaderCellValueEvent)1 ScenarioSimulationGridHeaderUtilities.getEnableTestToolsEvent (org.drools.workbench.screens.scenariosimulation.client.utils.ScenarioSimulationGridHeaderUtilities.getEnableTestToolsEvent)1 ScenarioGrid (org.drools.workbench.screens.scenariosimulation.client.widgets.ScenarioGrid)1 Test (org.junit.Test)1