use of org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple in project kie-wb-common by kiegroup.
the class RelationColumn method getMinimumWidthOfPeers.
private double getMinimumWidthOfPeers() {
final GridCellTuple parent = gridWidget.getParentInformation();
final GridData parentUiModel = parent.getGridWidget().getModel();
final int parentUiRowIndex = parent.getRowIndex();
final int parentUiColumnIndex = parent.getColumnIndex();
double minimumWidth = super.getMinimumWidth();
for (int uiRowIndex = 0; uiRowIndex < parentUiModel.getRowCount(); uiRowIndex++) {
if (uiRowIndex != parentUiRowIndex) {
final GridRow row = parentUiModel.getRow(uiRowIndex);
final GridCell<?> cell = row.getCells().get(parentUiColumnIndex);
if (cell != null) {
final GridCellValue<?> value = cell.getValue();
if (value instanceof ExpressionCellValue) {
final ExpressionCellValue ecv = (ExpressionCellValue) value;
final Optional<BaseExpressionGrid> editor = ecv.getValue();
final double padding = editor.map(BaseExpressionGrid::getPadding).get();
minimumWidth = Math.max(minimumWidth, ecv.getMinimumWidth().orElse(0.0) + padding * 2);
}
}
}
}
return minimumWidth;
}
use of org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple in project kie-wb-common by kiegroup.
the class BaseContextUIModelMapperTest method testFromDMNModelUndefinedExpression.
@Test
public void testFromDMNModelUndefinedExpression() {
mapper.fromDMNModel(0, 2);
assertTrue(uiModel.getCell(0, 2).getValue() instanceof ExpressionCellValue);
final ExpressionCellValue dcv0 = (ExpressionCellValue) uiModel.getCell(0, 2).getValue();
assertEquals(undefinedExpressionEditor, dcv0.getValue().get());
verify(undefinedExpressionEditorDefinition).getEditor(parentCaptor.capture(), eq(Optional.empty()), eq(context.getContextEntry().get(0)), eq(Optional.empty()), eq(Optional.of(context.getContextEntry().get(0).getVariable())), eq(1));
final GridCellTuple parent = parentCaptor.getValue();
assertEquals(0, parent.getRowIndex());
assertEquals(2, parent.getColumnIndex());
assertEquals(gridWidget, parent.getGridWidget());
}
use of org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple in project kie-wb-common by kiegroup.
the class BaseContextUIModelMapperTest method testFromDMNModelLiteralExpression.
@Test
@SuppressWarnings("unchecked")
public void testFromDMNModelLiteralExpression() {
mapper.fromDMNModel(1, 2);
assertTrue(uiModel.getCell(1, 2).getValue() instanceof ExpressionCellValue);
final ExpressionCellValue dcv1 = (ExpressionCellValue) uiModel.getCell(1, 2).getValue();
assertEquals(literalExpressionEditor, dcv1.getValue().get());
verify(literalExpressionEditorDefinition).getEditor(parentCaptor.capture(), eq(Optional.empty()), eq(context.getContextEntry().get(1)), eq(Optional.of(context.getContextEntry().get(1).getExpression())), eq(Optional.empty()), eq(1));
final GridCellTuple parent = parentCaptor.getValue();
assertEquals(1, parent.getRowIndex());
assertEquals(2, parent.getColumnIndex());
assertEquals(gridWidget, parent.getGridWidget());
}
use of org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple in project kie-wb-common by kiegroup.
the class DecisionTableGridTest method testHeaderTextBoxFactoryWhenNotNested.
@Test
public void testHeaderTextBoxFactoryWhenNotNested() {
setupGrid(makeHasNameForDecision(), 0);
final GridCellTuple tupleWithoutValue = new GridCellTuple(0, 2, gridWidget);
final GridCellValueTuple tupleWithValue = new GridCellValueTuple<>(0, 2, gridWidget, new BaseGridCellValue<>("value"));
final TextBoxSingletonDOMElementFactory factory = grid.getHeaderTextBoxFactory();
assertThat(factory.getHasNoValueCommand().apply(tupleWithoutValue)).isInstanceOf(DeleteHeaderValueCommand.class);
assertThat(factory.getHasValueCommand().apply(tupleWithValue)).isInstanceOf(SetHeaderValueCommand.class);
}
use of org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple in project kie-wb-common by kiegroup.
the class DecisionTableGridTest method testHeaderHasNameTextBoxFactoryWhenNotNested.
@Test
public void testHeaderHasNameTextBoxFactoryWhenNotNested() {
setupGrid(makeHasNameForDecision(), 0);
final GridCellTuple tupleWithoutValue = new GridCellTuple(0, 2, gridWidget);
final GridCellValueTuple tupleWithValue = new GridCellValueTuple<>(0, 2, gridWidget, new BaseGridCellValue<>("value"));
final TextBoxSingletonDOMElementFactory factory = grid.getHeaderHasNameTextBoxFactory();
assertCommands(factory.getHasNoValueCommand().apply(tupleWithoutValue), DeleteHeaderValueCommand.class, UpdateElementPropertyCommand.class);
assertCommands(factory.getHasValueCommand().apply(tupleWithValue), SetHeaderValueCommand.class, UpdateElementPropertyCommand.class);
}
Aggregations