Search in sources :

Example 1 with MenuModel

use of org.jowidgets.tools.model.item.MenuModel in project jo-client-platform by jo-source.

the class BeanTableImpl method createCellPopupMenuModel.

private IMenuModel createCellPopupMenuModel(final Integer index) {
    final IMenuModel menuModel;
    if (hasDefaultMenus) {
        final IMenuModel headerPopupMenuModelUndecorated;
        if (!isColumnPopupDetectionSupported()) {
            headerPopupMenuModelUndecorated = createHeaderPopupMenuModelUndecorated(index);
        } else {
            headerPopupMenuModelUndecorated = null;
        }
        final IMenuModel cellPopupMenu = menuFactory.cellPopupMenu(this, headerPopupMenuModelUndecorated, index.intValue());
        if (cellPopupMenu != null) {
            menuModel = cellPopupMenu;
        } else {
            menuModel = new MenuModel();
        }
    } else {
        menuModel = new MenuModel();
    }
    boolean separatorNeeded = menuModel.getChildren().size() > 0;
    if (creatorAction != null) {
        if (separatorNeeded) {
            menuModel.addSeparator();
            separatorNeeded = false;
        }
        menuModel.addAction(creatorAction);
    }
    if (copyAction != null) {
        if (separatorNeeded) {
            menuModel.addSeparator();
            separatorNeeded = false;
        }
        menuModel.addAction(copyAction);
    }
    if (pasteAction != null) {
        if (separatorNeeded) {
            menuModel.addSeparator();
            separatorNeeded = false;
        }
        menuModel.addAction(pasteAction);
    }
    if (deleteAction != null) {
        if (separatorNeeded) {
            menuModel.addSeparator();
            separatorNeeded = false;
        }
        menuModel.addAction(deleteAction);
    }
    separatorNeeded = menuModel.getChildren().size() > 0;
    if (moveOrderedBeanUpAction != null && moveOrderedBeanDownAction != null) {
        if (separatorNeeded) {
            menuModel.addSeparator();
        }
        menuModel.addAction(moveOrderedBeanUpAction);
        menuModel.addAction(moveOrderedBeanDownAction);
    }
    if (cellMenuInterceptor != null) {
        cellMenuInterceptor.afterMenuCreated(this, menuModel, index.intValue());
    }
    addMenuModel(menuModel, cellPopupMenuModel);
    addMenuModel(menuModel, pluggedCellPopupMenuModel);
    menuModel.addDecorator(createDecorator(false));
    return menuModel;
}
Also used : IMenuModel(org.jowidgets.api.model.item.IMenuModel) IMenuModel(org.jowidgets.api.model.item.IMenuModel) MenuModel(org.jowidgets.tools.model.item.MenuModel)

Example 2 with MenuModel

use of org.jowidgets.tools.model.item.MenuModel in project jo-client-platform by jo-source.

the class CapWorkbenchMenuFactoryImpl method dataMenu.

@Override
public IMenuModel dataMenu() {
    IMenuModel result = new MenuModel(Messages.getString("CapWorkbenchMenuFactoryImpl.data"));
    final IDataModelAction loadAction = CapWorkbenchActionsProvider.loadAction();
    boolean separator = false;
    if (loadAction != null) {
        result.addAction(loadAction);
        separator = true;
    }
    final IDataModelAction cancelAction = CapWorkbenchActionsProvider.cancelAction();
    if (cancelAction != null) {
        result.addAction(cancelAction);
        separator = true;
    }
    if (separator) {
        result.addSeparator();
        separator = false;
    }
    final IDataModelAction undoAction = CapWorkbenchActionsProvider.undoAction();
    if (undoAction != null) {
        result.addAction(undoAction);
        separator = true;
    }
    final IDataModelAction saveAction = CapWorkbenchActionsProvider.saveAction();
    if (saveAction != null) {
        result.addAction(saveAction);
        separator = true;
    }
    if (separator) {
        result.addSeparator();
    }
    final IAction refreshLookUpsAction = CapWorkbenchActionsProvider.refreshLookUpsAction();
    if (refreshLookUpsAction != null) {
        result.addAction(refreshLookUpsAction);
    }
    final int size = result.getChildren().size();
    if (size > 0) {
        final IMenuItemModel itemModel = result.getChildren().get(size - 1);
        if (itemModel instanceof ISeparatorItemModel) {
            result.removeItem(itemModel);
        }
    }
    // Modify with plugins
    for (final IWorkbenchMenuInterceptorPlugin plugin : PluginProvider.getPlugins(IWorkbenchMenuInterceptorPlugin.ID)) {
        result = plugin.getMenuInterceptor().dataMenuModel(result);
        if (result == null) {
            break;
        }
    }
    return result;
}
Also used : IMenuModel(org.jowidgets.api.model.item.IMenuModel) IAction(org.jowidgets.api.command.IAction) ISeparatorItemModel(org.jowidgets.api.model.item.ISeparatorItemModel) IMenuModel(org.jowidgets.api.model.item.IMenuModel) MenuModel(org.jowidgets.tools.model.item.MenuModel) IMenuItemModel(org.jowidgets.api.model.item.IMenuItemModel) IWorkbenchMenuInterceptorPlugin(org.jowidgets.cap.ui.api.plugin.IWorkbenchMenuInterceptorPlugin) IDataModelAction(org.jowidgets.cap.ui.api.command.IDataModelAction)

Example 3 with MenuModel

use of org.jowidgets.tools.model.item.MenuModel in project jo-client-platform by jo-source.

the class BeanRelationTreeImpl method createNodeMenus.

private IMenuModel createNodeMenus(final IBeanRelationNodeModel<Object, Object> relationNodeModel, final IMenuModel relationMenu, final IAction createAction) {
    final IMenuModel result = new MenuModel();
    boolean needSeparator = false;
    final IAction copyAction = createCopyAction(relationNodeModel);
    if (copyAction != null && createAction == null) {
        result.addAction(copyAction);
        needSeparator = true;
    }
    if (relationMenu.getChildren().size() > 0) {
        for (final IMenuItemModel item : relationMenu.getChildren()) {
            result.addItem(item);
            if (copyAction != null && createAction != null && item instanceof IActionItemModel) {
                final IAction action = ((IActionItemModel) item).getAction();
                if (NullCompatibleEquivalence.equals(createAction, action)) {
                    result.addAction(copyAction);
                }
            }
        }
        needSeparator = true;
    }
    final IEntityService entityService = ServiceProvider.getService(IEntityService.ID);
    if (entityService != null) {
        final Object childEntityId = relationNodeModel.getChildEntityId();
        if (relationNodeModel.getParentEntityId() != null && relationNodeModel.getParentBean() != null) {
            final List<IEntityLinkDescriptor> links = entityService.getEntityLinks(relationNodeModel.getParentEntityId());
            for (final IEntityLinkDescriptor link : links) {
                if (childEntityId.equals(link.getLinkedEntityId())) {
                    final IAction linkDeleterAction = createLinkDeleterAction(relationNodeModel, link);
                    if (linkDeleterAction != null) {
                        if (needSeparator) {
                            result.addSeparator();
                            needSeparator = false;
                        }
                        result.addAction(linkDeleterAction);
                    }
                }
            }
        }
        final IAction deleterAction = createDeleterAction(relationNodeModel);
        if (deleterAction != null) {
            if (needSeparator) {
                result.addSeparator();
                needSeparator = false;
            }
            result.addAction(deleterAction);
        }
    }
    if (menuInterceptor != null) {
        return menuInterceptor.nodeMenu(relationNodeModel, result);
    } else {
        return result;
    }
}
Also used : IMenuModel(org.jowidgets.api.model.item.IMenuModel) IAction(org.jowidgets.api.command.IAction) IEntityService(org.jowidgets.cap.common.api.service.IEntityService) IEntityLinkDescriptor(org.jowidgets.cap.common.api.entity.IEntityLinkDescriptor) IMenuModel(org.jowidgets.api.model.item.IMenuModel) MenuModel(org.jowidgets.tools.model.item.MenuModel) IMenuItemModel(org.jowidgets.api.model.item.IMenuItemModel) IActionItemModel(org.jowidgets.api.model.item.IActionItemModel)

Example 4 with MenuModel

use of org.jowidgets.tools.model.item.MenuModel in project jo-client-platform by jo-source.

the class BeanTableImpl method createHeaderPopupMenuModelUndecorated.

private IMenuModel createHeaderPopupMenuModelUndecorated(final Integer index) {
    final IMenuModel menuModel;
    if (hasDefaultMenus) {
        final IMenuModel headerPopupMenu = menuFactory.headerPopupMenu(this, index.intValue());
        if (headerPopupMenu != null) {
            menuModel = headerPopupMenu;
        } else {
            menuModel = new MenuModel();
        }
    } else {
        menuModel = new MenuModel();
    }
    if (headerMenuInterceptor != null) {
        headerMenuInterceptor.afterMenuCreated(this, menuModel, index.intValue());
    }
    addMenuModel(menuModel, headerPopupMenuModel);
    addMenuModel(menuModel, pluggedHeaderPopupMenuModel);
    return menuModel;
}
Also used : IMenuModel(org.jowidgets.api.model.item.IMenuModel) IMenuModel(org.jowidgets.api.model.item.IMenuModel) MenuModel(org.jowidgets.tools.model.item.MenuModel)

Aggregations

IMenuModel (org.jowidgets.api.model.item.IMenuModel)4 MenuModel (org.jowidgets.tools.model.item.MenuModel)4 IAction (org.jowidgets.api.command.IAction)2 IMenuItemModel (org.jowidgets.api.model.item.IMenuItemModel)2 IActionItemModel (org.jowidgets.api.model.item.IActionItemModel)1 ISeparatorItemModel (org.jowidgets.api.model.item.ISeparatorItemModel)1 IEntityLinkDescriptor (org.jowidgets.cap.common.api.entity.IEntityLinkDescriptor)1 IEntityService (org.jowidgets.cap.common.api.service.IEntityService)1 IDataModelAction (org.jowidgets.cap.ui.api.command.IDataModelAction)1 IWorkbenchMenuInterceptorPlugin (org.jowidgets.cap.ui.api.plugin.IWorkbenchMenuInterceptorPlugin)1