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);
}
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);
}
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);
}
}
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());
}
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);
}
Aggregations