use of org.kie.workbench.common.dmn.client.editors.expressions.types.undefined.UndefinedExpressionGrid in project kie-wb-common by kiegroup.
the class DMNGridLayer method addGhost.
void addGhost(final ExpressionContainerGrid container, final GridWidget gridWidget) {
// Rectangle the size of the ExpressionContainerGrid
final Rectangle r = getGhostRectangle();
r.setWidth(container.getWidth() + BaseExpressionGridTheme.STROKE_WIDTH);
r.setHeight(container.getHeight() + BaseExpressionGridTheme.STROKE_WIDTH);
r.setFillColor(ColorName.WHITE);
r.setAlpha(0.50);
r.setListening(false);
final Group g = GWT.create(Group.class);
final Transform transform = getViewport().getTransform();
g.setX(container.getX() + transform.getTranslateX());
g.setY(container.getY() + transform.getTranslateY());
g.add(r);
// LiteralExpression and UndefinedExpression are not handled as grids in
// their own right. In these circumstances use their parent GridWidget.
GridWidget gw = gridWidget;
if (gw instanceof LiteralExpressionGrid) {
gw = ((LiteralExpressionGrid) gw).getParentInformation().getGridWidget();
} else if (gw instanceof UndefinedExpressionGrid) {
gw = ((UndefinedExpressionGrid) gw).getParentInformation().getGridWidget();
}
// Clip the inner GridWidget so everything outside of it is ghosted
final IPathClipper clipper = new InverseGridWidgetClipper(container, gw);
clipper.setActive(true);
g.setPathClipper(clipper);
g.drawWithTransforms(getContext(), 1.0, getStorageBounds());
}
use of org.kie.workbench.common.dmn.client.editors.expressions.types.undefined.UndefinedExpressionGrid in project kie-wb-common by kiegroup.
the class FunctionGrid method getItems.
@Override
@SuppressWarnings("unused")
public List<ListSelectorItem> getItems(final int uiRowIndex, final int uiColumnIndex) {
final List<ListSelectorItem> items = new ArrayList<>();
final FunctionDefinition.Kind kind = KindUtilities.getKind(getExpression().get().get());
// If cell editor is UndefinedExpressionGrid don't add extra items
final GridCell<?> cell = model.getCell(uiRowIndex, uiColumnIndex);
final ExpressionCellValue ecv = (ExpressionCellValue) cell.getValue();
if (!ecv.getValue().isPresent()) {
return items;
}
final BaseExpressionGrid grid = ecv.getValue().get();
if (grid instanceof UndefinedExpressionGrid) {
return items;
}
items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ExpressionEditor_Clear), true, () -> {
cellEditorControls.hide();
gridPanel.setFocus(true);
clearExpressionType();
}));
return items;
}
use of org.kie.workbench.common.dmn.client.editors.expressions.types.undefined.UndefinedExpressionGrid in project kie-wb-common by kiegroup.
the class DMNGridLayerTest method testGhostRenderingUndefinedExpression.
@Test
public void testGhostRenderingUndefinedExpression() {
final UndefinedExpressionGrid undefinedExpressionGrid = mock(UndefinedExpressionGrid.class);
final GridCellTuple parentGridCellTuple = new GridCellTuple(0, 0, container);
GwtMockito.useProviderForType(Group.class, clazz -> ghostGroup);
doReturn(new HashSet<>(Arrays.asList(container, undefinedExpressionGrid))).when(gridLayer).getGridWidgets();
doReturn(ghostRectangle).when(gridLayer).getGhostRectangle();
doReturn(parentGridCellTuple).when(undefinedExpressionGrid).getParentInformation();
gridLayer.select(undefinedExpressionGrid);
gridLayer.doBatch();
assertGhostRendering();
}
use of org.kie.workbench.common.dmn.client.editors.expressions.types.undefined.UndefinedExpressionGrid in project kie-wb-common by kiegroup.
the class ContextGrid method getItems.
@Override
@SuppressWarnings("unused")
public List<ListSelectorItem> getItems(final int uiRowIndex, final int uiColumnIndex) {
final List<ListSelectorItem> items = new ArrayList<>();
final boolean isMultiRow = SelectionUtils.isMultiRow(model);
final boolean isMultiSelect = SelectionUtils.isMultiSelect(model);
if (uiRowIndex < model.getRowCount() - 1) {
items.add(ListSelectorHeaderItem.build(translationService.format(DMNEditorConstants.ContextEditor_Header)));
items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ContextEditor_InsertContextEntryAbove), !isMultiRow, () -> {
cellEditorControls.hide();
getExpression().get().ifPresent(e -> addContextEntry(uiRowIndex));
}));
items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ContextEditor_InsertContextEntryBelow), !isMultiRow, () -> {
cellEditorControls.hide();
getExpression().get().ifPresent(e -> addContextEntry(uiRowIndex + 1));
}));
items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ContextEditor_DeleteContextEntry), !isMultiRow && model.getRowCount() > 2 && uiRowIndex < model.getRowCount() - 1, () -> {
cellEditorControls.hide();
deleteContextEntry(uiRowIndex);
}));
}
// If not ExpressionEditor column don't add extra items
if (ContextUIModelMapperHelper.getSection(uiColumnIndex) != ContextUIModelMapperHelper.ContextSection.EXPRESSION) {
return items;
}
// If cell editor is UndefinedExpressionGrid don't add extra items
final GridCell<?> cell = model.getCell(uiRowIndex, uiColumnIndex);
final ExpressionCellValue ecv = (ExpressionCellValue) cell.getValue();
if (!ecv.getValue().isPresent()) {
return items;
}
final BaseExpressionGrid grid = ecv.getValue().get();
if (grid instanceof UndefinedExpressionGrid) {
return items;
}
if (items.size() > 0) {
items.add(new ListSelectorDividerItem());
}
items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ExpressionEditor_Clear), !isMultiSelect, () -> {
cellEditorControls.hide();
clearExpressionType(uiRowIndex);
}));
return items;
}
use of org.kie.workbench.common.dmn.client.editors.expressions.types.undefined.UndefinedExpressionGrid in project kie-wb-common by kiegroup.
the class ExpressionEditorColumnTest method testEditNestedUndefinedExpressionGrid.
@Test
public void testEditNestedUndefinedExpressionGrid() {
final GridCell<Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>>> cell = mock(GridCell.class);
final GridCellValue<Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>>> cellValue = mock(GridCellValue.class);
final UndefinedExpressionGrid undefinedExpressionGrid = mock(UndefinedExpressionGrid.class);
when(cell.getValue()).thenReturn(cellValue);
when(cellValue.getValue()).thenReturn(Optional.of(undefinedExpressionGrid));
column.edit(cell, null, null);
verify(undefinedExpressionGrid).startEditingCell(0, 0);
}
Aggregations