Search in sources :

Example 11 with IMenuModel

use of org.jowidgets.api.model.item.IMenuModel in project jo-client-platform by jo-source.

the class BeanTableMenuFactoryImpl method filterCellMenu.

@Override
public IMenuModel filterCellMenu(final IBeanTable<BEAN_TYPE> table, final int columnIndex) {
    Assert.paramNotNull(table, "table");
    IMenuModel menuModel = new BeanTableCellFilterMenuModel<BEAN_TYPE>(table, columnIndex, this);
    for (final IBeanTableMenuInterceptor<BEAN_TYPE> interceptor : interceptors) {
        if (menuModel != null) {
            menuModel = interceptor.filterCellMenu(table, columnIndex, menuModel);
        } else {
            break;
        }
    }
    return menuModel;
}
Also used : IMenuModel(org.jowidgets.api.model.item.IMenuModel)

Example 12 with IMenuModel

use of org.jowidgets.api.model.item.IMenuModel in project jo-client-platform by jo-source.

the class BeanTableMenuFactoryImpl method headerPopupMenu.

@Override
public IMenuModel headerPopupMenu(final IBeanTable<BEAN_TYPE> table, final int columnIndex) {
    Assert.paramNotNull(table, "table");
    IMenuModel menuModel = new BeanTableHeaderMenuModel<BEAN_TYPE>(table, columnIndex, this);
    for (final IBeanTableMenuInterceptor<BEAN_TYPE> interceptor : interceptors) {
        if (menuModel != null) {
            menuModel = interceptor.headerPopupMenu(table, columnIndex, menuModel);
        } else {
            break;
        }
    }
    return menuModel;
}
Also used : IMenuModel(org.jowidgets.api.model.item.IMenuModel)

Example 13 with IMenuModel

use of org.jowidgets.api.model.item.IMenuModel 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 14 with IMenuModel

use of org.jowidgets.api.model.item.IMenuModel in project jo-client-platform by jo-source.

the class BeanTableImpl method addMenusFromPlugins.

@SuppressWarnings({ "rawtypes", "unchecked" })
private void addMenusFromPlugins(final Class<BEAN_TYPE> beanType, final Object entityId, final IMenuModel menuModel, final IMenuModel cellMenuModel, final IMenuModel headerMenuModel) {
    final IPluginPropertiesBuilder propBuilder = PluginToolkit.pluginPropertiesBuilder();
    propBuilder.add(IBeanTableMenuContributionPlugin.ENTITIY_ID_PROPERTY_KEY, entityId);
    propBuilder.add(IBeanTableMenuContributionPlugin.BEAN_TYPE_PROPERTY_KEY, beanType);
    final IPluginProperties properties = propBuilder.build();
    final List<IBeanTableMenuContributionPlugin<?>> plugins = PluginProvider.getPlugins(IBeanTableMenuContributionPlugin.ID, properties);
    if (plugins != null) {
        for (final IBeanTableMenuContributionPlugin plugin : plugins) {
            final IMenuModel menu = plugin.getTableMenu(properties, this);
            if (menu != null) {
                menuModel.addItemsOfModel(menu);
            }
            final IMenuModel cellMenu = plugin.getCellMenu(properties, this);
            if (menu != null) {
                cellMenuModel.addItemsOfModel(cellMenu);
            }
            final IMenuModel headerMenu = plugin.getHeaderMenu(properties, this);
            if (menu != null) {
                headerMenuModel.addItemsOfModel(headerMenu);
            }
        }
    }
}
Also used : IPluginProperties(org.jowidgets.plugin.api.IPluginProperties) IMenuModel(org.jowidgets.api.model.item.IMenuModel) IPluginPropertiesBuilder(org.jowidgets.plugin.api.IPluginPropertiesBuilder) IBeanTableMenuContributionPlugin(org.jowidgets.cap.ui.api.plugin.IBeanTableMenuContributionPlugin)

Example 15 with IMenuModel

use of org.jowidgets.api.model.item.IMenuModel 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)17 IAction (org.jowidgets.api.command.IAction)4 MenuModel (org.jowidgets.tools.model.item.MenuModel)4 IMenuItemModel (org.jowidgets.api.model.item.IMenuItemModel)2 IToolBarModel (org.jowidgets.api.model.item.IToolBarModel)2 IActionItemModel (org.jowidgets.api.model.item.IActionItemModel)1 IMenuBarModel (org.jowidgets.api.model.item.IMenuBarModel)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 IBeanTableMenuContributionPlugin (org.jowidgets.cap.ui.api.plugin.IBeanTableMenuContributionPlugin)1 IWorkbenchMenuInterceptorPlugin (org.jowidgets.cap.ui.api.plugin.IWorkbenchMenuInterceptorPlugin)1 IPluginProperties (org.jowidgets.plugin.api.IPluginProperties)1 IPluginPropertiesBuilder (org.jowidgets.plugin.api.IPluginPropertiesBuilder)1 MenuBarModel (org.jowidgets.tools.model.item.MenuBarModel)1