Search in sources :

Example 26 with BaseExpressionGrid

use of org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid in project kie-wb-common by kiegroup.

the class JavaFunctionEditorDefinitionTest 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 FunctionSupplementaryGrid);
}
Also used : Context(org.kie.workbench.common.dmn.api.definition.v1_1.Context) FunctionSupplementaryGrid(org.kie.workbench.common.dmn.client.editors.expressions.types.function.supplementary.FunctionSupplementaryGrid) GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) Test(org.junit.Test)

Example 27 with BaseExpressionGrid

use of org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid in project kie-wb-common by kiegroup.

the class PMMLFunctionEditorDefinitionTest 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 FunctionSupplementaryGrid);
}
Also used : Context(org.kie.workbench.common.dmn.api.definition.v1_1.Context) FunctionSupplementaryGrid(org.kie.workbench.common.dmn.client.editors.expressions.types.function.supplementary.FunctionSupplementaryGrid) GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) Test(org.junit.Test)

Example 28 with BaseExpressionGrid

use of org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid in project kie-wb-common by kiegroup.

the class RelationEditorDefinitionTest method testEditor.

@Test
public void testEditor() {
    final Optional<Relation> expression = definition.getModelClass();
    final Optional<BaseExpressionGrid> oEditor = definition.getEditor(parent, Optional.empty(), hasExpression, expression, hasName, 0);
    assertThat(oEditor).isPresent();
    final GridWidget editor = oEditor.get();
    assertThat(editor).isInstanceOf(RelationGrid.class);
}
Also used : Relation(org.kie.workbench.common.dmn.api.definition.v1_1.Relation) GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) Test(org.junit.Test)

Example 29 with BaseExpressionGrid

use of org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid 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<>();
    items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.InvocationEditor_InsertParameterAbove), true, () -> {
        cellEditorControls.hide();
        expression.ifPresent(e -> addParameterBinding(uiRowIndex));
    }));
    items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.InvocationEditor_InsertParameterBelow), true, () -> {
        cellEditorControls.hide();
        expression.ifPresent(e -> addParameterBinding(uiRowIndex + 1));
    }));
    items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.InvocationEditor_DeleteParameter), 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), true, () -> {
        cellEditorControls.hide();
        clearExpressionType(uiRowIndex);
    }));
    return items;
}
Also used : CellEditorControlsView(org.kie.workbench.common.dmn.client.widgets.grid.controls.container.CellEditorControlsView) Arrays(java.util.Arrays) DefinitionUtils(org.kie.workbench.common.stunner.core.util.DefinitionUtils) AddParameterBindingCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.invocation.AddParameterBindingCommand) HasListSelectorControl(org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl) ListSelectorView(org.kie.workbench.common.dmn.client.widgets.grid.controls.list.ListSelectorView) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) DMNGridLayer(org.kie.workbench.common.dmn.client.widgets.layer.DMNGridLayer) Binding(org.kie.workbench.common.dmn.api.definition.v1_1.Binding) ClearExpressionTypeCommand(org.kie.workbench.common.dmn.client.commands.general.ClearExpressionTypeCommand) ExpressionEditorDefinitions(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions) Supplier(java.util.function.Supplier) BaseHeaderMetaData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseHeaderMetaData) ArrayList(java.util.ArrayList) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) RowNumberColumn(org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) UndefinedExpressionGrid(org.kie.workbench.common.dmn.client.editors.expressions.types.undefined.UndefinedExpressionGrid) 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) 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) TranslationService(org.jboss.errai.ui.client.local.spi.TranslationService) CanvasCommandFactory(org.kie.workbench.common.stunner.core.client.command.CanvasCommandFactory) GridCell(org.uberfire.ext.wires.core.grids.client.model.GridCell) GridDataCache(org.kie.workbench.common.dmn.client.widgets.grid.model.GridDataCache) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) SessionCommandManager(org.kie.workbench.common.stunner.core.client.command.SessionCommandManager) DeleteParameterBindingCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.invocation.DeleteParameterBindingCommand) HasName(org.kie.workbench.common.dmn.api.definition.HasName) NameColumnHeaderMetaData(org.kie.workbench.common.dmn.client.editors.expressions.types.context.NameColumnHeaderMetaData) List(java.util.List) TextBoxSingletonDOMElementFactory(org.kie.workbench.common.dmn.client.widgets.grid.columns.factory.TextBoxSingletonDOMElementFactory) 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) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) Invocation(org.kie.workbench.common.dmn.api.definition.v1_1.Invocation) 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 30 with BaseExpressionGrid

use of org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid in project kie-wb-common by kiegroup.

the class DMNGridColumn method updateWidthOfPeers.

public void updateWidthOfPeers() {
    if (gridWidget instanceof BaseExpressionGrid) {
        final BaseExpressionGrid beg = (BaseExpressionGrid) gridWidget;
        final int parentColumnIndex = beg.getParentInformation().getColumnIndex();
        final GridData parentGridData = beg.getParentInformation().getGridWidget().getModel();
        if (parentGridData != null) {
            final GridColumn<?> parentColumn = parentGridData.getColumns().get(parentColumnIndex);
            parentColumn.setWidth(beg.getWidth() + beg.getPadding() * 2);
        }
    }
}
Also used : BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData)

Aggregations

BaseExpressionGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid)32 Test (org.junit.Test)15 ExpressionCellValue (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)13 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)13 GridData (org.uberfire.ext.wires.core.grids.client.model.GridData)11 GridWidget (org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget)11 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)8 List (java.util.List)7 Optional (java.util.Optional)7 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)7 Expression (org.kie.workbench.common.dmn.api.definition.v1_1.Expression)7 GridCell (org.uberfire.ext.wires.core.grids.client.model.GridCell)7 ArrayList (java.util.ArrayList)6 HasName (org.kie.workbench.common.dmn.api.definition.HasName)6 HasListSelectorControl (org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl)6 DMNGridRow (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow)6 DMNGridLayer (org.kie.workbench.common.dmn.client.widgets.layer.DMNGridLayer)6 InformationItem (org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem)5 ExpressionEditorDefinition (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinition)5 ExpressionEditorColumn (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionEditorColumn)5