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;
}
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();
}
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();
}
Aggregations