use of org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData in project drools-wb by kiegroup.
the class ScenarioSimulationGridHeaderUtilitiesTest method testIsHeaderEditableInstanceAssignedButPropertySelected.
@Test
public void testIsHeaderEditableInstanceAssignedButPropertySelected() {
when(scenarioGridColumnOne.isInstanceAssigned()).thenReturn(true);
final ScenarioHeaderMetaData metaDataMock = (ScenarioHeaderMetaData) scenarioGridColumnOne.getHeaderMetaData().get(0);
when(metaDataMock.isPropertyHeader()).thenReturn(true);
final boolean result = ScenarioSimulationGridHeaderUtilities.isEditableHeader(scenarioGridColumnOne, 0);
assertThat(result).as("Instance Assigned but Property selected").isFalse();
}
use of org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData in project drools-wb by kiegroup.
the class AbstractScesimGridModel method getInstanceLimits.
/**
* This methods returns the <code>Range</code> of a <b>single</b> block of columns of the same instance/data object.
* A <code>single</code> block is made of all the columns immediately to the left and right of the selected one with the same "label".
* If there is another column with the same "label" but separated by a different column, it is not part of the group.
* @param columnIndex
* @param columnIndexStart the leftmost index to consider when evaluating the range
* @return
*/
protected Range getInstanceLimits(int columnIndex, int columnIndexStart) {
final ScenarioGridColumn column = (ScenarioGridColumn) columns.get(columnIndex);
final String originalColumnGroup = column.getInformationHeaderMetaData().getColumnGroup();
final ScenarioHeaderMetaData selectedInformationHeaderMetaData = column.getInformationHeaderMetaData();
String originalColumnTitle = selectedInformationHeaderMetaData.getTitle();
int leftPosition = columnIndex;
while (leftPosition > columnIndexStart && ((ScenarioGridColumn) columns.get(leftPosition - 1)).getInformationHeaderMetaData().getColumnGroup().equals(originalColumnGroup) && ((ScenarioGridColumn) columns.get(leftPosition - 1)).getInformationHeaderMetaData().getTitle().equals(originalColumnTitle)) {
leftPosition--;
}
int rightPosition = columnIndex;
while (rightPosition < columns.size() - 1 && ((ScenarioGridColumn) columns.get(rightPosition + 1)).getInformationHeaderMetaData().getColumnGroup().equals(originalColumnGroup) && ((ScenarioGridColumn) columns.get(rightPosition + 1)).getInformationHeaderMetaData().getTitle().equals(originalColumnTitle)) {
rightPosition++;
}
return new Range(leftPosition, rightPosition);
}
use of org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData in project drools-wb by kiegroup.
the class ScenarioSimulationGridHeaderUtilities method isEditableHeader.
/**
* Checks whether the edit mode can be invoked on header cell from given column on given row.
* @param column
* @param uiHeaderRowIndex
* @return true if conditions are met, false otherwise
*/
public static boolean isEditableHeader(final ScenarioGridColumn column, final Integer uiHeaderRowIndex) {
final GridColumn.HeaderMetaData headerMetaData = column.getHeaderMetaData().get(uiHeaderRowIndex);
if (!(headerMetaData instanceof ScenarioHeaderMetaData)) {
throw new IllegalStateException("Header metadata has to be an instance of ScenarioHeaderMetaData");
}
final ScenarioHeaderMetaData scenarioHeaderMetaData = (ScenarioHeaderMetaData) headerMetaData;
if (scenarioHeaderMetaData.isEditingMode() || scenarioHeaderMetaData.isReadOnly()) {
return false;
}
if (!column.isInstanceAssigned() || !column.isEditableHeaders()) {
return false;
}
return scenarioHeaderMetaData.isInstanceHeader() || (scenarioHeaderMetaData.isPropertyHeader() && column.isPropertyAssigned());
}
use of org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData in project drools-wb by kiegroup.
the class CommonEditHandler method manageHeaderLeftClick.
/**
* 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 scenarioGrid
* @param uiColumnIndex
* @param scenarioGridColumn
* @param uiHeaderRowIndex
* @return
*/
protected static boolean manageHeaderLeftClick(ScenarioGrid scenarioGrid, Integer uiColumnIndex, ScenarioGridColumn scenarioGridColumn, Integer uiHeaderRowIndex) /*, EventBus eventBus*/
{
if (!isEditableHeaderLocal(scenarioGridColumn, uiHeaderRowIndex)) {
return false;
}
ScenarioHeaderMetaData clickedScenarioHeaderMetadata = (ScenarioHeaderMetaData) scenarioGridColumn.getHeaderMetaData().get(uiHeaderRowIndex);
if (clickedScenarioHeaderMetadata == null) {
return false;
}
String group = ScenarioSimulationUtils.getOriginalColumnGroup(clickedScenarioHeaderMetadata.getColumnGroup());
switch(group) {
case "GIVEN":
case "EXPECT":
return manageGivenExpectHeaderLeftClick(scenarioGrid, clickedScenarioHeaderMetadata, uiColumnIndex, uiHeaderRowIndex);
default:
return false;
}
}
Aggregations