Search in sources :

Example 11 with KieAssetsDropdownItem

use of org.kie.workbench.common.widgets.client.assets.dropdown.KieAssetsDropdownItem in project drools-wb by kiegroup.

the class SettingsPresenter method syncDmnFilePath.

@Override
public void syncDmnFilePath() {
    String dmnFilePath = getCleanValue(() -> settingsScenarioSimulationDropdown.getValue().map(KieAssetsDropdownItem::getValue).orElse(""));
    eventBus.fireEvent(new UpdateSettingsDataEvent(settingsToUpdate -> settingsToUpdate.setDmnFilePath(dmnFilePath), settingsToCheck -> !Objects.equals(settingsToCheck.getDmnFilePath(), dmnFilePath), true));
}
Also used : UpdateSettingsDataEvent(org.drools.workbench.screens.scenariosimulation.client.events.UpdateSettingsDataEvent) RULE(org.drools.scenariosimulation.api.model.ScenarioSimulationModel.Type.RULE) EventBus(com.google.gwt.event.shared.EventBus) ValidateSimulationEvent(org.drools.workbench.screens.scenariosimulation.client.events.ValidateSimulationEvent) ScenarioSimulationModel(org.drools.scenariosimulation.api.model.ScenarioSimulationModel) Settings(org.drools.scenariosimulation.api.model.Settings) DMN(org.drools.scenariosimulation.api.model.ScenarioSimulationModel.Type.DMN) DEFAULT_PREFERRED_WIDHT(org.drools.workbench.screens.scenariosimulation.client.rightpanel.SettingsPresenter.DEFAULT_PREFERRED_WIDHT) Supplier(java.util.function.Supplier) KieAssetsDropdownItem(org.kie.workbench.common.widgets.client.assets.dropdown.KieAssetsDropdownItem) Objects(java.util.Objects) Inject(javax.inject.Inject) Style(com.google.gwt.dom.client.Style) SettingsScenarioSimulationDropdown(org.drools.workbench.screens.scenariosimulation.client.dropdown.SettingsScenarioSimulationDropdown) IDENTIFIER(org.drools.workbench.screens.scenariosimulation.client.rightpanel.SettingsPresenter.IDENTIFIER) PostConstruct(javax.annotation.PostConstruct) Optional(java.util.Optional) ScenarioSimulationEditorConstants(org.drools.workbench.screens.scenariosimulation.client.resources.i18n.ScenarioSimulationEditorConstants) ApplicationScoped(javax.enterprise.context.ApplicationScoped) Named(javax.inject.Named) WorkbenchScreen(org.uberfire.client.annotations.WorkbenchScreen) Command(org.uberfire.mvp.Command) UpdateSettingsDataEvent(org.drools.workbench.screens.scenariosimulation.client.events.UpdateSettingsDataEvent) KieAssetsDropdownItem(org.kie.workbench.common.widgets.client.assets.dropdown.KieAssetsDropdownItem)

Example 12 with KieAssetsDropdownItem

use of org.kie.workbench.common.widgets.client.assets.dropdown.KieAssetsDropdownItem 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)

Aggregations

KieAssetsDropdownItem (org.kie.workbench.common.widgets.client.assets.dropdown.KieAssetsDropdownItem)12 Test (org.junit.Test)8 ValidateSimulationEvent (org.drools.workbench.screens.scenariosimulation.client.events.ValidateSimulationEvent)3 Before (org.junit.Before)3 DMNIncludedModel (org.kie.workbench.common.dmn.api.editors.included.DMNIncludedModel)3 PMMLIncludedModel (org.kie.workbench.common.dmn.api.editors.included.PMMLIncludedModel)3 BaseIncludedModelActiveRecord (org.kie.workbench.common.dmn.client.editors.included.BaseIncludedModelActiveRecord)3 GwtMockitoTestRunner (com.google.gwtmockito.GwtMockitoTestRunner)2 Arrays.asList (java.util.Arrays.asList)2 List (java.util.List)2 Consumer (java.util.function.Consumer)2 Assert.assertEquals (org.junit.Assert.assertEquals)2 RunWith (org.junit.runner.RunWith)2 Import (org.kie.workbench.common.dmn.api.definition.model.Import)2 DMN (org.kie.workbench.common.dmn.api.editors.included.DMNImportTypes.DMN)2 PMML (org.kie.workbench.common.dmn.api.editors.included.DMNImportTypes.PMML)2 IncludedModel (org.kie.workbench.common.dmn.api.editors.included.IncludedModel)2 LocationURI (org.kie.workbench.common.dmn.api.property.dmn.LocationURI)2 DMNIncludeModelsClient (org.kie.workbench.common.dmn.client.api.included.legacy.DMNIncludeModelsClient)2 DMNIncludedModelActiveRecord (org.kie.workbench.common.dmn.client.editors.included.DMNIncludedModelActiveRecord)2