use of org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid in project kie-wb-common by kiegroup.
the class UndefinedExpressionGrid method onExpressionTypeChanged.
void onExpressionTypeChanged(final ExpressionType type) {
final Optional<Expression> expression = expressionEditorDefinitionsSupplier.get().stream().filter(e -> e.getType().equals(type)).map(ExpressionEditorDefinition::getModelClass).findFirst().get();
final Optional<ExpressionEditorDefinition<Expression>> expressionEditorDefinition = expressionEditorDefinitionsSupplier.get().getExpressionEditorDefinition(expression);
expressionEditorDefinition.ifPresent(ed -> {
final Optional<BaseExpressionGrid> editor = ed.getEditor(parent, nodeUUID, hasExpression, expression, hasName, nesting);
final GridCellValueTuple gcv = new GridCellValueTuple<>(parent.getRowIndex(), parent.getColumnIndex(), parent.getGridWidget(), new ExpressionCellValue(editor));
sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new SetCellValueCommand(gcv, () -> uiModelMapper, () -> editor.ifPresent(e -> {
e.selectFirstCell();
synchroniseViewWhenExpressionEditorChanged(e);
})));
});
}
use of org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid in project kie-wb-common by kiegroup.
the class CommandUtils method updateParentInformation.
public static void updateParentInformation(final GridData uiModel) {
final Optional<ExpressionEditorColumn> expressionColumn = uiModel.getColumns().stream().filter(c -> c instanceof ExpressionEditorColumn).map(c -> (ExpressionEditorColumn) c).findFirst();
expressionColumn.ifPresent(c -> {
final int columnIndex = uiModel.getColumns().indexOf(c);
for (int rowIndex = 0; rowIndex < uiModel.getRowCount(); rowIndex++) {
final GridCell<?> cell = uiModel.getCell(rowIndex, columnIndex);
if (cell != null) {
final GridCellValue<?> value = cell.getValue();
if (value instanceof ExpressionCellValue) {
final ExpressionCellValue ecv = (ExpressionCellValue) value;
if (ecv.getValue().isPresent()) {
final BaseExpressionGrid beg = ecv.getValue().get();
beg.getParentInformation().setRowIndex(rowIndex);
beg.getParentInformation().setColumnIndex(columnIndex);
}
}
}
}
});
}
use of org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid 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> 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.BaseExpressionGrid 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> editor = ecv.getValue();
if (editor.isPresent()) {
final BaseExpressionGrid beg = editor.get();
updateWidthOfLastColumn(beg, columnWidth);
}
}
}
}
}
}
use of org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid in project kie-wb-common by kiegroup.
the class ContextEditorDefinitionTest method testEditor.
@Test
public void testEditor() {
final Optional<Context> expression = definition.getModelClass();
final Optional<BaseExpressionGrid> oEditor = definition.getEditor(parent, Optional.empty(), hasExpression, expression, hasName, 0);
assertTrue(oEditor.isPresent());
final GridWidget editor = oEditor.get();
assertTrue(editor instanceof ContextGrid);
}
Aggregations