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]));
}
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());
}
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);
}
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);
}
}
}
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);
}
}
Aggregations