use of org.kie.workbench.common.dmn.client.widgets.grid.model.BaseUIModelMapper in project kie-wb-common by kiegroup.
the class ContextEditorDefinitionTest method testEditor.
@Test
public void testEditor() {
when(hasExpression.getExpression()).thenReturn(definition.getModelClass().get());
final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> oEditor = definition.getEditor(parent, Optional.empty(), hasExpression, hasName, false, 0);
assertTrue(oEditor.isPresent());
final GridWidget editor = oEditor.get();
assertTrue(editor instanceof ContextGrid);
}
use of org.kie.workbench.common.dmn.client.widgets.grid.model.BaseUIModelMapper in project kie-wb-common by kiegroup.
the class ExpressionContainerGridTest method testGetBaseExpressionGrid.
@Test
public void testGetBaseExpressionGrid() {
final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> expectedBaseExpressionGrid = Optional.of(mock(LiteralExpressionGrid.class));
final ExpressionCellValue value = mock(ExpressionCellValue.class);
final GridCell<?> cell = new BaseGridCell<>(value);
final Supplier<GridCell<?>> cellSupplier = () -> cell;
when(value.getValue()).thenReturn(expectedBaseExpressionGrid);
grid.getModel().setCell(0, 0, cellSupplier);
assertEquals(expectedBaseExpressionGrid, grid.getBaseExpressionGrid());
}
use of org.kie.workbench.common.dmn.client.widgets.grid.model.BaseUIModelMapper in project kie-wb-common by kiegroup.
the class ExpressionContainerGrid method getExistingEditorWidth.
double getExistingEditorWidth() {
double existingWidth = DMNGridColumn.DEFAULT_WIDTH;
final GridCell<?> cell = model.getRow(0).getCells().get(0);
if (cell != null) {
final GridCellValue<?> value = cell.getValue();
if (value instanceof ExpressionCellValue) {
final ExpressionCellValue ecv = (ExpressionCellValue) value;
final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> editor = ecv.getValue();
if (editor.isPresent()) {
final BaseExpressionGrid beg = editor.get();
existingWidth = Collections.max(Arrays.asList(existingWidth, beg.getWidth() + beg.getPadding() * 2, beg.getMinimumWidth() + beg.getPadding() * 2));
}
}
}
return existingWidth;
}
use of org.kie.workbench.common.dmn.client.widgets.grid.model.BaseUIModelMapper in project kie-wb-common by kiegroup.
the class ExpressionEditorColumn method getMinimumWidth.
@Override
public Double getMinimumWidth() {
double minimumWidth = super.getMinimumWidth();
final GridData model = gridWidget.getModel();
final int columnIndex = getLogicalColumnIndex(model);
if (columnIndex != -1) {
for (GridRow row : model.getRows()) {
final GridCell<?> cell = row.getCells().get(columnIndex);
if (cell != null) {
final GridCellValue<?> value = cell.getValue();
if (value instanceof ExpressionCellValue) {
final ExpressionCellValue ecv = (ExpressionCellValue) value;
final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> editor = ecv.getValue();
final double padding = editor.map(BaseExpressionGrid::getPadding).orElse(0.0);
minimumWidth = Math.max(minimumWidth, ecv.getMinimumWidth().orElse(0.0) + padding * 2);
}
}
}
}
return minimumWidth;
}
use of org.kie.workbench.common.dmn.client.widgets.grid.model.BaseUIModelMapper in project kie-wb-common by kiegroup.
the class ExpressionEditorColumn method updateWidthOfChildren.
protected void updateWidthOfChildren() {
final double columnWidth = getWidth();
final GridData model = gridWidget.getModel();
final int columnIndex = getLogicalColumnIndex(model);
if (columnIndex != -1) {
for (GridRow row : model.getRows()) {
final GridCell<?> cell = row.getCells().get(columnIndex);
if (cell != null) {
final GridCellValue<?> value = cell.getValue();
if (value instanceof ExpressionCellValue) {
final ExpressionCellValue ecv = (ExpressionCellValue) value;
final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> editor = ecv.getValue();
if (editor.isPresent()) {
final BaseExpressionGrid beg = editor.get();
updateWidthOfLastColumn(beg, columnWidth);
}
}
}
}
}
}
Aggregations