use of org.uberfire.ext.wires.core.grids.client.model.GridRow 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.uberfire.ext.wires.core.grids.client.model.GridRow in project kie-wb-common by kiegroup.
the class AddContextEntryCommandTest method testCanvasCommandExecuteMultipleEntries.
@Test
public void testCanvasCommandExecuteMultipleEntries() {
makeCommand();
// first row
command.newGraphCommand(handler).execute(gce);
final Command<AbstractCanvasHandler, CanvasViolation> firstEntryCanvasCommand = command.newCanvasCommand(handler);
assertEquals(CanvasCommandResultBuilder.SUCCESS, firstEntryCanvasCommand.execute(handler));
verify(command).updateRowNumbers();
verify(command).updateParentInformation();
// second row
final ContextEntry secondRowEntry = new ContextEntry() {
{
setVariable(new InformationItem());
}
};
final GridRow uiSecondModelRow = new BaseGridRow();
command = spy(new AddContextEntryCommand(context, secondRowEntry, uiModel, uiSecondModelRow, context.getContextEntry().size() - 1, uiModelMapper, canvasOperation));
command.newGraphCommand(handler).execute(gce);
final Command<AbstractCanvasHandler, CanvasViolation> secondEntryCanvasCommand = command.newCanvasCommand(handler);
assertEquals(CanvasCommandResultBuilder.SUCCESS, secondEntryCanvasCommand.execute(handler));
verify(command).updateRowNumbers();
verify(command).updateParentInformation();
assertEquals(3, uiModel.getRowCount());
assertEquals(uiModelRow, uiModel.getRows().get(0));
assertEquals(uiSecondModelRow, uiModel.getRows().get(1));
assertEquals(uiDefaultResultModelRow, uiModel.getRows().get(2));
assertEquals(3, uiModel.getColumnCount());
assertEquals(uiRowNumberColumn, uiModel.getColumns().get(0));
assertEquals(uiNameColumn, uiModel.getColumns().get(1));
assertEquals(uiExpressionEditorColumn, uiModel.getColumns().get(2));
assertEquals(3, uiModel.getRows().get(0).getCells().size());
assertEquals(1, uiModel.getCell(0, 0).getValue().getValue());
assertEquals(ContextEntryDefaultValueUtilities.PREFIX + "1", ((InformationItemCell.HasNameAndDataTypeCell) uiModel.getCell(0, 1).getValue().getValue()).getName().getValue());
assertTrue(uiModel.getCell(0, 2).getValue() instanceof ExpressionCellValue);
assertEquals(3, uiModel.getRows().get(1).getCells().size());
assertEquals(2, uiModel.getCell(1, 0).getValue().getValue());
assertEquals(ContextEntryDefaultValueUtilities.PREFIX + "2", ((InformationItemCell.HasNameAndDataTypeCell) uiModel.getCell(1, 1).getValue().getValue()).getName().getValue());
assertTrue(uiModel.getCell(1, 2).getValue() instanceof ExpressionCellValue);
// Default row
assertEquals(1, uiModel.getRows().get(2).getCells().size());
assertTrue(uiModel.getCell(2, 2).getValue() instanceof ExpressionCellValue);
verify(canvasOperation, times(2)).execute();
}
use of org.uberfire.ext.wires.core.grids.client.model.GridRow in project kie-wb-common by kiegroup.
the class DeleteContextEntryCommandTest method testCanvasCommandExecuteWithColumnsMultipleRows.
@Test
public void testCanvasCommandExecuteWithColumnsMultipleRows() {
addContextEntries(3);
final GridRow firstRow = uiModel.getRow(0);
final GridRow lastRow = uiModel.getRow(2);
makeCommand(1);
uiModel.appendColumn(uiModelColumn);
final Command<AbstractCanvasHandler, CanvasViolation> cc = command.newCanvasCommand(handler);
assertEquals(CanvasCommandResultBuilder.SUCCESS, cc.execute(handler));
assertEquals(2, uiModel.getRowCount());
assertEquals(2, uiModel.getColumnCount());
assertEquals(uiRowNumberColumn, uiModel.getColumns().get(0));
assertEquals(uiModelColumn, uiModel.getColumns().get(1));
assertEquals(firstRow, uiModel.getRow(0));
assertEquals(lastRow, uiModel.getRow(1));
verify(command).updateRowNumbers();
verify(command).updateParentInformation();
verify(canvasOperation).execute();
}
use of org.uberfire.ext.wires.core.grids.client.model.GridRow in project kie-wb-common by kiegroup.
the class AddDecisionRuleCommandTest method assertDefaultUiRowValues.
private void assertDefaultUiRowValues(final int uiRowIndex) {
final GridRow uiGridRow = uiModel.getRow(uiRowIndex);
assertEquals(uiRowIndex + 1, uiGridRow.getCells().get(0).getValue().getValue());
assertEquals(DecisionTableDefaultValueUtilities.INPUT_CLAUSE_UNARY_TEST_TEXT, uiGridRow.getCells().get(1).getValue().getValue());
assertEquals(DecisionTableDefaultValueUtilities.OUTPUT_CLAUSE_EXPRESSION_TEXT, uiGridRow.getCells().get(2).getValue().getValue());
assertEquals(DecisionTableDefaultValueUtilities.RULE_ANNOTATION_CLAUSE_EXPRESSION_TEXT, uiGridRow.getCells().get(3).getValue().getValue());
}
use of org.uberfire.ext.wires.core.grids.client.model.GridRow 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;
}
Aggregations