Search in sources :

Example 1 with ScenarioHeaderMetaData

use of org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData in project drools-wb by kiegroup.

the class ScenarioSimulationBuildersTest method testHeaderBuilder.

@Test
public void testHeaderBuilder() {
    ScenarioSimulationBuilders.HeaderBuilder builder = ScenarioSimulationBuilders.HeaderBuilder.get(scenarioHeaderTextBoxSingletonDOMElementFactoryMock);
    builder.setColumnTitle(COLUMN_INSTANCE_TITLE_FIRST);
    builder.setColumnGroup(COLUMN_GROUP_FIRST);
    builder.setInstanceHeader(true);
    List<HeaderMetaData> retrieved = builder.build();
    assertNotNull(retrieved);
    assertEquals(1, retrieved.size());
    ScenarioHeaderMetaData headerMetaData = (ScenarioHeaderMetaData) retrieved.get(0);
    assertNotNull(headerMetaData);
    assertEquals(COLUMN_INSTANCE_TITLE_FIRST, headerMetaData.getTitle());
    assertEquals(COLUMN_GROUP_FIRST, headerMetaData.getColumnGroup());
    assertTrue(headerMetaData.getMetadataType().equals(ScenarioHeaderMetaData.MetadataType.INSTANCE));
    assertFalse(headerMetaData.isReadOnly());
}
Also used : ScenarioHeaderMetaData(org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData) HeaderMetaData(org.uberfire.ext.wires.core.grids.client.model.GridColumn.HeaderMetaData) ScenarioHeaderMetaData(org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData) Test(org.junit.Test)

Example 2 with ScenarioHeaderMetaData

use of org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData in project drools-wb by kiegroup.

the class ScenarioSimulationGridHeaderUtilitiesTest method setup.

@Before
public void setup() {
    super.setup();
    doReturn(gridRenderer).when(scenarioGridMock).getRenderer();
    doReturn(gridRendererHelper).when(scenarioGridMock).getRendererHelper();
    doReturn(ri).when(gridRendererHelper).getRenderingInformation();
    doReturn(HEADER_HEIGHT).when(gridRenderer).getHeaderHeight();
    doReturn(HEADER_ROW_HEIGHT).when(gridRenderer).getHeaderRowHeight();
    doReturn(floatingBlockInformation).when(ri).getFloatingBlockInformation();
    doReturn(0.0).when(floatingBlockInformation).getX();
    doReturn(0.0).when(floatingBlockInformation).getWidth();
    doReturn(mock(Viewport.class)).when(scenarioGridMock).getViewport();
    when(scenarioGridMock.getModel()).thenReturn(scenarioGridModelMock);
    final ScenarioHeaderMetaData clickedScenarioHeaderMetadataMock = mock(ScenarioHeaderMetaData.class);
    scenarioGridColumnOne = mockGridColumn(100.0, Collections.singletonList(clickedScenarioHeaderMetadataMock), COLUMN_ONE_TITLE, COLUMN_GROUP);
    scenarioGridColumnTwo = mockGridColumn(100.0, Collections.singletonList(clickedScenarioHeaderMetadataMock), COLUMN_TWO_TITLE, COLUMN_GROUP);
    gridColumns.add(scenarioGridColumnOne);
    gridColumns.add(scenarioGridColumnTwo);
}
Also used : ScenarioHeaderMetaData(org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData) Viewport(com.ait.lienzo.client.core.shape.Viewport) Before(org.junit.Before)

Example 3 with ScenarioHeaderMetaData

use of org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData 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 4 with ScenarioHeaderMetaData

use of org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData in project drools-wb by kiegroup.

the class AbstractScenarioSimulationGridPanelHandler method manageHeaderCoordinates.

/**
 * This method check if the click happened on an <b>second level header</b> (i.e. the header of a specific column) cell. If it is so, manage it and returns <code>true</code>,
 * otherwise returns <code>false</code>
 * @param uiColumnIndex
 * @param scenarioGridColumn
 * @param clickPoint - coordinates relative to the grid top left corner
 * @return
 */
protected boolean manageHeaderCoordinates(Integer uiColumnIndex, ScenarioGridColumn scenarioGridColumn, Point2D clickPoint) {
    // Get row index
    final Integer uiHeaderRowIndex = getUiHeaderRowIndexLocal(clickPoint);
    if (uiHeaderRowIndex == null || uiColumnIndex == null || scenarioGridColumn == null) {
        return false;
    }
    ScenarioHeaderMetaData clickedScenarioHeaderMetadata = getColumnScenarioHeaderMetaDataLocal(clickPoint);
    if (clickedScenarioHeaderMetadata == null) {
        return false;
    }
    String group = ScenarioSimulationUtils.getOriginalColumnGroup(clickedScenarioHeaderMetadata.getColumnGroup());
    switch(group) {
        case "GIVEN":
        case "EXPECT":
            return manageGivenExpectHeaderCoordinates(clickedScenarioHeaderMetadata, scenarioGridColumn, group, uiColumnIndex);
        default:
            return false;
    }
}
Also used : ScenarioHeaderMetaData(org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData)

Example 5 with ScenarioHeaderMetaData

use of org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData in project drools-wb by kiegroup.

the class AbstractSelectedColumnCommand method insertNewColumn.

/**
 * It inserts a new <code>ScenarioGridColumn</code> in <code>ScenarioGridModel</code>
 * @param context It contains the <b>Context</b> inside which the commands will be executed
 * @param selectedColumn The selected <code>ScenarioGridColumn</code> where the command was launched
 * @param columnPosition Used to define in which position the new column should be added
 * @param cloneInstance If true, it create a new column inside the same instance of the selected column
 * @return The created <code>ScenarioGridColumn</code>
 */
protected ScenarioGridColumn insertNewColumn(ScenarioSimulationContext context, ScenarioGridColumn selectedColumn, int columnPosition, boolean cloneInstance) {
    final ScenarioHeaderMetaData selectedInformationHeaderMetaData = selectedColumn.getInformationHeaderMetaData();
    String columnGroup = selectedInformationHeaderMetaData.getColumnGroup();
    String originalInstanceTitle = selectedInformationHeaderMetaData.getTitle();
    final FactMappingType factMappingType = FactMappingType.valueOf(columnGroup.toUpperCase());
    final Map.Entry<String, String> validPlaceholders = context.getAbstractScesimGridModelByGridWidget(gridWidget).getValidPlaceholders();
    String instanceTitle = cloneInstance ? originalInstanceTitle : validPlaceholders.getKey();
    String propertyTitle = validPlaceholders.getValue();
    String placeHolder = ScenarioSimulationEditorConstants.INSTANCE.defineValidType();
    final ScenarioGridColumn scenarioGridColumnLocal = getScenarioGridColumnLocal(instanceTitle, propertyTitle, String.valueOf(new Date().getTime()), columnGroup, factMappingType, context.getScenarioHeaderTextBoxSingletonDOMElementFactory(gridWidget), context.getScenarioCellTextAreaSingletonDOMElementFactory(gridWidget), placeHolder);
    if (cloneInstance) {
        scenarioGridColumnLocal.setFactIdentifier(selectedColumn.getFactIdentifier());
    }
    scenarioGridColumnLocal.setInstanceAssigned(cloneInstance);
    scenarioGridColumnLocal.setPropertyAssigned(false);
    context.getAbstractScesimGridModelByGridWidget(gridWidget).insertColumn(columnPosition, scenarioGridColumnLocal);
    return scenarioGridColumnLocal;
}
Also used : ScenarioHeaderMetaData(org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData) FactMappingType(org.drools.scenariosimulation.api.model.FactMappingType) ScenarioGridColumn(org.drools.workbench.screens.scenariosimulation.client.widgets.ScenarioGridColumn) Map(java.util.Map) SortedMap(java.util.SortedMap) Date(java.util.Date)

Aggregations

ScenarioHeaderMetaData (org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData)19 ScenarioGridColumn (org.drools.workbench.screens.scenariosimulation.client.widgets.ScenarioGridColumn)6 Test (org.junit.Test)6 AbstractScenarioSimulationTest (org.drools.workbench.screens.scenariosimulation.client.AbstractScenarioSimulationTest)4 GridColumn (org.uberfire.ext.wires.core.grids.client.model.GridColumn)3 FactMapping (org.drools.scenariosimulation.api.model.FactMapping)2 FactMappingType (org.drools.scenariosimulation.api.model.FactMappingType)2 EnableTestToolsEvent (org.drools.workbench.screens.scenariosimulation.client.events.EnableTestToolsEvent)2 ReloadTestToolsEvent (org.drools.workbench.screens.scenariosimulation.client.events.ReloadTestToolsEvent)2 Before (org.junit.Before)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 AbstractNodeMouseEvent (com.ait.lienzo.client.core.event.AbstractNodeMouseEvent)1 Viewport (com.ait.lienzo.client.core.shape.Viewport)1 Point2D (com.ait.lienzo.client.core.types.Point2D)1 Date (java.util.Date)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 SortedMap (java.util.SortedMap)1 AbstractScesimData (org.drools.scenariosimulation.api.model.AbstractScesimData)1