Search in sources :

Example 6 with UndefinedExpressionGrid

use of org.kie.workbench.common.dmn.client.editors.expressions.types.undefined.UndefinedExpressionGrid in project kie-wb-common by kiegroup.

the class ListGrid method getItems.

@Override
public java.util.List<ListSelectorItem> getItems(final int uiRowIndex, final int uiColumnIndex) {
    final java.util.List<ListSelectorItem> items = new ArrayList<>();
    final boolean isMultiRow = SelectionUtils.isMultiRow(model);
    final boolean isMultiSelect = SelectionUtils.isMultiSelect(model);
    items.add(ListSelectorHeaderItem.build(translationService.format(DMNEditorConstants.ListEditor_HeaderRows)));
    items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ListEditor_InsertRowAbove), !isMultiRow, () -> {
        cellEditorControls.hide();
        getExpression().get().ifPresent(e -> addRow(uiRowIndex));
    }));
    items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ListEditor_InsertRowBelow), !isMultiRow, () -> {
        cellEditorControls.hide();
        getExpression().get().ifPresent(e -> addRow(uiRowIndex + 1));
    }));
    items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ListEditor_DeleteRow), !isMultiRow && model.getRowCount() > 1, () -> {
        cellEditorControls.hide();
        getExpression().get().ifPresent(e -> deleteRow(uiRowIndex));
    }));
    // If not ExpressionEditor column don't add extra items
    if (ListUIModelMapperHelper.getSection(uiColumnIndex) != ListUIModelMapperHelper.ListSection.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 : CellEditorControlsView(org.kie.workbench.common.dmn.client.widgets.grid.controls.container.CellEditorControlsView) DefinitionUtils(org.kie.workbench.common.stunner.core.util.DefinitionUtils) DeleteListRowCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.list.DeleteListRowCommand) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) HasListSelectorControl(org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl) 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) Supplier(java.util.function.Supplier) List(org.kie.workbench.common.dmn.api.definition.model.List) 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) UndefinedExpressionGrid(org.kie.workbench.common.dmn.client.editors.expressions.types.undefined.UndefinedExpressionGrid) ReadOnlyProvider(org.kie.workbench.common.stunner.core.client.ReadOnlyProvider) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) SessionManager(org.kie.workbench.common.stunner.core.client.api.SessionManager) 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) EventPropagationMode(com.ait.lienzo.shared.core.types.EventPropagationMode) ContextGridRowNumberColumn(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ContextGridRowNumberColumn) TranslationService(org.jboss.errai.ui.client.local.spi.TranslationService) GridCell(org.uberfire.ext.wires.core.grids.client.model.GridCell) ClearExpressionTypeCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.list.ClearExpressionTypeCommand) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) SelectionUtils(org.kie.workbench.common.dmn.client.editors.expressions.util.SelectionUtils) SessionCommandManager(org.kie.workbench.common.stunner.core.client.command.SessionCommandManager) DomainObject(org.kie.workbench.common.stunner.core.domainobject.DomainObject) HasName(org.kie.workbench.common.dmn.api.definition.HasName) DomainObjectSelectionEvent(org.kie.workbench.common.stunner.core.client.canvas.event.selection.DomainObjectSelectionEvent) DefaultCanvasCommandFactory(org.kie.workbench.common.dmn.client.commands.factory.DefaultCanvasCommandFactory) ExpressionEditorGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.ExpressionEditorGridRow) AddListRowCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.list.AddListRowCommand) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) Optional(java.util.Optional) ExpressionEditorColumn(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionEditorColumn) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) Collections(java.util.Collections) ValueAndDataTypePopoverView(org.kie.workbench.common.dmn.client.editors.types.ValueAndDataTypePopoverView) 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) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)

Example 7 with UndefinedExpressionGrid

use of org.kie.workbench.common.dmn.client.editors.expressions.types.undefined.UndefinedExpressionGrid in project kie-wb-common by kiegroup.

the class InvocationGrid 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);
    items.add(ListSelectorHeaderItem.build(translationService.format(DMNEditorConstants.InvocationEditor_Header)));
    items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.InvocationEditor_InsertParameterAbove), !isMultiRow, () -> {
        cellEditorControls.hide();
        getExpression().get().ifPresent(e -> addParameterBinding(uiRowIndex));
    }));
    items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.InvocationEditor_InsertParameterBelow), !isMultiRow, () -> {
        cellEditorControls.hide();
        getExpression().get().ifPresent(e -> addParameterBinding(uiRowIndex + 1));
    }));
    items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.InvocationEditor_DeleteParameter), !isMultiRow && model.getRowCount() > 1, () -> {
        cellEditorControls.hide();
        deleteParameterBinding(uiRowIndex);
    }));
    // If not ExpressionEditor column don't add extra items
    if (uiColumnIndex != InvocationUIModelMapper.BINDING_EXPRESSION_COLUMN_INDEX) {
        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;
    }
    items.add(new ListSelectorDividerItem());
    items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ExpressionEditor_Clear), !isMultiSelect, () -> {
        cellEditorControls.hide();
        clearExpressionType(uiRowIndex);
    }));
    return items;
}
Also used : ClearExpressionTypeCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.invocation.ClearExpressionTypeCommand) CellEditorControlsView(org.kie.workbench.common.dmn.client.widgets.grid.controls.container.CellEditorControlsView) DefinitionUtils(org.kie.workbench.common.stunner.core.util.DefinitionUtils) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) 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) ExpressionEditorDefinitions(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions) UndefinedExpressionGrid(org.kie.workbench.common.dmn.client.editors.expressions.types.undefined.UndefinedExpressionGrid) EventPropagationMode(com.ait.lienzo.shared.core.types.EventPropagationMode) 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) 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) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) Optional(java.util.Optional) ValueAndDataTypePopoverView(org.kie.workbench.common.dmn.client.editors.types.ValueAndDataTypePopoverView) Binding(org.kie.workbench.common.dmn.api.definition.model.Binding) AddParameterBindingCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.invocation.AddParameterBindingCommand) HasListSelectorControl(org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl) Supplier(java.util.function.Supplier) 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) RowNumberColumn(org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn) 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) Invocation(org.kie.workbench.common.dmn.api.definition.model.Invocation) 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) UndefinedExpressionColumn(org.kie.workbench.common.dmn.client.editors.expressions.types.undefined.UndefinedExpressionColumn) SelectionUtils(org.kie.workbench.common.dmn.client.editors.expressions.util.SelectionUtils) SessionCommandManager(org.kie.workbench.common.stunner.core.client.command.SessionCommandManager) DeleteParameterBindingCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.invocation.DeleteParameterBindingCommand) DMNModelInstrumentedBase(org.kie.workbench.common.dmn.api.definition.model.DMNModelInstrumentedBase) DomainObjectSelectionEvent(org.kie.workbench.common.stunner.core.client.canvas.event.selection.DomainObjectSelectionEvent) Text(org.kie.workbench.common.dmn.api.property.dmn.Text) ExpressionEditorGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.ExpressionEditorGridRow) ExpressionEditorColumn(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionEditorColumn) 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) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)

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