Search in sources :

Example 1 with MenuItem

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

the class MenuDevCommandsBuilder method buildDevMenuItem.

private MenuItem buildDevMenuItem() {
    final DropDownMenu menu = new DropDownMenu() {

        {
            addStyleName("pull-right");
        }
    };
    for (final MenuDevCommand command : devCommands) {
        menu.add(new AnchorListItem(command.getText()) {

            {
                setIcon(command.getIcon());
                addClickHandler(event -> command.execute());
            }
        });
    }
    final IsWidget group = new ButtonGroup() {

        {
            add(new Button() {

                {
                    setToggleCaret(false);
                    setDataToggle(Toggle.DROPDOWN);
                    setIcon(IconType.COG);
                    setSize(ButtonSize.SMALL);
                    setTitle("Development");
                }
            });
            add(menu);
        }
    };
    return MenuUtils.buildItem(group);
}
Also used : AnchorListItem(org.gwtbootstrap3.client.ui.AnchorListItem) IconType(org.gwtbootstrap3.client.ui.constants.IconType) DropDownMenu(org.gwtbootstrap3.client.ui.DropDownMenu) ManagedInstance(org.jboss.errai.ioc.client.api.ManagedInstance) Button(org.gwtbootstrap3.client.ui.Button) Inject(javax.inject.Inject) List(java.util.List) Toggle(org.gwtbootstrap3.client.ui.constants.Toggle) MenuUtils(org.kie.workbench.common.stunner.client.widgets.menu.MenuUtils) MenuItem(org.uberfire.workbench.model.menu.MenuItem) ApplicationScoped(javax.enterprise.context.ApplicationScoped) IsWidget(com.google.gwt.user.client.ui.IsWidget) LinkedList(java.util.LinkedList) ButtonSize(org.gwtbootstrap3.client.ui.constants.ButtonSize) ButtonGroup(org.gwtbootstrap3.client.ui.ButtonGroup) IsWidget(com.google.gwt.user.client.ui.IsWidget) AnchorListItem(org.gwtbootstrap3.client.ui.AnchorListItem) ButtonGroup(org.gwtbootstrap3.client.ui.ButtonGroup) Button(org.gwtbootstrap3.client.ui.Button) DropDownMenu(org.gwtbootstrap3.client.ui.DropDownMenu)

Example 2 with MenuItem

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

the class DMNEditorMenuSessionItems method addPerformAutomaticLayout.

void addPerformAutomaticLayout(final FileMenuBuilder menu) {
    final MenuItem performAutomaticLayoutMenuItem = newPerformAutomaticLayout();
    addMenuItem(DMNPerformAutomaticLayoutCommand.class, performAutomaticLayoutMenuItem);
    menu.addNewTopLevelMenu(performAutomaticLayoutMenuItem);
}
Also used : MenuItem(org.uberfire.workbench.model.menu.MenuItem)

Example 3 with MenuItem

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

the class DMNEditorMenuSessionItemsValidateTest method setUp.

@Before
public void setUp() {
    menuItems = new DMNEditorMenuSessionItems(builder, sessionCommands, placeManager) {

        @Override
        MenuItem newPerformAutomaticLayout() {
            return mock(MenuItem.class);
        }
    };
    final FileMenuBuilder fileMenuBuilder = mock(FileMenuBuilder.class);
    doReturn(fileMenuBuilder).when(fileMenuBuilder).addNewTopLevelMenu(any());
    menuItems.populateMenu(fileMenuBuilder);
    verify(builder).newValidateItem(validateItemArgumentCaptor.capture());
    doReturn(validateSessionCommand).when(sessionCommands).getValidateSessionCommand();
    validateItemArgumentCaptor.getValue().execute();
    verify(validateSessionCommand).execute(violationsArgumentCapture.capture());
}
Also used : FileMenuBuilder(org.kie.workbench.common.widgets.client.menu.FileMenuBuilder) MenuItem(org.uberfire.workbench.model.menu.MenuItem) Before(org.junit.Before)

Example 4 with MenuItem

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

the class DMNDiagramEditorTest method testOnDataTypeEditModeToggleWhenEditModeIsNotEnabled.

@Test
@SuppressWarnings("unchecked")
public void testOnDataTypeEditModeToggleWhenEditModeIsNotEnabled() {
    final DataTypeEditModeToggleEvent event = mock(DataTypeEditModeToggleEvent.class);
    final MenuItem menuItem = mock(MenuItem.class);
    final Menus menus = mock(Menus.class);
    final List<MenuItem> items = singletonList(menuItem);
    when(menus.getItems()).thenReturn(items);
    when(event.isEditModeEnabled()).thenReturn(false);
    doAnswer(invocationOnMock -> {
        invocationOnMock.getArgument(0, Consumer.class).accept(menus);
        return null;
    }).when(editor).getMenu(any());
    editor.onDataTypeEditModeToggle(event);
    verify(menuItem).setEnabled(true);
}
Also used : Consumer(java.util.function.Consumer) Menus(org.uberfire.workbench.model.menu.Menus) MenuItem(org.uberfire.workbench.model.menu.MenuItem) DataTypeEditModeToggleEvent(org.kie.workbench.common.dmn.client.editors.types.listview.common.DataTypeEditModeToggleEvent) Test(org.junit.Test)

Example 5 with MenuItem

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

the class DMNDiagramEditorTest method testOnDataTypeEditModeToggleWhenEditModeIsEnabled.

@Test
@SuppressWarnings("unchecked")
public void testOnDataTypeEditModeToggleWhenEditModeIsEnabled() {
    final DataTypeEditModeToggleEvent event = mock(DataTypeEditModeToggleEvent.class);
    final MenuItem menuItem = mock(MenuItem.class);
    final Menus menus = mock(Menus.class);
    final List<MenuItem> items = singletonList(menuItem);
    when(menus.getItems()).thenReturn(items);
    when(event.isEditModeEnabled()).thenReturn(true);
    doAnswer(invocationOnMock -> {
        invocationOnMock.getArgument(0, Consumer.class).accept(menus);
        return null;
    }).when(editor).getMenu(any());
    editor.onDataTypeEditModeToggle(event);
    verify(menuItem).setEnabled(false);
}
Also used : Consumer(java.util.function.Consumer) Menus(org.uberfire.workbench.model.menu.Menus) MenuItem(org.uberfire.workbench.model.menu.MenuItem) DataTypeEditModeToggleEvent(org.kie.workbench.common.dmn.client.editors.types.listview.common.DataTypeEditModeToggleEvent) Test(org.junit.Test)

Aggregations

MenuItem (org.uberfire.workbench.model.menu.MenuItem)34 Test (org.junit.Test)18 Button (org.gwtbootstrap3.client.ui.Button)6 IsWidget (com.google.gwt.user.client.ui.IsWidget)5 ButtonGroup (org.gwtbootstrap3.client.ui.ButtonGroup)5 DropDownMenu (org.gwtbootstrap3.client.ui.DropDownMenu)5 Command (org.uberfire.mvp.Command)5 AnchorListItem (org.gwtbootstrap3.client.ui.AnchorListItem)4 ButtonSize (org.gwtbootstrap3.client.ui.constants.ButtonSize)4 IconType (org.gwtbootstrap3.client.ui.constants.IconType)4 Toggle (org.gwtbootstrap3.client.ui.constants.Toggle)4 MenuUtils (org.kie.workbench.common.stunner.client.widgets.menu.MenuUtils)4 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)3 ApplicationScoped (javax.enterprise.context.ApplicationScoped)3 Inject (javax.inject.Inject)3 IconPosition (org.gwtbootstrap3.client.ui.constants.IconPosition)3 Pull (org.gwtbootstrap3.client.ui.constants.Pull)3 PlaceRequest (org.uberfire.mvp.PlaceRequest)3 Menus (org.uberfire.workbench.model.menu.Menus)3 BaseMenuCustom (org.uberfire.workbench.model.menu.impl.BaseMenuCustom)3