Search in sources :

Example 1 with BaseMenuCustom

use of org.uberfire.workbench.model.menu.impl.BaseMenuCustom in project kie-wb-common by kiegroup.

the class MenuUtilsTest method testBuildItemWithHasEnabledIsWidget.

@Test
public void testBuildItemWithHasEnabledIsWidget() {
    BaseMenuCustom menuItem = (BaseMenuCustom) MenuUtils.buildItem(hasEnabledIsWidget);
    assertEquals(widget, menuItem.build());
    menuItem.setEnabled(true);
    verify(hasEnabledIsWidget, times(1)).setEnabled(true);
    menuItem.setEnabled(false);
    verify(hasEnabledIsWidget, times(1)).setEnabled(false);
    when(hasEnabledIsWidget.isEnabled()).thenReturn(true);
    assertTrue(menuItem.isEnabled());
}
Also used : BaseMenuCustom(org.uberfire.workbench.model.menu.impl.BaseMenuCustom) Test(org.junit.Test)

Example 2 with BaseMenuCustom

use of org.uberfire.workbench.model.menu.impl.BaseMenuCustom in project kie-wb-common by kiegroup.

the class MenuUtilsTest method testBuildItemWithNormalIsWidget.

@Test
public void testBuildItemWithNormalIsWidget() {
    BaseMenuCustom menuItem = (BaseMenuCustom) MenuUtils.buildItem(isWidget);
    assertEquals(widget, menuItem.build());
    menuItem.setEnabled(true);
    assertTrue(menuItem.isEnabled());
    menuItem.setEnabled(false);
    assertFalse(menuItem.isEnabled());
}
Also used : BaseMenuCustom(org.uberfire.workbench.model.menu.impl.BaseMenuCustom) Test(org.junit.Test)

Example 3 with BaseMenuCustom

use of org.uberfire.workbench.model.menu.impl.BaseMenuCustom in project kie-wb-common by kiegroup.

the class DiagramEditorMenuSessionItemsTest method testIsEnabledWithRegisteredMenuItem.

@Test
public void testIsEnabledWithRegisteredMenuItem() {
    final MenuItem menuItem = new BaseMenuCustom<String>() {

        @Override
        public String build() {
            return "";
        }
    };
    when(itemsBuilder.newClearItem(Mockito.<Command>any())).thenReturn(menuItem);
    editorMenuSessionItems.populateMenu(fileMenuBuilder);
    editorMenuSessionItems.setItemEnabled(ClearSessionCommand.class, true);
    assertTrue(menuItem.isEnabled());
    editorMenuSessionItems.setItemEnabled(ClearSessionCommand.class, false);
    assertFalse(menuItem.isEnabled());
}
Also used : BaseMenuCustom(org.uberfire.workbench.model.menu.impl.BaseMenuCustom) MenuItem(org.uberfire.workbench.model.menu.MenuItem) Test(org.junit.Test)

Example 4 with BaseMenuCustom

use of org.uberfire.workbench.model.menu.impl.BaseMenuCustom in project kie-wb-common by kiegroup.

the class ExplorerMenuViewImpl method asMenu.

@Override
public Menus asMenu() {
    return MenuFactory.newTopLevelCustomMenu(new MenuFactory.CustomMenuBuilder() {

        @Override
        public void push(MenuFactory.CustomMenuBuilder element) {
        }

        @Override
        public MenuItem build() {
            return new BaseMenuCustom() {

                @Override
                public Widget build() {
                    return new ButtonGroup() {

                        {
                            add(new Button() {

                                {
                                    setToggleCaret(false);
                                    setDataToggle(Toggle.DROPDOWN);
                                    setIcon(IconType.COG);
                                    setSize(ButtonSize.SMALL);
                                    setTitle(ProjectExplorerConstants.INSTANCE.customizeView());
                                }
                            });
                            add(new DropDownMenu() {

                                {
                                    addStyleName("pull-right");
                                    add(businessView);
                                    add(techView);
                                    add(new Divider());
                                    add(breadcrumbExplorer);
                                    add(treeExplorer);
                                    add(new Divider());
                                    add(showTagFilter);
                                    add(new Divider());
                                    add(archiveProject);
                                }
                            });
                        }
                    };
                }
            };
        }
    }).endMenu().newTopLevelCustomMenu(new MenuFactory.CustomMenuBuilder() {

        @Override
        public void push(MenuFactory.CustomMenuBuilder element) {
        }

        @Override
        public MenuItem build() {
            return new BaseMenuCustom() {

                @Override
                public Widget build() {
                    return new Button() {

                        {
                            setIcon(IconType.REFRESH);
                            setSize(ButtonSize.SMALL);
                            setTitle(ProjectExplorerConstants.INSTANCE.refresh());
                            addClickHandler(new ClickHandler() {

                                @Override
                                public void onClick(ClickEvent event) {
                                    presenter.onRefresh();
                                }
                            });
                        }
                    };
                }
            };
        }
    }).endMenu().build();
}
Also used : MenuFactory(org.uberfire.workbench.model.menu.MenuFactory) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ButtonGroup(org.gwtbootstrap3.client.ui.ButtonGroup) Button(org.gwtbootstrap3.client.ui.Button) BaseMenuCustom(org.uberfire.workbench.model.menu.impl.BaseMenuCustom) DropDownMenu(org.gwtbootstrap3.client.ui.DropDownMenu) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Widget(com.google.gwt.user.client.ui.Widget) MenuItem(org.uberfire.workbench.model.menu.MenuItem) Divider(org.gwtbootstrap3.client.ui.Divider)

Example 5 with BaseMenuCustom

use of org.uberfire.workbench.model.menu.impl.BaseMenuCustom in project kie-wb-common by kiegroup.

the class MenuUtilsTest method testBuildItemWithButtonGroup.

@Test
public void testBuildItemWithButtonGroup() {
    final MenuUtils.HasEnabledIsWidget wrappedButtonGroup = MenuUtils.buildHasEnabledWidget(buttonGroup, button);
    final BaseMenuCustom menuItem = (BaseMenuCustom) MenuUtils.buildItem(wrappedButtonGroup);
    assertEquals(buttonGroup, menuItem.build());
    menuItem.setEnabled(true);
    verify(button, times(1)).setEnabled(true);
    menuItem.setEnabled(false);
    verify(button, times(1)).setEnabled(false);
    when(button.isEnabled()).thenReturn(true);
    assertTrue(menuItem.isEnabled());
}
Also used : BaseMenuCustom(org.uberfire.workbench.model.menu.impl.BaseMenuCustom) Test(org.junit.Test)

Aggregations

BaseMenuCustom (org.uberfire.workbench.model.menu.impl.BaseMenuCustom)6 Test (org.junit.Test)5 MenuItem (org.uberfire.workbench.model.menu.MenuItem)3 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 Widget (com.google.gwt.user.client.ui.Widget)1 Button (org.gwtbootstrap3.client.ui.Button)1 ButtonGroup (org.gwtbootstrap3.client.ui.ButtonGroup)1 Divider (org.gwtbootstrap3.client.ui.Divider)1 DropDownMenu (org.gwtbootstrap3.client.ui.DropDownMenu)1 MenuFactory (org.uberfire.workbench.model.menu.MenuFactory)1