Search in sources :

Example 1 with AbstractDecoratorItem

use of org.kie.workbench.common.stunner.lienzo.toolbox.items.AbstractDecoratorItem in project kie-wb-common by kiegroup.

the class ButtonGridItemImpl method decorateGrid.

@Override
public ButtonGridItemImpl decorateGrid(final DecoratorItem<?> decorator) {
    removeDecoratorHandlers();
    toolbox.decorate(decorator);
    if (decorator instanceof AbstractDecoratorItem) {
        final AbstractDecoratorItem instance = (AbstractDecoratorItem) decorator;
        decoratorHandlers[0] = instance.asPrimitive().setListening(true).addNodeMouseEnterHandler(event -> itemFocusCallback.execute());
        decoratorHandlers[1] = instance.asPrimitive().addNodeMouseExitHandler(event -> itemUnFocusCallback.execute());
        registrations().register(decoratorHandlers[0]);
        registrations().register(decoratorHandlers[1]);
    }
    return this;
}
Also used : NodeMouseClickHandler(com.ait.lienzo.client.core.event.NodeMouseClickHandler) MultiPath(com.ait.lienzo.client.core.shape.MultiPath) Iterator(java.util.Iterator) NodeDragMoveHandler(com.ait.lienzo.client.core.event.NodeDragMoveHandler) DecoratorItem(org.kie.workbench.common.stunner.lienzo.toolbox.items.DecoratorItem) Point2DGrid(org.kie.workbench.common.stunner.lienzo.toolbox.grid.Point2DGrid) AbstractDecoratorItem(org.kie.workbench.common.stunner.lienzo.toolbox.items.AbstractDecoratorItem) Shape(com.ait.lienzo.client.core.shape.Shape) Group(com.ait.lienzo.client.core.shape.Group) AbstractPrimitiveItem(org.kie.workbench.common.stunner.lienzo.toolbox.items.AbstractPrimitiveItem) Supplier(java.util.function.Supplier) AbstractDecoratedItem(org.kie.workbench.common.stunner.lienzo.toolbox.items.AbstractDecoratedItem) HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) DecoratedItem(org.kie.workbench.common.stunner.lienzo.toolbox.items.DecoratedItem) Point2D(com.ait.lienzo.client.core.types.Point2D) HandlerRegistrationManager(com.ait.tooling.nativetools.client.event.HandlerRegistrationManager) NodeDragEndHandler(com.ait.lienzo.client.core.event.NodeDragEndHandler) BiConsumer(java.util.function.BiConsumer) Direction(com.ait.lienzo.shared.core.types.Direction) NodeDragStartHandler(com.ait.lienzo.client.core.event.NodeDragStartHandler) BoundingBox(com.ait.lienzo.client.core.types.BoundingBox) Timer(com.google.gwt.user.client.Timer) ButtonGridItem(org.kie.workbench.common.stunner.lienzo.toolbox.items.ButtonGridItem) Command(org.uberfire.mvp.Command) AbstractDecoratorItem(org.kie.workbench.common.stunner.lienzo.toolbox.items.AbstractDecoratorItem)

Example 2 with AbstractDecoratorItem

use of org.kie.workbench.common.stunner.lienzo.toolbox.items.AbstractDecoratorItem 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 3 with AbstractDecoratorItem

use of org.kie.workbench.common.stunner.lienzo.toolbox.items.AbstractDecoratorItem in project kie-wb-common by kiegroup.

the class ItemImplTest method testFocusExecutorDoingFocus.

@Test
public void testFocusExecutorDoingFocus() {
    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.focus();
    verify(focusExecutor, times(1)).setAlpha(AbstractFocusableGroupItem.ALPHA_FOCUSED);
    verify(decorator, times(1)).show();
    verify(decPrimitive, times(1)).moveToBottom();
    verify(tooltip, times(1)).show();
}
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)

Aggregations

Group (com.ait.lienzo.client.core.shape.Group)3 AbstractDecoratorItem (org.kie.workbench.common.stunner.lienzo.toolbox.items.AbstractDecoratorItem)3 Command (org.uberfire.mvp.Command)3 Test (org.junit.Test)2 NodeDragEndHandler (com.ait.lienzo.client.core.event.NodeDragEndHandler)1 NodeDragMoveHandler (com.ait.lienzo.client.core.event.NodeDragMoveHandler)1 NodeDragStartHandler (com.ait.lienzo.client.core.event.NodeDragStartHandler)1 NodeMouseClickHandler (com.ait.lienzo.client.core.event.NodeMouseClickHandler)1 MultiPath (com.ait.lienzo.client.core.shape.MultiPath)1 Shape (com.ait.lienzo.client.core.shape.Shape)1 BoundingBox (com.ait.lienzo.client.core.types.BoundingBox)1 Point2D (com.ait.lienzo.client.core.types.Point2D)1 Direction (com.ait.lienzo.shared.core.types.Direction)1 HandlerRegistrationManager (com.ait.tooling.nativetools.client.event.HandlerRegistrationManager)1 HandlerRegistration (com.google.gwt.event.shared.HandlerRegistration)1 Timer (com.google.gwt.user.client.Timer)1 Iterator (java.util.Iterator)1 BiConsumer (java.util.function.BiConsumer)1 Supplier (java.util.function.Supplier)1 Point2DGrid (org.kie.workbench.common.stunner.lienzo.toolbox.grid.Point2DGrid)1