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