Search in sources :

Example 26 with IMenu

use of org.eclipse.scout.rt.client.ui.action.menu.IMenu in project scout.rt by eclipse.

the class PageWithTable6Test method assertMenus.

private static void assertMenus(PageWithTable.Table table, String[] expectedMenus) {
    List<String> actualMenus = new ArrayList<String>();
    for (IMenu m : ActionUtility.normalizedActions(table.getContextMenu().getChildActions(), ActionUtility.createMenuFilterMenuTypes(table.getContextMenu().getCurrentMenuTypes(), true))) {
        if (m.isEnabled()) {
            actualMenus.add(m.getText());
        }
    }
    assertArrayEquals(expectedMenus, actualMenus.toArray(new String[0]));
}
Also used : IMenu(org.eclipse.scout.rt.client.ui.action.menu.IMenu) ArrayList(java.util.ArrayList)

Example 27 with IMenu

use of org.eclipse.scout.rt.client.ui.action.menu.IMenu in project scout.rt by eclipse.

the class AbstractDesktop method initConfig.

protected void initConfig() {
    m_eventHistory = createEventHistory();
    // add convenience observer for event history
    addDesktopListener(new DesktopListener() {

        @Override
        public void desktopChanged(DesktopEvent e) {
            IEventHistory<DesktopEvent> h = getEventHistory();
            if (h != null) {
                h.notifyEvent(e);
            }
        }
    });
    ClientSessionProvider.currentSession().getMemoryPolicy().registerDesktop(this);
    BEANS.get(IDeviceTransformationService.class).install(this);
    initDesktopExtensions();
    setTitle(getConfiguredTitle());
    setCssClass(getConfiguredCssClass());
    setSelectViewTabsKeyStrokesEnabled(getConfiguredSelectViewTabsKeyStrokesEnabled());
    setSelectViewTabsKeyStrokeModifier(getConfiguredSelectViewTabsKeyStrokeModifier());
    setLogoId(getConfiguredLogoId());
    setDisplayStyle(getConfiguredDisplayStyle());
    initDisplayStyle(getDisplayStyle());
    setCacheSplitterPosition(getConfiguredCacheSplitterPosition());
    List<IDesktopExtension> extensions = getDesktopExtensions();
    m_contributionHolder = new ContributionComposite(this);
    // outlines
    OrderedCollection<IOutline> outlines = new OrderedCollection<IOutline>();
    for (IDesktopExtension ext : extensions) {
        try {
            ext.contributeOutlines(outlines);
        } catch (Exception t) {
            LOG.error("contributing outlines by {}", ext, t);
        }
    }
    List<IOutline> contributedOutlines = m_contributionHolder.getContributionsByClass(IOutline.class);
    outlines.addAllOrdered(contributedOutlines);
    // move outlines
    ExtensionUtility.moveModelObjects(outlines);
    setAvailableOutlines(outlines.getOrderedList());
    // actions (keyStroke, menu, viewButton, toolButton)
    List<IAction> actionList = new ArrayList<IAction>();
    for (IDesktopExtension ext : extensions) {
        try {
            ext.contributeActions(actionList);
        } catch (Exception t) {
            LOG.error("contributing actions by {}", ext, t);
        }
    }
    List<IAction> contributedActions = m_contributionHolder.getContributionsByClass(IAction.class);
    actionList.addAll(contributedActions);
    // build complete menu and viewButton lists
    // only top level menus
    OrderedComparator orderedComparator = new OrderedComparator();
    List<IMenu> menuList = new ActionFinder().findActions(actionList, IMenu.class, false);
    ExtensionUtility.moveModelObjects(menuList);
    Collections.sort(menuList, orderedComparator);
    m_menus = menuList;
    List<IViewButton> viewButtonList = new ActionFinder().findActions(actionList, IViewButton.class, false);
    ExtensionUtility.moveModelObjects(viewButtonList);
    Collections.sort(viewButtonList, orderedComparator);
    m_viewButtons = viewButtonList;
    // add dynamic keyStrokes
    List<IKeyStroke> ksList = new ActionFinder().findActions(actionList, IKeyStroke.class, true);
    for (IKeyStroke ks : ksList) {
        try {
            ks.initAction();
        } catch (RuntimeException | PlatformError e) {
            LOG.error("could not initialize key stroke '{}'.", ks, e);
        }
    }
    addKeyStrokes(ksList.toArray(new IKeyStroke[ksList.size()]));
    // init outlines
    for (IOutline o : m_availableOutlines) {
        try {
            o.initTree();
        } catch (Exception e) {
            LOG.error("Could not init outline {}", o, e);
        }
    }
    addPropertyChangeListener(new P_LocalPropertyChangeListener());
}
Also used : IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) ArrayList(java.util.ArrayList) IEventHistory(org.eclipse.scout.rt.client.ui.IEventHistory) IKeyStroke(org.eclipse.scout.rt.client.ui.action.keystroke.IKeyStroke) OrderedComparator(org.eclipse.scout.rt.platform.OrderedComparator) IMenu(org.eclipse.scout.rt.client.ui.action.menu.IMenu) IAction(org.eclipse.scout.rt.client.ui.action.IAction) ContributionComposite(org.eclipse.scout.rt.shared.extension.ContributionComposite) OrderedCollection(org.eclipse.scout.rt.platform.util.collection.OrderedCollection) DeepLinkException(org.eclipse.scout.rt.client.deeplink.DeepLinkException) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) VetoException(org.eclipse.scout.rt.platform.exception.VetoException) PlatformError(org.eclipse.scout.rt.platform.exception.PlatformError) IViewButton(org.eclipse.scout.rt.client.ui.action.view.IViewButton) IDeviceTransformationService(org.eclipse.scout.rt.client.transformation.IDeviceTransformationService) ActionFinder(org.eclipse.scout.rt.client.ui.action.ActionFinder)

Example 28 with IMenu

use of org.eclipse.scout.rt.client.ui.action.menu.IMenu in project scout.rt by eclipse.

the class OutlineMenuWrapper method wrapChildActions.

protected void wrapChildActions() {
    List<IMenu> childActions = m_wrappedMenu.getChildActions();
    List<IMenu> wrappedChildActions = new ArrayList<IMenu>(childActions.size());
    // create child wrappers
    for (IAction a : ActionUtility.getActions(m_wrappedMenu.getChildActions(), m_menuFilter)) {
        if (a instanceof IMenu) {
            wrappedChildActions.add(new OutlineMenuWrapper((IMenu) a, m_menuTypeMapper, m_menuFilter));
        }
    }
    propertySupport.setProperty(PROP_CHILD_ACTIONS, wrappedChildActions);
}
Also used : IMenu(org.eclipse.scout.rt.client.ui.action.menu.IMenu) IAction(org.eclipse.scout.rt.client.ui.action.IAction) ArrayList(java.util.ArrayList)

Example 29 with IMenu

use of org.eclipse.scout.rt.client.ui.action.menu.IMenu 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)

Example 30 with IMenu

use of org.eclipse.scout.rt.client.ui.action.menu.IMenu in project scout.rt by eclipse.

the class AbstractPageWithNodes method enhanceDetailFormWithPageMenus.

protected void enhanceDetailFormWithPageMenus() {
    if (getOutline() == null) {
        return;
    }
    IForm form = getDetailForm();
    IFormFieldContextMenu mainBoxContextMenu = form.getRootGroupBox().getContextMenu();
    List<IMenu> menus = mainBoxContextMenu.getChildActions();
    for (IMenu menu : getOutline().getMenusForPage(this)) {
        // TODO [6.2] hmu, bsh: menues im ui sammeln anstelle in forms injecten
        if (menu.getMenuTypes().contains(TreeMenuType.Header) && menu.getMenuTypes().size() == 1) {
            // Don't show TreeMenuType.Header. These menus should only be shown on outline title
            continue;
        }
        menus.add(OutlineMenuWrapper.wrapMenu(menu));
    }
    if (!CollectionUtility.equalsCollection(menus, mainBoxContextMenu.getChildActions())) {
        mainBoxContextMenu.setChildActions(menus);
    }
}
Also used : IMenu(org.eclipse.scout.rt.client.ui.action.menu.IMenu) IFormFieldContextMenu(org.eclipse.scout.rt.client.ui.action.menu.root.IFormFieldContextMenu) IForm(org.eclipse.scout.rt.client.ui.form.IForm)

Aggregations

IMenu (org.eclipse.scout.rt.client.ui.action.menu.IMenu)64 ArrayList (java.util.ArrayList)17 Test (org.junit.Test)17 OrderedCollection (org.eclipse.scout.rt.platform.util.collection.OrderedCollection)12 IAction (org.eclipse.scout.rt.client.ui.action.IAction)8 JSONObject (org.json.JSONObject)8 TestMenus (org.eclipse.scout.rt.client.extension.ui.action.tree.fixture.TestMenus)6 IActionVisitor (org.eclipse.scout.rt.client.ui.action.IActionVisitor)6 JSONArray (org.json.JSONArray)6 IKeyStroke (org.eclipse.scout.rt.client.ui.action.keystroke.IKeyStroke)5 ITable (org.eclipse.scout.rt.client.ui.basic.table.ITable)5 ITreeNode (org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode)5 ContributionComposite (org.eclipse.scout.rt.shared.extension.ContributionComposite)5 LinkedList (java.util.LinkedList)4 IOutline (org.eclipse.scout.rt.client.ui.desktop.outline.IOutline)4 ProcessingException (org.eclipse.scout.rt.platform.exception.ProcessingException)4 List (java.util.List)3 ActionFinder (org.eclipse.scout.rt.client.ui.action.ActionFinder)3 AbstractMenu (org.eclipse.scout.rt.client.ui.action.menu.AbstractMenu)3 IFormFieldContextMenu (org.eclipse.scout.rt.client.ui.action.menu.root.IFormFieldContextMenu)3