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