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());
}
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);
}
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);
}
}
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;
}
}
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;
}
Aggregations