Search in sources :

Example 6 with IAction

use of org.eclipse.scout.rt.client.ui.action.IAction 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 7 with IAction

use of org.eclipse.scout.rt.client.ui.action.IAction 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 8 with IAction

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

the class TableContextMenu method calculateEnableState.

/**
 * @param ownerValue
 */
protected void calculateEnableState(List<? extends ITableRow> ownerValue) {
    boolean enabled = getContainer().isEnabled();
    if (enabled) {
        for (ITableRow row : ownerValue) {
            if (!row.isEnabled()) {
                enabled = false;
                break;
            }
        }
    }
    final boolean inheritedEnability = enabled;
    acceptVisitor(new IActionVisitor() {

        @Override
        public int visit(IAction action) {
            if (action instanceof IMenu) {
                IMenu menu = (IMenu) action;
                if (!menu.hasChildActions() && menu.isInheritAccessibility()) {
                    menu.setEnabledInheritAccessibility(inheritedEnability);
                }
            }
            return CONTINUE;
        }
    });
}
Also used : IActionVisitor(org.eclipse.scout.rt.client.ui.action.IActionVisitor) IMenu(org.eclipse.scout.rt.client.ui.action.menu.IMenu) IAction(org.eclipse.scout.rt.client.ui.action.IAction) ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow)

Example 9 with IAction

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

the class TableContextMenu method handleOwnerEnabledChanged.

protected void handleOwnerEnabledChanged() {
    ITable container = getContainer();
    if (container != null) {
        final boolean enabled = container.isEnabled();
        acceptVisitor(new IActionVisitor() {

            @Override
            public int visit(IAction action) {
                if (action instanceof IMenu) {
                    IMenu menu = (IMenu) action;
                    if (!menu.hasChildActions() && menu.isInheritAccessibility()) {
                        menu.setEnabled(enabled);
                    }
                }
                return CONTINUE;
            }
        });
    }
}
Also used : IActionVisitor(org.eclipse.scout.rt.client.ui.action.IActionVisitor) IMenu(org.eclipse.scout.rt.client.ui.action.menu.IMenu) IAction(org.eclipse.scout.rt.client.ui.action.IAction) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable)

Example 10 with IAction

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

the class TreeContextMenu method handleOwnerEnabledChanged.

protected void handleOwnerEnabledChanged() {
    ITree container = getContainer();
    if (container != null) {
        final boolean enabled = container.isEnabled();
        acceptVisitor(new IActionVisitor() {

            @Override
            public int visit(IAction action) {
                if (action instanceof IMenu) {
                    IMenu menu = (IMenu) action;
                    if (!menu.hasChildActions() && menu.isInheritAccessibility()) {
                        menu.setEnabledInheritAccessibility(enabled);
                    }
                }
                return CONTINUE;
            }
        });
    }
}
Also used : IActionVisitor(org.eclipse.scout.rt.client.ui.action.IActionVisitor) IMenu(org.eclipse.scout.rt.client.ui.action.menu.IMenu) IAction(org.eclipse.scout.rt.client.ui.action.IAction) ITree(org.eclipse.scout.rt.client.ui.basic.tree.ITree)

Aggregations

IAction (org.eclipse.scout.rt.client.ui.action.IAction)13 IActionVisitor (org.eclipse.scout.rt.client.ui.action.IActionVisitor)8 IMenu (org.eclipse.scout.rt.client.ui.action.menu.IMenu)8 ArrayList (java.util.ArrayList)5 JsonAdapterPropertyConfig (org.eclipse.scout.rt.ui.html.json.form.fields.JsonAdapterPropertyConfig)3 JsonAdapterPropertyConfigBuilder (org.eclipse.scout.rt.ui.html.json.form.fields.JsonAdapterPropertyConfigBuilder)3 JSONObject (org.json.JSONObject)3 List (java.util.List)2 ITable (org.eclipse.scout.rt.client.ui.basic.table.ITable)2 ITree (org.eclipse.scout.rt.client.ui.basic.tree.ITree)2 ResourceListTransferObject (org.eclipse.scout.rt.client.ui.dnd.ResourceListTransferObject)2 LinkedList (java.util.LinkedList)1 DeepLinkException (org.eclipse.scout.rt.client.deeplink.DeepLinkException)1 IDeviceTransformationService (org.eclipse.scout.rt.client.transformation.IDeviceTransformationService)1 IEventHistory (org.eclipse.scout.rt.client.ui.IEventHistory)1 ActionFinder (org.eclipse.scout.rt.client.ui.action.ActionFinder)1 IActionFilter (org.eclipse.scout.rt.client.ui.action.IActionFilter)1 IKeyStroke (org.eclipse.scout.rt.client.ui.action.keystroke.IKeyStroke)1 IContextMenu (org.eclipse.scout.rt.client.ui.action.menu.root.IContextMenu)1 IActionNode (org.eclipse.scout.rt.client.ui.action.tree.IActionNode)1