Search in sources :

Example 1 with Group

use of com.ait.lienzo.client.core.shape.Group in project kie-wb-common by kiegroup.

the class GroupItemTest method testHide.

@Test
public void testHide() {
    when(group.getAlpha()).thenReturn(1d);
    final Command before = mock(Command.class);
    final Command after = mock(Command.class);
    tested.hide(before, after);
    verify(before, times(1)).execute();
    verify(hideExecutor, times(1)).accept(eq(group), eq(after));
    verify(showExecutor, never()).accept(any(Group.class), any(Command.class));
}
Also used : Group(com.ait.lienzo.client.core.shape.Group) Command(org.uberfire.mvp.Command) Test(org.junit.Test)

Example 2 with Group

use of com.ait.lienzo.client.core.shape.Group in project kie-wb-common by kiegroup.

the class ButtonGridItemImplTest method setUp.

@Before
@SuppressWarnings("unchecked")
public void setUp() {
    buttonGroup = spy(new Group().setAlpha(0d));
    toolboxGroup = spy(new Group());
    when(buttonGroup.getComputedBoundingPoints()).thenReturn(buttonBoundingPoints);
    when(buttonGroup.getBoundingBox()).thenReturn(buttonBoundingBox);
    when(buttonBoundingPoints.getBoundingBox()).thenReturn(buttonBoundingBox);
    when(toolboxGroup.getComputedBoundingPoints()).thenReturn(toolboxBoundingPoints);
    when(toolboxGroup.getBoundingBox()).thenReturn(toolboxBoundingBox);
    when(toolboxBoundingPoints.getBoundingBox()).thenReturn(toolboxBoundingBox);
    when(button.getBoundingBox()).thenReturn(() -> buttonBoundingBox);
    when(button.asPrimitive()).thenReturn(buttonGroup);
    when(button.getPrimitive()).thenReturn(mock(IPrimitive.class));
    when(button.getWrapped()).thenReturn(buttonWrap);
    when(buttonWrap.registrations()).thenReturn(registrations);
    when(buttonWrap.asPrimitive()).thenReturn(buttonGroup);
    when(buttonWrap.getBoundingBox()).thenReturn(() -> buttonBoundingBox);
    when(toolbox.getBoundingBox()).thenReturn(() -> toolboxBoundingBox);
    when(toolbox.asPrimitive()).thenReturn(toolboxGroup);
    when(toolbox.getPrimitive()).thenReturn(mock(IPrimitive.class));
    when(toolbox.getAt()).thenReturn(Direction.SOUTH_EAST);
    when(toolbox.getWrapped()).thenReturn(toolboxWrap);
    when(toolboxWrap.asPrimitive()).thenReturn(toolboxGroup);
    when(toolboxWrap.getBoundingBox()).thenReturn(() -> toolboxBoundingBox);
    when(button1.getPrimitive()).thenReturn(button1Prim);
    doAnswer(invocationOnMock -> {
        ((Command) invocationOnMock.getArguments()[0]).execute();
        ((Command) invocationOnMock.getArguments()[1]).execute();
        return button;
    }).when(button).show(any(Command.class), any(Command.class));
    doAnswer(invocationOnMock -> {
        ((Command) invocationOnMock.getArguments()[0]).execute();
        ((Command) invocationOnMock.getArguments()[1]).execute();
        return button;
    }).when(button).hide(any(Command.class), any(Command.class));
    doAnswer(invocationOnMock -> {
        ((Command) invocationOnMock.getArguments()[0]).execute();
        ((Command) invocationOnMock.getArguments()[1]).execute();
        return toolbox;
    }).when(toolbox).show(any(Command.class), any(Command.class));
    doAnswer(invocationOnMock -> {
        ((Command) invocationOnMock.getArguments()[0]).execute();
        ((Command) invocationOnMock.getArguments()[1]).execute();
        return toolbox;
    }).when(toolbox).hide(any(Command.class), any(Command.class));
    tested = new ButtonGridItemImpl(button, toolbox).useHideExecutor(hideExecutor).useShowExecutor(showExecutor);
}
Also used : Group(com.ait.lienzo.client.core.shape.Group) Command(org.uberfire.mvp.Command) IPrimitive(com.ait.lienzo.client.core.shape.IPrimitive) Before(org.junit.Before)

Example 3 with Group

use of com.ait.lienzo.client.core.shape.Group in project kie-wb-common by kiegroup.

the class ItemImplTest method testFocusExecutorDoingUnFocus.

@Test
public void testFocusExecutorDoingUnFocus() {
    final AbstractDecoratorItem decorator = mock(AbstractDecoratorItem.class);
    final Group decPrimitive = mock(Group.class);
    when(decorator.asPrimitive()).thenReturn(decPrimitive);
    final TooltipItem<?> tooltip = mock(TooltipItem.class);
    tested = new ItemImpl(groupItem, shape).setFocusDelay(0).setUnFocusDelay(0).decorate(decorator).tooltip(tooltip);
    final AbstractFocusableGroupItem<ItemImpl>.FocusGroupExecutor focusExecutor = spy(tested.getFocusGroupExecutor());
    doAnswer(invocationOnMock -> {
        ((Command) invocationOnMock.getArguments()[1]).execute();
        return null;
    }).when(focusExecutor).accept(any(Group.class), any(Command.class));
    focusExecutor.unFocus();
    verify(focusExecutor, times(1)).setAlpha(AbstractFocusableGroupItem.ALPHA_UNFOCUSED);
    verify(decorator, times(3)).hide();
    verify(tooltip, times(2)).hide();
}
Also used : Group(com.ait.lienzo.client.core.shape.Group) Command(org.uberfire.mvp.Command) AbstractDecoratorItem(org.kie.workbench.common.stunner.lienzo.toolbox.items.AbstractDecoratorItem) Test(org.junit.Test)

Example 4 with Group

use of com.ait.lienzo.client.core.shape.Group in project kie-wb-common by kiegroup.

the class LienzoSvgDataUriGlyphRendererTest method testRender.

@Test
@SuppressWarnings("unchecked")
public void testRender() {
    final Group glyphView = tested.render(glyph, 100, 200);
    assertEquals(group, glyphView);
    final ArgumentCaptor<String> imageGlyphCaptor = ArgumentCaptor.forClass(String.class);
    verify(lienzoPictureGlyphRenderer, times(1)).render(imageGlyphCaptor.capture(), eq(100d), eq(200d));
    assertEquals(URI_B64, imageGlyphCaptor.getValue());
}
Also used : Group(com.ait.lienzo.client.core.shape.Group) Mockito.anyString(org.mockito.Mockito.anyString) Test(org.junit.Test)

Example 5 with Group

use of com.ait.lienzo.client.core.shape.Group in project kie-wb-common by kiegroup.

the class BaseExpressionGrid method executeRenderQueueCommands.

@Override
protected void executeRenderQueueCommands(final boolean isSelectionLayer) {
    final List<Pair<Group, GridRenderer.RendererCommand>> gridLineCommands = new ArrayList<>();
    final List<Pair<Group, GridRenderer.RendererCommand>> allOtherCommands = new ArrayList<>();
    final List<Pair<Group, GridRenderer.RendererCommand>> selectedCellsCommands = new ArrayList<>();
    for (Pair<Group, List<GridRenderer.RendererCommand>> p : renderQueue) {
        final Group parent = p.getK1();
        final List<GridRenderer.RendererCommand> commands = p.getK2();
        for (GridRenderer.RendererCommand command : commands) {
            if (command instanceof GridRenderer.RenderSelectedCellsCommand) {
                selectedCellsCommands.add(new Pair<>(parent, command));
            } else if (command instanceof GridRenderer.RenderHeaderGridLinesCommand) {
                gridLineCommands.add(new Pair<>(parent, command));
            } else if (command instanceof GridRenderer.RenderBodyGridLinesCommand) {
                gridLineCommands.add(new Pair<>(parent, command));
            } else {
                allOtherCommands.add(new Pair<>(parent, command));
            }
        }
    }
    final Predicate<Pair<Group, GridRenderer.RendererCommand>> renderHeader = (p) -> {
        final GridRenderer.RendererCommand command = p.getK2();
        if (isHeaderHidden()) {
            return !(command instanceof GridRenderer.RendererHeaderCommand);
        }
        return true;
    };
    renderQueue.clear();
    allOtherCommands.stream().filter(renderHeader).forEach(p -> addCommandToRenderQueue(p.getK1(), p.getK2()));
    gridLineCommands.stream().filter(renderHeader).forEach(p -> addCommandToRenderQueue(p.getK1(), p.getK2()));
    selectedCellsCommands.stream().filter(renderHeader).forEach(p -> addCommandToRenderQueue(p.getK1(), p.getK2()));
    super.executeRenderQueueCommands(isSelectionLayer);
}
Also used : TextAreaSingletonDOMElementFactory(org.kie.workbench.common.dmn.client.widgets.grid.columns.factory.TextAreaSingletonDOMElementFactory) 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) DMNGridLayer(org.kie.workbench.common.dmn.client.widgets.layer.DMNGridLayer) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) Group(com.ait.lienzo.client.core.shape.Group) GridSelectionManager(org.uberfire.ext.wires.core.grids.client.widget.layer.GridSelectionManager) BaseGridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.impl.BaseGridWidget) GridLayerRedrawManager(org.uberfire.ext.wires.core.grids.client.widget.layer.impl.GridLayerRedrawManager) SetHeaderValueCommand(org.kie.workbench.common.dmn.client.commands.general.SetHeaderValueCommand) Layer(com.ait.lienzo.client.core.shape.Layer) SetCellValueCommand(org.kie.workbench.common.dmn.client.commands.general.SetCellValueCommand) DeleteHeaderValueCommand(org.kie.workbench.common.dmn.client.commands.general.DeleteHeaderValueCommand) CanvasCommandFactory(org.kie.workbench.common.stunner.core.client.command.CanvasCommandFactory) Predicate(java.util.function.Predicate) GridDataCache(org.kie.workbench.common.dmn.client.widgets.grid.model.GridDataCache) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) AbstractCanvasGraphCommand(org.kie.workbench.common.stunner.core.client.canvas.command.AbstractCanvasGraphCommand) DeleteCellValueCommand(org.kie.workbench.common.dmn.client.commands.general.DeleteCellValueCommand) GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) HasName(org.kie.workbench.common.dmn.api.definition.HasName) List(java.util.List) TextBoxSingletonDOMElementFactory(org.kie.workbench.common.dmn.client.widgets.grid.columns.factory.TextBoxSingletonDOMElementFactory) Optional(java.util.Optional) EditableHeaderGridWidgetMouseDoubleClickHandler(org.kie.workbench.common.dmn.client.widgets.grid.columns.EditableHeaderGridWidgetMouseDoubleClickHandler) Viewport(com.ait.lienzo.client.core.shape.Viewport) GridRenderer(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.GridRenderer) Function(java.util.function.Function) ArrayList(java.util.ArrayList) RowNumberColumn(org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) Element(org.kie.workbench.common.stunner.core.graph.Element) Command(org.kie.workbench.common.stunner.core.command.Command) Expression(org.kie.workbench.common.dmn.api.definition.v1_1.Expression) SessionManager(org.kie.workbench.common.stunner.core.client.api.SessionManager) Pair(org.uberfire.commons.data.Pair) BaseUIModelMapper(org.kie.workbench.common.dmn.client.widgets.grid.model.BaseUIModelMapper) 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) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) EditableHeaderMetaData(org.kie.workbench.common.dmn.client.widgets.grid.columns.EditableHeaderMetaData) SessionCommandManager(org.kie.workbench.common.stunner.core.client.command.SessionCommandManager) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) GridPinnedModeManager(org.uberfire.ext.wires.core.grids.client.widget.layer.pinning.GridPinnedModeManager) NodeMouseDoubleClickHandler(com.ait.lienzo.client.core.event.NodeMouseDoubleClickHandler) INodeXYEvent(com.ait.lienzo.client.core.event.INodeXYEvent) GridCellValueTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellValueTuple) CompositeCommand(org.kie.workbench.common.stunner.core.command.impl.CompositeCommand) Group(com.ait.lienzo.client.core.shape.Group) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) GridRenderer(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.GridRenderer) Pair(org.uberfire.commons.data.Pair)

Aggregations

Group (com.ait.lienzo.client.core.shape.Group)66 Test (org.junit.Test)17 Rectangle (com.ait.lienzo.client.core.shape.Rectangle)10 Before (org.junit.Before)10 Text (com.ait.lienzo.client.core.shape.Text)9 GridRenderer (org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.GridRenderer)8 Layer (com.ait.lienzo.client.core.shape.Layer)7 Point2D (com.ait.lienzo.client.core.types.Point2D)7 Command (org.uberfire.mvp.Command)6 BoundingBox (com.ait.lienzo.client.core.types.BoundingBox)4 GridColumn (org.uberfire.ext.wires.core.grids.client.model.GridColumn)4 Line (com.ait.lienzo.client.core.shape.Line)3 ArrayList (java.util.ArrayList)3 SVGContainer (org.kie.workbench.common.stunner.svg.client.shape.view.SVGContainer)3 GridWidget (org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget)3 GridRendererTheme (org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.themes.GridRendererTheme)3 IPathClipper (com.ait.lienzo.client.core.shape.IPathClipper)2 MultiPath (com.ait.lienzo.client.core.shape.MultiPath)2 WiresShape (com.ait.lienzo.client.core.shape.wires.WiresShape)2 Point2DArray (com.ait.lienzo.client.core.types.Point2DArray)2