Search in sources :

Example 1 with ITableContextMenu

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);
}
Also used : ITableContextMenu(org.eclipse.scout.rt.client.ui.action.menu.root.ITableContextMenu) IMenu(org.eclipse.scout.rt.client.ui.action.menu.IMenu) OrderedCollection(org.eclipse.scout.rt.platform.util.collection.OrderedCollection) ITableContextMenu(org.eclipse.scout.rt.client.ui.action.menu.root.ITableContextMenu) TableContextMenu(org.eclipse.scout.rt.client.ui.action.menu.root.internal.TableContextMenu)

Example 2 with ITableContextMenu

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());
}
Also used : ITableContextMenu(org.eclipse.scout.rt.client.ui.action.menu.root.ITableContextMenu) AbstractTable(org.eclipse.scout.rt.client.ui.basic.table.AbstractTable) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) IActionFilter(org.eclipse.scout.rt.client.ui.action.IActionFilter) Test(org.junit.Test)

Example 3 with ITableContextMenu

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());
}
Also used : ITableContextMenu(org.eclipse.scout.rt.client.ui.action.menu.root.ITableContextMenu) AbstractTable(org.eclipse.scout.rt.client.ui.basic.table.AbstractTable) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) IActionFilter(org.eclipse.scout.rt.client.ui.action.IActionFilter) Test(org.junit.Test)

Example 4 with ITableContextMenu

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());
}
Also used : ITableContextMenu(org.eclipse.scout.rt.client.ui.action.menu.root.ITableContextMenu) AbstractTable(org.eclipse.scout.rt.client.ui.basic.table.AbstractTable) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) IActionFilter(org.eclipse.scout.rt.client.ui.action.IActionFilter) Test(org.junit.Test)

Example 5 with ITableContextMenu

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);
        }
    }
}
Also used : ITableContextMenu(org.eclipse.scout.rt.client.ui.action.menu.root.ITableContextMenu) OutlineMenuWrapper(org.eclipse.scout.rt.client.ui.desktop.outline.OutlineMenuWrapper) IMenu(org.eclipse.scout.rt.client.ui.action.menu.IMenu) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable)

Aggregations

ITableContextMenu (org.eclipse.scout.rt.client.ui.action.menu.root.ITableContextMenu)9 ITable (org.eclipse.scout.rt.client.ui.basic.table.ITable)8 IActionFilter (org.eclipse.scout.rt.client.ui.action.IActionFilter)7 AbstractTable (org.eclipse.scout.rt.client.ui.basic.table.AbstractTable)7 Test (org.junit.Test)7 IMenu (org.eclipse.scout.rt.client.ui.action.menu.IMenu)2 TableContextMenu (org.eclipse.scout.rt.client.ui.action.menu.root.internal.TableContextMenu)1 OutlineMenuWrapper (org.eclipse.scout.rt.client.ui.desktop.outline.OutlineMenuWrapper)1 OrderedCollection (org.eclipse.scout.rt.platform.util.collection.OrderedCollection)1