Search in sources :

Example 31 with BaseGridData

use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData in project kie-wb-common by kiegroup.

the class DMNGridPanelContextMenuHandlerTest method mockGridWidget.

private BaseGrid mockGridWidget() {
    final BaseGrid gridWidget = spy(new BaseGrid(gridLayer, new BaseGridData(false), renderer, sessionManager, sessionCommandManager, canvasCommandFactory, refreshFormPropertiesEvent, domainObjectSelectionEvent, cellEditorControls, translationService) {

        @Override
        public Layer getLayer() {
            return gridLayer;
        }
    });
    gridWidget.getModel().appendColumn(new RowNumberColumn());
    gridWidget.getModel().appendColumn(gridColumn);
    gridWidget.getModel().appendRow(new BaseGridRow());
    gridWidget.getModel().appendRow(new BaseGridRow());
    return gridWidget;
}
Also used : RowNumberColumn(org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) DMNGridLayer(org.kie.workbench.common.dmn.client.widgets.layer.DMNGridLayer) Layer(com.ait.lienzo.client.core.shape.Layer) BaseGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseGrid)

Example 32 with BaseGridData

use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData in project kie-wb-common by kiegroup.

the class DeleteRelationColumnCommandTest method setup.

@Before
public void setup() {
    this.relation = new Relation();
    this.informationItem = new InformationItem();
    this.relation.getColumn().add(informationItem);
    this.uiModel = new BaseGridData();
    this.uiModel.appendColumn(uiRowNumberColumn);
    this.uiModel.appendColumn(uiModelColumn);
    doReturn(ruleManager).when(handler).getRuleManager();
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiModelColumn).getIndex();
    this.uiModelMapper = new RelationUIModelMapper(() -> uiModel, () -> Optional.of(relation), listSelector, DEFAULT_HEIGHT);
}
Also used : RelationUIModelMapper(org.kie.workbench.common.dmn.client.editors.expressions.types.relation.RelationUIModelMapper) Relation(org.kie.workbench.common.dmn.api.definition.model.Relation) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Before(org.junit.Before)

Example 33 with BaseGridData

use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData in project kie-wb-common by kiegroup.

the class FunctionGridTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    when(parent.getGridWidget()).thenReturn(parentGridWidget);
    when(parentGridWidget.getModel()).thenReturn(parentGridData);
    when(parentGridData.getColumns()).thenReturn(Collections.singletonList(parentGridColumn));
    when(sessionManager.getCurrentSession()).thenReturn(session);
    when(session.getGridPanel()).thenReturn(gridPanel);
    when(session.getGridLayer()).thenReturn(gridLayer);
    when(session.getCellEditorControls()).thenReturn(cellEditorControls);
    definition = new FunctionEditorDefinition(definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, editorSelectedEvent, refreshFormPropertiesEvent, domainObjectSelectionEvent, listSelector, translationService, expressionEditorDefinitionsSupplier, supplementaryEditorDefinitionsSupplier, headerEditor, parametersEditor, kindEditor, readOnlyProvider);
    literalExpressionEditorDefinition = spy(new LiteralExpressionEditorDefinition(definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, editorSelectedEvent, refreshFormPropertiesEvent, domainObjectSelectionEvent, listSelector, translationService, headerEditor, readOnlyProvider));
    expression = definition.getModelClass();
    definition.enrich(Optional.empty(), hasExpression, expression);
    expression.get().getFormalParameter().add(parameter);
    parameter.getName().setValue(PARAMETER_NAME);
    final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
    expressionEditorDefinitions.add((ExpressionEditorDefinition) definition);
    expressionEditorDefinitions.add((ExpressionEditorDefinition) literalExpressionEditorDefinition);
    expressionEditorDefinitions.add(supplementaryExpressionEditorDefinition);
    final Decision decision = new Decision();
    decision.setName(new Name("name"));
    hasName = Optional.of(decision);
    when(expressionEditorDefinitionsSupplier.get()).thenReturn(expressionEditorDefinitions);
    when(supplementaryEditorDefinitionsSupplier.get()).thenReturn(expressionEditorDefinitions);
    // Setup LiteralExpression definition and editor
    doReturn(Optional.of(literalExpressionEditor)).when(literalExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt());
    when(literalExpressionEditor.getGridPanel()).thenReturn(gridPanel);
    when(literalExpressionEditor.getLayer()).thenReturn(gridLayer);
    when(literalExpressionEditor.getModel()).thenReturn(new BaseGridData(false));
    doCallRealMethod().when(literalExpressionEditor).resize(any(Function.class));
    doCallRealMethod().when(literalExpressionEditor).doResize(any(PrioritizedCommand.class), any(Function.class));
    doCallRealMethod().when(literalExpressionEditor).selectFirstCell();
    when(literalExpressionEditor.getParentInformation()).thenReturn(parent);
    // Setup Supplementary expression definition and editor
    when(supplementaryExpressionEditorDefinition.getModelClass()).thenReturn(Optional.of(supplementaryExpression));
    when(supplementaryExpressionEditorDefinition.getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt())).thenReturn(Optional.of(supplementaryExpressionEditor));
    when(supplementaryExpressionEditor.getGridPanel()).thenReturn(gridPanel);
    when(supplementaryExpressionEditor.getLayer()).thenReturn(gridLayer);
    when(supplementaryExpressionEditor.getModel()).thenReturn(new BaseGridData(false));
    doCallRealMethod().when(supplementaryExpressionEditor).resize(any(Function.class));
    doCallRealMethod().when(supplementaryExpressionEditor).doResize(any(PrioritizedCommand.class), any(Function.class));
    doCallRealMethod().when(supplementaryExpressionEditor).selectFirstCell();
    when(supplementaryExpressionEditor.getParentInformation()).thenReturn(parent);
    when(session.getCanvasHandler()).thenReturn(canvasHandler);
    when(gridWidget.getModel()).thenReturn(new BaseGridData(false));
    when(canvasHandler.getDiagram()).thenReturn(diagram);
    when(diagram.getGraph()).thenReturn(graph);
    when(graph.nodes()).thenReturn(Collections.singletonList(node));
    when(canvasHandler.getGraphIndex()).thenReturn(index);
    when(index.get(Mockito.<String>any())).thenReturn(element);
    when(element.getContent()).thenReturn(mock(Definition.class));
    when(definitionUtils.getNameIdentifier(any())).thenReturn("name");
    when(canvasCommandFactory.updatePropertyValue(any(Element.class), Mockito.<String>any(), any())).thenReturn(mock(UpdateElementPropertyCommand.class));
    when(canvasHandler.getGraphExecutionContext()).thenReturn(graphCommandExecutionContext);
    doAnswer((i) -> i.getArguments()[0].toString()).when(translationService).format(Mockito.<String>any());
    doAnswer((i) -> i.getArguments()[0].toString()).when(translationService).getTranslation(Mockito.<String>any());
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) Optional(java.util.Optional) Element(org.kie.workbench.common.stunner.core.graph.Element) FunctionDefinition(org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition) ExpressionEditorDefinition(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinition) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) LiteralExpressionEditorDefinition(org.kie.workbench.common.dmn.client.editors.expressions.types.literal.LiteralExpressionEditorDefinition) LiteralExpressionEditorDefinition(org.kie.workbench.common.dmn.client.editors.expressions.types.literal.LiteralExpressionEditorDefinition) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) UpdateElementPropertyCommand(org.kie.workbench.common.stunner.core.client.canvas.command.UpdateElementPropertyCommand) HasName(org.kie.workbench.common.dmn.api.definition.HasName) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) ExpressionEditorDefinitions(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions) Function(java.util.function.Function) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) PrioritizedCommand(org.uberfire.ext.wires.core.grids.client.widget.layer.impl.GridLayerRedrawManager.PrioritizedCommand) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Before(org.junit.Before)

Example 34 with BaseGridData

use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData in project kie-wb-common by kiegroup.

the class BaseLiteralExpressionGridTest method setup.

@Before
public void setup() {
    when(sessionManager.getCurrentSession()).thenReturn(session);
    when(session.getGridPanel()).thenReturn(gridPanel);
    when(session.getGridLayer()).thenReturn(gridLayer);
    when(session.getCellEditorControls()).thenReturn(cellEditorControls);
    tupleWithoutValue = new GridCellTuple(0, 0, gridWidget);
    tupleWithValue = new GridCellValueTuple<>(0, 0, gridWidget, new BaseGridCellValue<>("value"));
    definition = getDefinition();
    final Decision decision = new Decision();
    decision.setName(new Name(NAME));
    hasName = Optional.of(decision);
    expression = definition.getModelClass();
    expression.ifPresent(e -> e.getText().setValue(EXPRESSION_TEXT));
    when(session.getCanvasHandler()).thenReturn(canvasHandler);
    when(gridLayer.getVisibleBounds()).thenReturn(mock(Bounds.class));
    when(gridWidget.getModel()).thenReturn(new BaseGridData(false));
    when(canvasHandler.getDiagram()).thenReturn(diagram);
    when(diagram.getGraph()).thenReturn(graph);
    when(graph.nodes()).thenReturn(Collections.singletonList(node));
    when(canvasHandler.getGraphIndex()).thenReturn(index);
    when(index.get(Mockito.<String>any())).thenReturn(element);
    when(element.getContent()).thenReturn(mock(Definition.class));
    when(definitionUtils.getNameIdentifier(any())).thenReturn("name");
    when(canvasCommandFactory.updatePropertyValue(any(Element.class), Mockito.<String>any(), any())).thenReturn(mock(UpdateElementPropertyCommand.class));
    parentGridWidget = getParentGridWidget();
    parentGridUiModel = getParentGridWidgetUiModel();
    when(parentGridWidget.getModel()).thenReturn(parentGridUiModel);
    when(parent.getGridWidget()).thenReturn(parentGridWidget);
    when(parent.getRowIndex()).thenReturn(PARENT_ROW_INDEX);
    when(parent.getColumnIndex()).thenReturn(PARENT_COLUMN_INDEX);
    doAnswer((i) -> i.getArguments()[0].toString()).when(translationService).getTranslation(Mockito.<String>any());
}
Also used : GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) Bounds(org.uberfire.ext.wires.core.grids.client.model.Bounds) Element(org.kie.workbench.common.stunner.core.graph.Element) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) BaseEditorDefinition(org.kie.workbench.common.dmn.client.editors.expressions.types.BaseEditorDefinition) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) UpdateElementPropertyCommand(org.kie.workbench.common.stunner.core.client.canvas.command.UpdateElementPropertyCommand) BaseGridCellValue(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue) HasName(org.kie.workbench.common.dmn.api.definition.HasName) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Before(org.junit.Before)

Example 35 with BaseGridData

use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData in project kie-wb-common by kiegroup.

the class FunctionUIModelMapperTest method setup.

@SuppressWarnings("unchecked")
public void setup(final boolean isOnlyVisualChangeAllowedSupplier) {
    this.uiModel = new BaseGridData();
    this.uiModel.appendRow(new BaseGridRow());
    this.uiModel.appendRow(new BaseGridRow());
    this.uiModel.appendColumn(uiExpressionEditorColumn);
    when(uiExpressionEditorColumn.getIndex()).thenReturn(0);
    when(gridWidget.getModel()).thenReturn(uiModel);
    // Core Editor definitions
    final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
    expressionEditorDefinitions.add(literalExpressionEditorDefinition);
    when(expressionEditorDefinitionsSupplier.get()).thenReturn(expressionEditorDefinitions);
    when(literalExpressionEditorDefinition.getModelClass()).thenReturn(Optional.of(literalExpression));
    when(literalExpressionEditor.getExpression()).thenReturn(() -> Optional.of(literalExpression));
    when(literalExpressionEditorDefinition.getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt())).thenReturn(Optional.of(literalExpressionEditor));
    // Supplementary Editor definitions
    final ExpressionEditorDefinitions supplementaryEditorDefinitions = new ExpressionEditorDefinitions();
    supplementaryEditorDefinitions.add(supplementaryEditorDefinition);
    when(supplementaryEditorDefinitionsSupplier.get()).thenReturn(supplementaryEditorDefinitions);
    when(supplementaryEditorDefinition.getModelClass()).thenReturn(Optional.of(context));
    when(supplementaryEditor.getExpression()).thenReturn(() -> Optional.of(context));
    when(supplementaryEditorDefinition.getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt())).thenReturn(Optional.of(supplementaryEditor));
    this.function = new FunctionDefinition();
    this.mapper = new FunctionUIModelMapper(gridWidget, () -> uiModel, () -> Optional.of(function), () -> isOnlyVisualChangeAllowedSupplier, expressionEditorDefinitionsSupplier, supplementaryEditorDefinitionsSupplier, listSelector, 1);
    this.cellValueSupplier = Optional::empty;
}
Also used : ExpressionEditorDefinitions(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) Optional(java.util.Optional) FunctionDefinition(org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)

Aggregations

BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)56 Before (org.junit.Before)41 BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)24 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)23 Optional (java.util.Optional)20 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)19 ExpressionEditorDefinitions (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions)18 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)13 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)10 HasName (org.kie.workbench.common.dmn.api.definition.HasName)7 InformationItem (org.kie.workbench.common.dmn.api.definition.model.InformationItem)7 Element (org.kie.workbench.common.stunner.core.graph.Element)7 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)7 Test (org.junit.Test)6 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)6 UpdateElementPropertyCommand (org.kie.workbench.common.stunner.core.client.canvas.command.UpdateElementPropertyCommand)6 List (org.kie.workbench.common.dmn.api.definition.model.List)5 ExpressionCellValue (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)5 GridData (org.uberfire.ext.wires.core.grids.client.model.GridData)5 BaseBounds (org.uberfire.ext.wires.core.grids.client.model.impl.BaseBounds)5