Search in sources :

Example 1 with ValidateSimulationEvent

use of org.drools.workbench.screens.scenariosimulation.client.events.ValidateSimulationEvent in project drools-wb by kiegroup.

the class SettingsPresenter method validateSimulation.

/**
 * It checks if a user selected DMN path is valid or not. If valid, it clears the <code>dmnPathErrorLabel</code>
 * span element and it validates the whole Simulation. If not valid, the otherwise.
 * This method should be called everytime a value is selected in <code>{@link SettingsScenarioSimulationDropdown}</code> widget
 */
protected void validateSimulation() {
    final Optional<KieAssetsDropdownItem> value = settingsScenarioSimulationDropdown.getValue();
    String selectedPath = value.map(KieAssetsDropdownItem::getValue).orElse(null);
    boolean isValid = selectedPath != null && !selectedPath.isEmpty();
    if (!isValid) {
        view.getDmnFilePathErrorLabel().getStyle().setDisplay(Style.Display.INLINE);
        view.getDmnFilePathErrorLabel().setInnerText(ScenarioSimulationEditorConstants.INSTANCE.chooseValidDMNAsset());
    } else {
        this.syncDmnFilePath();
        view.getDmnFilePathErrorLabel().getStyle().setDisplay(Style.Display.NONE);
        view.getDmnFilePathErrorLabel().setInnerText("");
        eventBus.fireEvent(new ValidateSimulationEvent());
    }
}
Also used : ValidateSimulationEvent(org.drools.workbench.screens.scenariosimulation.client.events.ValidateSimulationEvent) KieAssetsDropdownItem(org.kie.workbench.common.widgets.client.assets.dropdown.KieAssetsDropdownItem)

Example 2 with ValidateSimulationEvent

use of org.drools.workbench.screens.scenariosimulation.client.events.ValidateSimulationEvent in project drools-wb by kiegroup.

the class ScenarioSimulationEventHandlerTest method onValidateEvent.

@Test
public void onValidateEvent() {
    ValidateSimulationEvent event = new ValidateSimulationEvent();
    scenarioSimulationEventHandler.onEvent(event);
    verify(scenarioSimulationEditorPresenterMock, times(1)).validateSimulation();
}
Also used : ValidateSimulationEvent(org.drools.workbench.screens.scenariosimulation.client.events.ValidateSimulationEvent) Test(org.junit.Test) AbstractScenarioSimulationTest(org.drools.workbench.screens.scenariosimulation.client.AbstractScenarioSimulationTest)

Aggregations

ValidateSimulationEvent (org.drools.workbench.screens.scenariosimulation.client.events.ValidateSimulationEvent)2 AbstractScenarioSimulationTest (org.drools.workbench.screens.scenariosimulation.client.AbstractScenarioSimulationTest)1 Test (org.junit.Test)1 KieAssetsDropdownItem (org.kie.workbench.common.widgets.client.assets.dropdown.KieAssetsDropdownItem)1