use of org.eclipse.scout.rt.client.ui.action.menu.root.ITableContextMenu in project scout.rt by eclipse.
the class AbstractTable method initMenus.
protected void initMenus() {
List<Class<? extends IMenu>> ma = getDeclaredMenus();
OrderedCollection<IMenu> menus = new OrderedCollection<IMenu>();
Map<Class<?>, Class<? extends IMenu>> replacements = ConfigurationUtility.getReplacementMapping(ma);
if (!replacements.isEmpty()) {
m_menuReplacementMapping = replacements;
}
for (Class<? extends IMenu> clazz : ma) {
IMenu menu = ConfigurationUtility.newInnerInstance(this, clazz);
menus.addOrdered(menu);
}
List<IMenu> contributedMenus = m_contributionHolder.getContributionsByClass(IMenu.class);
menus.addAllOrdered(contributedMenus);
injectMenusInternal(menus);
addHeaderMenus(menus);
// set container on menus
for (IMenu menu : menus) {
menu.setContainerInternal(this);
}
new MoveActionNodesHandler<IMenu>(menus).moveModelObjects();
ITableContextMenu contextMenu = new TableContextMenu(this, menus.getOrderedList());
setContextMenu(contextMenu);
}
use of org.eclipse.scout.rt.client.ui.action.menu.root.ITableContextMenu in project scout.rt by eclipse.
the class TableMenuTest method testRowDisabledSingleSelection.
/**
* Tests menu disabled if row disabled, single selection
*/
@Test
public void testRowDisabledSingleSelection() {
Table t = new Table();
t.addRowsByMatrix(TEST_ROWS);
ITableContextMenu contextMenu = t.getContextMenu();
t.getRow(0).setEnabled(false);
t.selectRows(CollectionUtility.arrayList(t.getRow(0)), false);
IActionFilter filter = ActionUtility.createMenuFilterMenuTypes(contextMenu.getCurrentMenuTypes(), true);
List<IMenu> visibleMenus = ActionUtility.normalizedActions(contextMenu.getChildActions(), filter);
assertEquals(false, visibleMenus.get(0).isEnabled());
}
use of org.eclipse.scout.rt.client.ui.action.menu.root.ITableContextMenu in project scout.rt by eclipse.
the class TableMenuTest method testSingleSelection.
/**
* Tests the visibility for a single selection menu
*/
@Test
public void testSingleSelection() {
Table t = new Table();
t.addRowsByMatrix(TEST_ROWS);
ITableContextMenu contextMenu = t.getContextMenu();
// single hugo boss
t.selectRows(CollectionUtility.arrayList(t.getRow(0)), false);
IActionFilter filter = ActionUtility.createMenuFilterMenuTypes(contextMenu.getCurrentMenuTypes(), true);
List<IMenu> visibleMenus = ActionUtility.normalizedActions(contextMenu.getChildActions(), filter);
assertEquals(2, visibleMenus.size());
assertEquals("SingleSelectionMenu", visibleMenus.get(0).getClass().getSimpleName());
assertEquals("HugoBossMenu", visibleMenus.get(1).getClass().getSimpleName());
// single only meier
t.selectRows(CollectionUtility.arrayList(t.getRow(1)), false);
filter = ActionUtility.createMenuFilterMenuTypes(contextMenu.getCurrentMenuTypes(), true);
visibleMenus = ActionUtility.normalizedActions(contextMenu.getChildActions(), filter);
assertEquals(1, visibleMenus.size());
assertEquals("SingleSelectionMenu", visibleMenus.get(0).getClass().getSimpleName());
}
use of org.eclipse.scout.rt.client.ui.action.menu.root.ITableContextMenu in project scout.rt by eclipse.
the class TableMenuTest method setMultiSelection.
/**
* Tests the visibility for a multi selection menu
*/
@Test
public void setMultiSelection() {
Table t = new Table();
t.addRowsByMatrix(TEST_ROWS);
ITableContextMenu contextMenu = t.getContextMenu();
// multi selection
t.selectRows(CollectionUtility.arrayList(t.getRow(0), t.getRow(1)), false);
IActionFilter filter = ActionUtility.createMenuFilterMenuTypes(contextMenu.getCurrentMenuTypes(), true);
List<IMenu> visibleMenus = ActionUtility.normalizedActions(contextMenu.getChildActions(), filter);
assertEquals(1, visibleMenus.size());
assertEquals("MultiSelectionMenu", visibleMenus.get(0).getClass().getSimpleName());
}
use of org.eclipse.scout.rt.client.ui.action.menu.root.ITableContextMenu in project scout.rt by eclipse.
the class AbstractPage method enhanceTableWithPageMenus.
protected void enhanceTableWithPageMenus() {
if (isPageMenusAdded()) {
return;
}
setPageMenusAdded();
ITable table = getTable();
if (table != null) {
ITableContextMenu contextMenu = table.getContextMenu();
List<IMenu> menus = contextMenu.getChildActions();
for (IMenu menu : getOutline().getContextMenu().getChildActions()) {
if (!OutlineMenuWrapper.containsWrappedMenu(table.getMenus(), menu)) {
// mapping from TreeMenuType to TableMenuType
menus.add(new OutlineMenuWrapper(menu, TREE_MENU_TYPE_MAPPER));
}
}
if (!CollectionUtility.equalsCollection(menus, contextMenu.getChildActions())) {
contextMenu.setChildActions(menus);
}
}
}
Aggregations