@Test public void testInitialize() { when(definitionPaletteItemWidgetInstance.get()).thenReturn(itemWidget); when(definitionPaletteGroupWidgetInstance.get()).thenReturn(groupWidget); DefaultPaletteCategory category = mockPaletteCategory(); widget.initialize(category, shapeFactory, itemMouseDownCallback); verify(view, times(1)).render(categoryGlyph, ICON_SIZE, ICON_SIZE); verify(definitionPaletteItemWidgetInstance, times(SIMPLE_ITEMS_COUNT)).get(); category.getItems() .stream() .filter(item -> !(item instanceof PaletteGroup)) .forEach(simpleItem -> verify(itemWidget, times(1)).initialize(simpleItem, shapeFactory, itemMouseDownCallback)); verify(definitionPaletteGroupWidgetInstance, times(GROUPS_COUNT)).get(); category.getItems() .stream() .filter(item -> (item instanceof PaletteGroup)) .map(item -> (DefaultPaletteGroup) item) .forEach(groupItem -> verify(groupWidget, times(1)).initialize(groupItem, shapeFactory, itemMouseDownCallback)); }
@Override public void initialize(final DefaultPaletteCategory category, final ShapeFactory<?, ?> shapeFactory, final Consumer<PaletteItemMouseEvent> itemMouseDownCallback) { this.category = category; this.itemMouseDownCallback = itemMouseDownCallback; final Glyph categoryGlyph = category.getGlyph(); view.render(categoryGlyph, category.getIconSize(), category.getIconSize()); renderItems(category.getItems(), shapeFactory); }
DefinitionPaletteCategoryWidget implements DefinitionPaletteCategoryWidgetView.Presenter { @Override public void initialize(final DefaultPaletteCategory category, final ShapeFactory<?, ?> shapeFactory, final Consumer<PaletteItemMouseEvent> itemMouseDownCallback) { this.category = category; this.itemMouseDownCallback = itemMouseDownCallback; final Glyph categoryGlyph = category.getGlyph(); view.render(categoryGlyph, category.getIconSize(), category.getIconSize()); renderItems(category.getItems(), shapeFactory); } }
DefinitionPaletteCategoryWidget implements DefinitionPaletteCategoryWidgetView.Presenter { @Override public void initialize(final DefaultPaletteCategory category, final ShapeFactory<?, ?> shapeFactory, final Consumer<PaletteItemMouseEvent> itemMouseDownCallback) { this.category = category; this.itemMouseDownCallback = itemMouseDownCallback; final Glyph categoryGlyph = category.getGlyph(); view.render(categoryGlyph, category.getIconSize(), category.getIconSize()); renderItems(category.getItems(), shapeFactory); } @Inject  DefinitionPaletteCategoryWidget(DefinitionPaletteCategoryWidgetView view,
                                           ManagedInstance<DefinitionPaletteItemWidget> definitionPaletteItemWidgetInstance,
                                           ManagedInstance<DefinitionPaletteGroupWidget> definitionPaletteGroupWidgetInstance); }
DefinitionPaletteCategoryWidget implements DefinitionPaletteCategoryWidgetView.Presenter { @Override public void initialize(final DefaultPaletteCategory category, final ShapeFactory<?, ?> shapeFactory, final Consumer<PaletteItemMouseEvent> itemMouseDownCallback) { this.category = category; this.itemMouseDownCallback = itemMouseDownCallback; final Glyph categoryGlyph = category.getGlyph(); view.render(categoryGlyph, category.getIconSize(), category.getIconSize()); renderItems(category.getItems(), shapeFactory); } @Inject  DefinitionPaletteCategoryWidget(DefinitionPaletteCategoryWidgetView view,
                                           ManagedInstance<DefinitionPaletteItemWidget> definitionPaletteItemWidgetInstance,
                                           ManagedInstance<DefinitionPaletteGroupWidget> definitionPaletteGroupWidgetInstance); @PostConstruct void setUp(); @Override HTMLElement getElement(); @Override void initialize(final DefaultPaletteCategory category,
                           final ShapeFactory<?, ?> shapeFactory,
                           final Consumer<PaletteItemMouseEvent> itemMouseDownCallback); void setOnOpenCallback(Consumer<DefaultPaletteCategory> onOpenCallback); void setOnCloseCallback(Consumer<DefaultPaletteCategory> onCloseCallback); void setVisible(final boolean visible); boolean isVisible(); void setAutoHidePanel(boolean autoHidePanel); DefinitionPaletteCategoryWidgetView getView(); @Override DefaultPaletteCategory getCategory(); @Override void onMouseDown(int clientX,
                            int clientY,
                            int x,
                            int y); @Override void onOpen(); @Override void onClose(); @PreDestroy void destroy(); }
DefinitionPaletteCategoryWidget implements DefinitionPaletteCategoryWidgetView.Presenter { @Override public void initialize(final DefaultPaletteCategory category, final ShapeFactory<?, ?> shapeFactory, final Consumer<PaletteItemMouseEvent> itemMouseDownCallback) { this.category = category; this.itemMouseDownCallback = itemMouseDownCallback; final Glyph categoryGlyph = category.getGlyph(); view.render(categoryGlyph, category.getIconSize(), category.getIconSize()); renderItems(category.getItems(), shapeFactory); } @Inject  DefinitionPaletteCategoryWidget(DefinitionPaletteCategoryWidgetView view,
                                           ManagedInstance<DefinitionPaletteItemWidget> definitionPaletteItemWidgetInstance,
                                           ManagedInstance<DefinitionPaletteGroupWidget> definitionPaletteGroupWidgetInstance); @PostConstruct void setUp(); @Override HTMLElement getElement(); @Override void initialize(final DefaultPaletteCategory category,
                           final ShapeFactory<?, ?> shapeFactory,
                           final Consumer<PaletteItemMouseEvent> itemMouseDownCallback); void setOnOpenCallback(Consumer<DefaultPaletteCategory> onOpenCallback); void setOnCloseCallback(Consumer<DefaultPaletteCategory> onCloseCallback); void setVisible(final boolean visible); boolean isVisible(); void setAutoHidePanel(boolean autoHidePanel); DefinitionPaletteCategoryWidgetView getView(); @Override DefaultPaletteCategory getCategory(); @Override void onMouseDown(int clientX,
                            int clientY,
                            int x,
                            int y); @Override void onOpen(); @Override void onClose(); @PreDestroy void destroy();  }