Search in sources :

Example 1 with OutlineMenuWrapper

use of org.eclipse.scout.rt.client.ui.desktop.outline.OutlineMenuWrapper in project scout.rt by eclipse.

the class MobileDeviceTransformer method notifyPageDetailTableChanged.

@Override
public void notifyPageDetailTableChanged(ITable table) {
    IPage<?> activePage = getDesktop().getOutline().getActivePage();
    IPage<?> parentPage = activePage.getParentPage();
    if (parentPage == null) {
        return;
    }
    ITable parentTable = parentPage.getTable();
    if (parentTable == null) {
        return;
    }
    // Remove empty space menus of the current detail table which are already defined on the parent detail table as single selection menus
    // This prevents duplicate menus because the ui concatenates these menus when a node is shown
    // It is important to only remove outline wrapper menus which are defined on the parent table because the menu could be defined on a page and therefore needs to be displayed
    List<IMenu> newMenus = new ArrayList<IMenu>();
    for (IMenu menu : table.getMenus()) {
        if ((menu instanceof OutlineMenuWrapper)) {
            OutlineMenuWrapper menuWrapper = (OutlineMenuWrapper) menu;
            IMenu originalMenu = unwrapOutlineWrapperMenu(menuWrapper);
            if (menuWrapper.getMenuTypes().contains(TableMenuType.EmptySpace) && originalMenu.getMenuTypes().contains(TableMenuType.SingleSelection) && parentTable.getMenus().contains(originalMenu)) {
                // This menu should be removed -> don't add it to the list of new menus
                continue;
            }
        }
        newMenus.add(menu);
    }
    if (!CollectionUtility.equalsCollection(newMenus, table.getContextMenu().getChildActions())) {
        table.getContextMenu().setChildActions(newMenus);
    }
}
Also used : OutlineMenuWrapper(org.eclipse.scout.rt.client.ui.desktop.outline.OutlineMenuWrapper) IMenu(org.eclipse.scout.rt.client.ui.action.menu.IMenu) ArrayList(java.util.ArrayList) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable)

Example 2 with OutlineMenuWrapper

use of org.eclipse.scout.rt.client.ui.desktop.outline.OutlineMenuWrapper in project scout.rt by eclipse.

the class JsonMenu method initJsonProperties.

@Override
protected void initJsonProperties(MENU model) {
    super.initJsonProperties(model);
    putJsonProperty(new JsonProperty<MENU>(PROP_SEPARATOR, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isSeparator();
        }
    });
    putJsonProperty(new JsonProperty<MENU>(PROP_OUTLINE_MENU_WRAPPER, model) {

        @Override
        protected Boolean modelValue() {
            return getModel() instanceof OutlineMenuWrapper;
        }
    });
    putJsonProperty(new JsonProperty<MENU>(IMenu.PROP_MENU_TYPES, model) {

        @Override
        protected Set<IMenuType> modelValue() {
            return getModel().getMenuTypes();
        }

        @Override
        public Object prepareValueForToJson(Object value) {
            Set<String> menuTypes = new HashSet<>();
            for (IMenuType type : getModel().getMenuTypes()) {
                String prefix = type.getClass().getSimpleName().replace("MenuType", "");
                menuTypes.add(prefix + "." + type.toString());
            }
            return new JSONArray(menuTypes);
        }
    });
    putJsonProperty(new JsonProperty<MENU>(IMenu.PROP_PREVENT_DOUBLE_CLICK, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isPreventDoubleClick();
        }
    });
}
Also used : OutlineMenuWrapper(org.eclipse.scout.rt.client.ui.desktop.outline.OutlineMenuWrapper) HashSet(java.util.HashSet) Set(java.util.Set) IMenuType(org.eclipse.scout.rt.client.ui.action.menu.IMenuType) JSONArray(org.json.JSONArray)

Example 3 with OutlineMenuWrapper

use of org.eclipse.scout.rt.client.ui.desktop.outline.OutlineMenuWrapper in project scout.rt by eclipse.

the class AbstractPageWithNodes method updateContextMenusForSelection.

protected void updateContextMenusForSelection() {
    // remove old
    if (m_pageMenusOfSelection != null) {
        getTable().getContextMenu().removeChildActions(m_pageMenusOfSelection);
        m_pageMenusOfSelection = null;
    }
    List<IMenu> pageMenus = new ArrayList<IMenu>();
    List<ITableRow> selectedRows = getTable().getSelectedRows();
    if (CollectionUtility.size(selectedRows) == 1) {
        ITreeNode node = getTreeNodeFor(CollectionUtility.firstElement(selectedRows));
        if (node instanceof IPageWithNodes) {
            IPageWithNodes pageWithNodes = (IPageWithNodes) node;
            IActionFilter filter = ActionUtility.createMenuFilterMenuTypes(CollectionUtility.hashSet(TreeMenuType.SingleSelection), false);
            List<IMenu> menus = ActionUtility.getActions(pageWithNodes.getMenus(), filter);
            for (IMenu m : menus) {
                pageMenus.add(new OutlineMenuWrapper(m, TREE_MENU_TYPE_MAPPER, filter));
            }
        }
    }
    getTable().getContextMenu().addChildActions(pageMenus);
    m_pageMenusOfSelection = pageMenus;
}
Also used : OutlineMenuWrapper(org.eclipse.scout.rt.client.ui.desktop.outline.OutlineMenuWrapper) IMenu(org.eclipse.scout.rt.client.ui.action.menu.IMenu) ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) ArrayList(java.util.ArrayList) IActionFilter(org.eclipse.scout.rt.client.ui.action.IActionFilter) ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow)

Example 4 with OutlineMenuWrapper

use of org.eclipse.scout.rt.client.ui.desktop.outline.OutlineMenuWrapper 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

OutlineMenuWrapper (org.eclipse.scout.rt.client.ui.desktop.outline.OutlineMenuWrapper)4 IMenu (org.eclipse.scout.rt.client.ui.action.menu.IMenu)3 ArrayList (java.util.ArrayList)2 ITable (org.eclipse.scout.rt.client.ui.basic.table.ITable)2 HashSet (java.util.HashSet)1 Set (java.util.Set)1 IActionFilter (org.eclipse.scout.rt.client.ui.action.IActionFilter)1 IMenuType (org.eclipse.scout.rt.client.ui.action.menu.IMenuType)1 ITableContextMenu (org.eclipse.scout.rt.client.ui.action.menu.root.ITableContextMenu)1 ITableRow (org.eclipse.scout.rt.client.ui.basic.table.ITableRow)1 ITreeNode (org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode)1 JSONArray (org.json.JSONArray)1