Search in sources :

Example 11 with MenuItem

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

the class AbstractDiagramEditorMenuSessionItems method populateMenu.

public void populateMenu(final FileMenuBuilder menu) {
    // Create the  menu items.
    final MenuItem clearItem = itemsBuilder.newClearItem(this::menu_clear);
    menuItems.put(ClearSessionCommand.class, clearItem);
    final MenuItem visitGraphItem = itemsBuilder.newVisitGraphItem(this::menu_visitGraph);
    menuItems.put(VisitGraphSessionCommand.class, visitGraphItem);
    final MenuItem switchGridItem = itemsBuilder.newSwitchGridItem(this::menu_switchGrid);
    menuItems.put(SwitchGridSessionCommand.class, switchGridItem);
    final MenuItem deleteSelectionItem = itemsBuilder.newDeleteSelectionItem(this::menu_deleteSelected);
    menuItems.put(DeleteSelectionSessionCommand.class, deleteSelectionItem);
    final MenuItem undoItem = itemsBuilder.newUndoItem(this::menu_undo);
    menuItems.put(UndoSessionCommand.class, undoItem);
    final MenuItem redoItem = itemsBuilder.newRedoItem(this::menu_redo);
    menuItems.put(RedoSessionCommand.class, redoItem);
    final MenuItem validateItem = itemsBuilder.newValidateItem(this::validate);
    menuItems.put(ValidateSessionCommand.class, validateItem);
    final MenuItem exportsItem = itemsBuilder.newExportsItem(this::export_imagePNG, this::export_imageJPG, this::export_imageSVG, this::export_imagePDF, this::export_fileRaw);
    menuItems.put(ExportToPngSessionCommand.class, exportsItem);
    menuItems.put(ExportToJpgSessionCommand.class, exportsItem);
    menuItems.put(ExportToSvgSessionCommand.class, exportsItem);
    menuItems.put(ExportToPdfSessionCommand.class, exportsItem);
    menuItems.put(ExportToRawFormatSessionCommand.class, exportsItem);
    final MenuItem pasteItem = itemsBuilder.newPasteItem(this::paste);
    menuItems.put(PasteSelectionSessionCommand.class, pasteItem);
    final MenuItem copyItem = itemsBuilder.newCopyItem(this::menu_copy);
    menuItems.put(CopySelectionSessionCommand.class, copyItem);
    final MenuItem cutItem = itemsBuilder.newCutItem(this::menu_cut);
    menuItems.put(CutSelectionSessionCommand.class, cutItem);
    // Populate the given editor's menu builder.
    menu.addNewTopLevelMenu(clearItem).addNewTopLevelMenu(visitGraphItem).addNewTopLevelMenu(switchGridItem).addNewTopLevelMenu(deleteSelectionItem).addNewTopLevelMenu(undoItem).addNewTopLevelMenu(redoItem).addNewTopLevelMenu(validateItem).addNewTopLevelMenu(exportsItem).addNewTopLevelMenu(copyItem).addNewTopLevelMenu(cutItem).addNewTopLevelMenu(pasteItem);
}
Also used : MenuItem(org.uberfire.workbench.model.menu.MenuItem)

Example 12 with MenuItem

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

the class ProjectEditorMenuSessionItemsTest method testEnableItemWithRegisteredMenuItem.

@Test
public void testEnableItemWithRegisteredMenuItem() {
    final MenuItem clearMenuItem = mock(MenuItem.class);
    when(itemsBuilder.newClearItem(Mockito.<Command>any())).thenReturn(clearMenuItem);
    editorMenuSessionItems.populateMenu(fileMenuBuilder);
    editorMenuSessionItems.setItemEnabled(ClearSessionCommand.class, true);
    verify(clearMenuItem).setEnabled(true);
    editorMenuSessionItems.setItemEnabled(ClearSessionCommand.class, false);
    verify(clearMenuItem).setEnabled(false);
}
Also used : MenuItem(org.uberfire.workbench.model.menu.MenuItem) Test(org.junit.Test)

Example 13 with MenuItem

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

the class ProjectEditorMenuSessionItemsTest 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 14 with MenuItem

use of org.uberfire.workbench.model.menu.MenuItem 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 15 with MenuItem

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

the class DiagramEditorMenuSessionItemsTest method testEnableItemWithRegisteredMenuItem.

@Test
public void testEnableItemWithRegisteredMenuItem() {
    final MenuItem clearMenuItem = mock(MenuItem.class);
    when(itemsBuilder.newClearItem(Mockito.<Command>any())).thenReturn(clearMenuItem);
    editorMenuSessionItems.populateMenu(fileMenuBuilder);
    editorMenuSessionItems.setItemEnabled(ClearSessionCommand.class, true);
    verify(clearMenuItem).setEnabled(true);
    editorMenuSessionItems.setItemEnabled(ClearSessionCommand.class, false);
    verify(clearMenuItem).setEnabled(false);
}
Also used : 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