Search in sources :

Example 31 with MenuItem

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

the class DiagramEditorMenuSessionItemsTest method testIsEnabledWithUnknownMenuItem.

@Test
public void testIsEnabledWithUnknownMenuItem() {
    final MenuItem menuItem = mock(MenuItem.class);
    when(itemsBuilder.newClearItem(Mockito.<Command>any())).thenReturn(menuItem);
    editorMenuSessionItems.populateMenu(fileMenuBuilder);
    try {
        assertFalse(editorMenuSessionItems.isItemEnabled(ClearSessionCommand.class));
    } catch (Exception e) {
        fail(e);
    }
}
Also used : ClearSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.impl.ClearSessionCommand) MenuItem(org.uberfire.workbench.model.menu.MenuItem) Test(org.junit.Test)

Example 32 with MenuItem

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

the class AbstractProcessProjectEditorMenuSessionItems method newFormsGenerationMenuItem.

private MenuItem newFormsGenerationMenuItem(final Command generateProcessForm, final Command generateAllForms, final Command generateSelectedForms) {
    final DropDownMenu menu = new DropDownMenu() {

        {
            setPull(Pull.RIGHT);
        }
    };
    menu.add(createAnchorListItem(getEditorGenerateProcessFormPropertyKey(), event -> generateProcessForm.execute()));
    menu.add(createAnchorListItem(getEditorGenerateAllFormsPropertyKey(), event -> generateAllForms.execute()));
    menu.add(createAnchorListItem(getEditorGenerateSelectionFormsPropertyKey(), event -> generateSelectedForms.execute()));
    final Button button = createButton(getEditorFormGenerationTitlePropertyKey());
    final IsWidget group = MenuUtils.buildHasEnabledWidget(new ButtonGroup() {

        {
            add(button);
            add(menu);
        }
    }, button);
    return MenuUtils.buildItem(group);
}
Also used : AnchorListItem(org.gwtbootstrap3.client.ui.AnchorListItem) IconType(org.gwtbootstrap3.client.ui.constants.IconType) EditorSessionCommands(org.kie.workbench.common.stunner.client.widgets.editor.EditorSessionCommands) Pull(org.gwtbootstrap3.client.ui.constants.Pull) DropDownMenu(org.gwtbootstrap3.client.ui.DropDownMenu) IconPosition(org.gwtbootstrap3.client.ui.constants.IconPosition) AbstractDiagramEditorMenuSessionItems(org.kie.workbench.common.stunner.project.client.editor.AbstractDiagramEditorMenuSessionItems) AbstractDiagramEditorMenuItemsBuilder(org.kie.workbench.common.stunner.project.client.editor.AbstractDiagramEditorMenuItemsBuilder) ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) Button(org.gwtbootstrap3.client.ui.Button) AbstractClientSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.AbstractClientSessionCommand) Toggle(org.gwtbootstrap3.client.ui.constants.Toggle) MenuUtils(org.kie.workbench.common.stunner.client.widgets.menu.MenuUtils) MenuItem(org.uberfire.workbench.model.menu.MenuItem) ClientSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.ClientSessionCommand) FileMenuBuilder(org.kie.workbench.common.widgets.client.menu.FileMenuBuilder) IsWidget(com.google.gwt.user.client.ui.IsWidget) ButtonSize(org.gwtbootstrap3.client.ui.constants.ButtonSize) Command(org.uberfire.mvp.Command) ButtonGroup(org.gwtbootstrap3.client.ui.ButtonGroup) IsWidget(com.google.gwt.user.client.ui.IsWidget) Button(org.gwtbootstrap3.client.ui.Button) ButtonGroup(org.gwtbootstrap3.client.ui.ButtonGroup) DropDownMenu(org.gwtbootstrap3.client.ui.DropDownMenu)

Example 33 with MenuItem

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

the class KieEditorTest method testAddCommonActions.

@Test
public void testAddCommonActions() {
    final Command onValidate = mock(Command.class);
    final MenuItem buildMenu = mock(MenuItem.class);
    final MenuItem build = mock(MenuItem.class);
    doReturn(onValidate).when(presenter).getValidateCommand();
    doReturn(buildMenu).when(versionRecordManager).buildMenu();
    doReturn(build).when(alertsButtonMenuItemBuilder).build();
    presenter.addCommonActions(fileMenuBuilder);
    verify(fileMenuBuilder).addValidate(onValidate);
    verify(fileMenuBuilder).addNewTopLevelMenu(buildMenu);
    verify(fileMenuBuilder).addNewTopLevelMenu(build);
}
Also used : ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Command(org.uberfire.mvp.Command) MenuItem(org.uberfire.workbench.model.menu.MenuItem) Test(org.junit.Test)

Example 34 with MenuItem

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

the class RegisteredDocumentsMenuBuilderTest method testEnable.

@Test
public void testEnable() {
    final MenuItem mi = builder.build();
    mi.setEnabled(true);
    verify(view, times(1)).setEnabled(eq(true));
}
Also used : DocumentMenuItem(org.kie.workbench.common.widgets.metadata.client.menu.RegisteredDocumentsMenuView.DocumentMenuItem) MenuItem(org.uberfire.workbench.model.menu.MenuItem) 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