Search in sources :

Example 1 with UndefinedExpressionGrid

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());
}
Also used : Group(com.ait.lienzo.client.core.shape.Group) GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) UndefinedExpressionGrid(org.kie.workbench.common.dmn.client.editors.expressions.types.undefined.UndefinedExpressionGrid) IPathClipper(com.ait.lienzo.client.core.shape.IPathClipper) Rectangle(com.ait.lienzo.client.core.shape.Rectangle) Transform(com.ait.lienzo.client.core.types.Transform) LiteralExpressionGrid(org.kie.workbench.common.dmn.client.editors.expressions.types.literal.LiteralExpressionGrid)

Example 2 with UndefinedExpressionGrid

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;
}
Also used : BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) UndefinedExpressionGrid(org.kie.workbench.common.dmn.client.editors.expressions.types.undefined.UndefinedExpressionGrid) ArrayList(java.util.ArrayList) FunctionDefinition(org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)

Example 3 with UndefinedExpressionGrid

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();
}
Also used : GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) UndefinedExpressionGrid(org.kie.workbench.common.dmn.client.editors.expressions.types.undefined.UndefinedExpressionGrid) Test(org.junit.Test)

Example 4 with UndefinedExpressionGrid

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;
}
Also used : AddContextEntryCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.context.AddContextEntryCommand) CellEditorControlsView(org.kie.workbench.common.dmn.client.widgets.grid.controls.container.CellEditorControlsView) DefinitionUtils(org.kie.workbench.common.stunner.core.util.DefinitionUtils) ListSelectorView(org.kie.workbench.common.dmn.client.widgets.grid.controls.list.ListSelectorView) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) DMNGridLayer(org.kie.workbench.common.dmn.client.widgets.layer.DMNGridLayer) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) BaseExpressionGridRenderer(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGridRenderer) ExpressionEditorDefinitions(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions) UndefinedExpressionGrid(org.kie.workbench.common.dmn.client.editors.expressions.types.undefined.UndefinedExpressionGrid) DeleteContextEntryCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.context.DeleteContextEntryCommand) EventPropagationMode(com.ait.lienzo.shared.core.types.EventPropagationMode) ContextEntry(org.kie.workbench.common.dmn.api.definition.model.ContextEntry) GridCell(org.uberfire.ext.wires.core.grids.client.model.GridCell) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) DomainObject(org.kie.workbench.common.stunner.core.domainobject.DomainObject) HasName(org.kie.workbench.common.dmn.api.definition.HasName) List(java.util.List) ClearExpressionTypeCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.context.ClearExpressionTypeCommand) DefaultCanvasCommandFactory(org.kie.workbench.common.dmn.client.commands.factory.DefaultCanvasCommandFactory) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) CommandUtils(org.kie.workbench.common.stunner.core.command.util.CommandUtils) Optional(java.util.Optional) GridWidgetDnDHandlersState(org.uberfire.ext.wires.core.grids.client.widget.dnd.GridWidgetDnDHandlersState) ValueAndDataTypePopoverView(org.kie.workbench.common.dmn.client.editors.types.ValueAndDataTypePopoverView) HasListSelectorControl(org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl) GridWidgetHandlersOperation(org.uberfire.ext.wires.core.grids.client.widget.dnd.GridWidgetDnDHandlersState.GridWidgetHandlersOperation) Supplier(java.util.function.Supplier) BaseHeaderMetaData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseHeaderMetaData) ArrayList(java.util.ArrayList) ExpressionEditorChanged(org.kie.workbench.common.dmn.client.widgets.grid.model.ExpressionEditorChanged) RefreshFormPropertiesEvent(org.kie.workbench.common.stunner.forms.client.event.RefreshFormPropertiesEvent) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) ReadOnlyProvider(org.kie.workbench.common.stunner.core.client.ReadOnlyProvider) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) DMNGridColumn(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridColumn) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) Context(org.kie.workbench.common.dmn.api.definition.model.Context) SessionManager(org.kie.workbench.common.stunner.core.client.api.SessionManager) CommandResult(org.kie.workbench.common.stunner.core.command.CommandResult) Event(javax.enterprise.event.Event) DMNEditorConstants(org.kie.workbench.common.dmn.client.resources.i18n.DMNEditorConstants) DMNGridPanel(org.kie.workbench.common.dmn.client.widgets.panel.DMNGridPanel) CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) TranslationService(org.jboss.errai.ui.client.local.spi.TranslationService) HasRowDragRestrictions(org.kie.workbench.common.dmn.client.widgets.grid.model.HasRowDragRestrictions) UndefinedExpressionColumn(org.kie.workbench.common.dmn.client.editors.expressions.types.undefined.UndefinedExpressionColumn) SelectionUtils(org.kie.workbench.common.dmn.client.editors.expressions.util.SelectionUtils) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) SessionCommandManager(org.kie.workbench.common.stunner.core.client.command.SessionCommandManager) DMNModelInstrumentedBase(org.kie.workbench.common.dmn.api.definition.model.DMNModelInstrumentedBase) DomainObjectSelectionEvent(org.kie.workbench.common.stunner.core.client.canvas.event.selection.DomainObjectSelectionEvent) ExpressionEditorGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.ExpressionEditorGridRow) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) UndefinedExpressionGrid(org.kie.workbench.common.dmn.client.editors.expressions.types.undefined.UndefinedExpressionGrid) ArrayList(java.util.ArrayList)

Example 5 with UndefinedExpressionGrid

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);
}
Also used : Optional(java.util.Optional) UndefinedExpressionGrid(org.kie.workbench.common.dmn.client.editors.expressions.types.undefined.UndefinedExpressionGrid) Test(org.junit.Test)

Aggregations

UndefinedExpressionGrid (org.kie.workbench.common.dmn.client.editors.expressions.types.undefined.UndefinedExpressionGrid)7 ArrayList (java.util.ArrayList)4 Optional (java.util.Optional)4 BaseExpressionGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid)4 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)4 EventPropagationMode (com.ait.lienzo.shared.core.types.EventPropagationMode)3 Supplier (java.util.function.Supplier)3 Event (javax.enterprise.event.Event)3 TranslationService (org.jboss.errai.ui.client.local.spi.TranslationService)3 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)3 HasName (org.kie.workbench.common.dmn.api.definition.HasName)3 DefaultCanvasCommandFactory (org.kie.workbench.common.dmn.client.commands.factory.DefaultCanvasCommandFactory)3 ExpressionEditorDefinitions (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions)3 ExpressionCellValue (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)3 SelectionUtils (org.kie.workbench.common.dmn.client.editors.expressions.util.SelectionUtils)3 ValueAndDataTypePopoverView (org.kie.workbench.common.dmn.client.editors.types.ValueAndDataTypePopoverView)3 DMNEditorConstants (org.kie.workbench.common.dmn.client.resources.i18n.DMNEditorConstants)3 CellEditorControlsView (org.kie.workbench.common.dmn.client.widgets.grid.controls.container.CellEditorControlsView)3 HasListSelectorControl (org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl)3 ListSelectorView (org.kie.workbench.common.dmn.client.widgets.grid.controls.list.ListSelectorView)3