Search in sources :

Example 1 with ScenarioGridColumn

use of org.drools.workbench.screens.scenariosimulation.client.widgets.ScenarioGridColumn in project drools-wb by kiegroup.

the class AbstractSelectedColumnCommandTest method insertNewColumnCommon.

protected void insertNewColumnCommon(int columnIndex, boolean cloneInstance) {
    int instanceNum = simulationDescriptorMock.getUnmodifiableFactMappings().size();
    ScenarioGridColumn createdColumn = ((AbstractSelectedColumnCommand) commandSpy).insertNewColumn(scenarioSimulationContextLocal, gridColumnMock, columnIndex, cloneInstance);
    String columnGroup = gridColumnMock.getInformationHeaderMetaData().getColumnGroup();
    String originalInstanceTitle = gridColumnMock.getInformationHeaderMetaData().getTitle();
    String instanceTitle = cloneInstance ? originalInstanceTitle : "INSTANCE " + instanceNum;
    String propertyTitle = "PROPERTY " + instanceNum;
    final FactMappingType factMappingType = FactMappingType.valueOf(columnGroup.toUpperCase());
    verify(commandSpy, times(1)).getScenarioGridColumnLocal(eq(instanceTitle), eq(propertyTitle), anyString(), eq(columnGroup), eq(factMappingType), eq(scenarioHeaderTextBoxSingletonDOMElementFactorySpy), eq(scenarioCellTextAreaSingletonDOMElementFactorySpy), eq(ScenarioSimulationEditorConstants.INSTANCE.defineValidType()));
    if (cloneInstance) {
        verify(createdColumn, times(1)).setFactIdentifier(eq(gridColumnMock.getFactIdentifier()));
    } else {
        verify(createdColumn, never()).setFactIdentifier(any());
    }
    verify(createdColumn, times(1)).setInstanceAssigned(eq(cloneInstance));
    verify(scenarioGridModelMock, times(1)).insertColumn(COLUMN_INDEX, createdColumn);
}
Also used : FactMappingType(org.drools.scenariosimulation.api.model.FactMappingType) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ScenarioGridColumn(org.drools.workbench.screens.scenariosimulation.client.widgets.ScenarioGridColumn)

Example 2 with ScenarioGridColumn

use of org.drools.workbench.screens.scenariosimulation.client.widgets.ScenarioGridColumn in project drools-wb by kiegroup.

the class ScenarioSimulationEventHandler method onEvent.

@Override
public void onEvent(SetInstanceHeaderEvent event) {
    if (context.getAbstractScesimGridModelByGridWidget(event.getGridWidget()).isSameInstanceType(event.getClassName())) {
        return;
    }
    context.getStatus().setFullPackage(event.getFullPackage());
    context.getStatus().setClassName(event.getClassName());
    if (((ScenarioGridColumn) context.getAbstractScesimGridModelByGridWidget(event.getGridWidget()).getSelectedColumn()).isInstanceAssigned()) {
        org.uberfire.mvp.Command okPreserveCommand = () -> commonExecution(new SetInstanceHeaderCommand(event.getGridWidget()), true);
        deletePopupPresenter.show(ScenarioSimulationEditorConstants.INSTANCE.changeTypeMainTitle(), ScenarioSimulationEditorConstants.INSTANCE.changeTypeMainQuestion(), ScenarioSimulationEditorConstants.INSTANCE.changeTypeText1(), ScenarioSimulationEditorConstants.INSTANCE.changeTypeTextQuestion(), ScenarioSimulationEditorConstants.INSTANCE.changeTypeTextDanger(), ScenarioSimulationEditorConstants.INSTANCE.changeType(), okPreserveCommand);
    } else {
        commonExecution(new SetInstanceHeaderCommand(event.getGridWidget()), true);
    }
}
Also used : ScenarioGridColumn(org.drools.workbench.screens.scenariosimulation.client.widgets.ScenarioGridColumn) SetInstanceHeaderCommand(org.drools.workbench.screens.scenariosimulation.client.commands.actualcommands.SetInstanceHeaderCommand)

Example 3 with ScenarioGridColumn

use of org.drools.workbench.screens.scenariosimulation.client.widgets.ScenarioGridColumn in project drools-wb by kiegroup.

the class ScenarioSimulationEventHandler method onEvent.

@Override
public void onEvent(DuplicateInstanceEvent event) {
    context.getStatus().setColumnId(String.valueOf(new Date().getTime()));
    context.getStatus().setColumnIndex(event.getColumnIndex());
    context.getStatus().setRight(true);
    context.getStatus().setAsProperty(false);
    context.getStatus().setFullPackage(((ScenarioGridColumn) context.getAbstractScesimGridModelByGridWidget(event.getGridWidget()).getSelectedColumn()).getFactIdentifier().getPackageWithoutClassName());
    commonExecution(new DuplicateInstanceCommand(event.getGridWidget()), true);
}
Also used : DuplicateInstanceCommand(org.drools.workbench.screens.scenariosimulation.client.commands.actualcommands.DuplicateInstanceCommand) ScenarioGridColumn(org.drools.workbench.screens.scenariosimulation.client.widgets.ScenarioGridColumn) Date(java.util.Date)

Example 4 with ScenarioGridColumn

use of org.drools.workbench.screens.scenariosimulation.client.widgets.ScenarioGridColumn in project drools-wb by kiegroup.

the class ScenarioSimulationUtilsTest method getScenarioGridColumn2.

@Test
public void getScenarioGridColumn2() {
    final ScenarioGridColumn retrieved = ScenarioSimulationUtils.getScenarioGridColumn(COLUMN_INSTANCE_TITLE_FIRST, COLUMN_PROPERTY_TITLE_FIRST, COLUMN_ID, COLUMN_GROUP_FIRST, factMappingType, scenarioHeaderTextBoxSingletonDOMElementFactoryMock, scenarioCellTextAreaSingletonDOMElementFactoryMock, PLACEHOLDER);
    assertNotNull(retrieved);
}
Also used : ScenarioGridColumn(org.drools.workbench.screens.scenariosimulation.client.widgets.ScenarioGridColumn) Test(org.junit.Test)

Example 5 with ScenarioGridColumn

use of org.drools.workbench.screens.scenariosimulation.client.widgets.ScenarioGridColumn in project drools-wb by kiegroup.

the class ScenarioSimulationUtilsTest method getScenarioGridColumn4.

@Test
public void getScenarioGridColumn4() {
    final ScenarioGridColumn retrieved = ScenarioSimulationUtils.getScenarioGridColumn(headerBuilderMock, scenarioCellTextAreaSingletonDOMElementFactoryMock, PLACEHOLDER);
    assertNotNull(retrieved);
}
Also used : ScenarioGridColumn(org.drools.workbench.screens.scenariosimulation.client.widgets.ScenarioGridColumn) Test(org.junit.Test)

Aggregations

ScenarioGridColumn (org.drools.workbench.screens.scenariosimulation.client.widgets.ScenarioGridColumn)32 ScenarioHeaderMetaData (org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData)10 FactMapping (org.drools.scenariosimulation.api.model.FactMapping)9 FactMappingType (org.drools.scenariosimulation.api.model.FactMappingType)8 ScenarioGridCellValue (org.drools.workbench.screens.scenariosimulation.client.values.ScenarioGridCellValue)8 ArrayList (java.util.ArrayList)7 Map (java.util.Map)7 ScenarioGridCell (org.drools.workbench.screens.scenariosimulation.client.widgets.ScenarioGridCell)7 GridColumn (org.uberfire.ext.wires.core.grids.client.model.GridColumn)7 List (java.util.List)6 Objects (java.util.Objects)6 AbstractScesimData (org.drools.scenariosimulation.api.model.AbstractScesimData)6 ExpressionElement (org.drools.scenariosimulation.api.model.ExpressionElement)6 ExpressionIdentifier (org.drools.scenariosimulation.api.model.ExpressionIdentifier)6 FactIdentifier (org.drools.scenariosimulation.api.model.FactIdentifier)6 ScenarioSimulationModel (org.drools.scenariosimulation.api.model.ScenarioSimulationModel)6 ScesimModelDescriptor (org.drools.scenariosimulation.api.model.ScesimModelDescriptor)6 Collections (java.util.Collections)5 Optional (java.util.Optional)5 Set (java.util.Set)5