static void addMenuComponent(final PageParameter pp) { final MenuBean menu = (MenuBean) pp.addComponentBean("AbstractHeaderPage_menu", MenuBean.class) .setMenuEvent(EMenuEvent.mouseenter) .setSelector(".re .acts .link_menuicon"); final AbstractElement<?>[] eles = new AbstractElement[] { ModuleContextFactory.get(IMyPortalWebContext.class).toMyPortalElement(pp), ModuleContextFactory.get(IFavoriteWebContext.class).toMyFavoriteElement(pp) }; for (final AbstractElement<?> ele : eles) { if (ele instanceof LinkElement) { final LinkElement link = (LinkElement) ele; if ("-".equals(link.getText())) { menu.addItem(MenuItem.sep()); } else { menu.addItem(MenuItem.of(link.getText()).setUrl(link.getHref())); } } } menu.addItem(MenuItem.sep()); menu.addItem( MenuItem.of($m("DemoTemplateT1.0")).setUrl(AbstractMVCPage.url(UserAttriPageT2.class))); }
@Override public MenuItems getContextMenu( final ComponentParameter cp, final MenuBean menuBean, final MenuItem menuItem) { if (menuItem == null) { final MenuItems items = MenuItems.of(); items.append(MenuItem.TBL_MOVE_UP("NewsFormAttachPage_move")); items.append(MenuItem.TBL_MOVE_UP2("NewsFormAttachPage_move")); items.append(MenuItem.TBL_MOVE_DOWN("NewsFormAttachPage_move")); items.append(MenuItem.TBL_MOVE_DOWN2("NewsFormAttachPage_move")); return items; } return null; }
@Override public MenuItems getMainMenuItems( final ComponentParameter cp, final MenuItem menuItem, final AbstractMVCPage templatePage) { final MenuItems al = MenuItems.of(); for (final IModuleContext ctx : ModuleContextFactory.allModules()) { final Module module = ctx.getModule(); MenuItem moduleItem = null; final ModuleFunction defaultFunction = ModuleFunction.getFunctionByName(module.getDefaultFunction()); if (defaultFunction instanceof WebModuleFunction) { if (!defaultFunction.isDisabled()) { moduleItem = MenuItem.of(defaultFunction.getText()) .setUrl(((WebModuleFunction) defaultFunction).getUrl()); } } else { moduleItem = MenuItem.of(module.getText()); } if (moduleItem != null) { final MenuItems children = moduleItem.children(); doSubItems(ctx, children, null, defaultFunction); if (StringUtils.hasText(moduleItem.getUrl()) || children.size() > 0) { al.add(moduleItem); } } } if (isShowMainMenuSeparator(cp)) { int i = 0, j = 0; final int c = al.size(); while (++i < c) { al.add(i + j++, MenuItem.sep()); } } return al; }
private void doSubItems( final IModuleContext ctx, final MenuItems children, final ModuleFunction parent, final ModuleFunction defaultFunction) { final ModuleFunctions functions = ctx.getFunctions(parent); if (functions != null) { for (final ModuleFunction function : functions) { if (function.isDisabled()) { continue; } if (!(function instanceof WebModuleFunction)) { continue; } if (defaultFunction != null && defaultFunction.equals(function)) { continue; } final MenuItem item = MenuItem.of(function.getText()).setUrl(((WebModuleFunction) function).getUrl()); children.add(item); doSubItems(ctx, item.children(), function, defaultFunction); } } }
@Override public ElementList getRightElements(final PageParameter pp) { final ProcessModelBean pm = WorkflowUtils.getProcessModel(pp); String params = null; if (pm != null) { params = "modelId=" + pm.getId(); } else { final String _gstr = pp.getParameter("pgroup"); if (StringUtils.hasText(_gstr)) { params = "pgroup=" + HttpUtils.encodeUrl(_gstr); } } final TabButtons tabs = TabButtons.of( new TabButton( $m("MyProcessWorksTPage.4"), uFactory.getUrl(pp, MyProcessWorksTPage.class, params))); final IWorkflowWebContext ctx = (IWorkflowWebContext) workflowContext; if (pp.isLmember(ctx.getProcessWorks_DeptRole(pp))) { final String url = uFactory.getUrl(pp, MyProcessWorks_DeptTPage.class, params); final StringBuilder txt = new StringBuilder(); PermissionDept dept = pp.getDept(ID.of(pp.getParameter("deptId"))); if (!dept.exists()) { dept = pp.getLdept(); } txt.append(dept); final List<PermissionDept> depts = pp.getLogin().depts(); if (depts.size() > 1) { final MenuBean menu = (MenuBean) pp.addComponentBean("MyProcessWorksTPage_depts_menu", MenuBean.class) .setMenuEvent(EMenuEvent.mouseenter) .setSelector(".MyProcessWorksTPage .tool_bar img.depts-menu"); final MenuItems items = menu.getMenuItems(); for (final PermissionDept _dept : depts) { if (_dept.equals(dept)) { continue; } items.add( MenuItem.of(_dept.getText()) .setOnclick( "$Actions.loc('" + HttpUtils.addParameters(url, "deptId=" + _dept.getId()) + "');")); } txt.append( new ImageElement( pp.getCssResourceHomePath(MyProcessWorksTPage.class) + "/images/down.png") .setClassName("depts-menu")); } tabs.append(new TabButton(txt, url)); } if (pp.isLmember(ctx.getProcessWorks_OrgRole(pp))) { tabs.append( new TabButton( $m("MyProcessWorksTPage.5"), uFactory.getUrl(pp, MyProcessWorks_OrgTPage.class, params))); } return ElementList.of(createTabsElement(pp, tabs)); }
@Override public MenuItems getContextMenu( final ComponentParameter cParameter, final MenuBean menuBean, final MenuItem menuItem) { if (menuItem == null) { final KVMap map = new KVMap() .add( "Add", MenuItem.of( menuBean, $m("Add"), MenuItem.ICON_ADD, "$category_action(item).add();")) .add( "Edit", MenuItem.of( menuBean, $m("Edit"), MenuItem.ICON_EDIT, "$category_action(item).edit();")) .add( "Delete", MenuItem.of( menuBean, $m("Delete"), MenuItem.ICON_DELETE, "$category_action(item).del();")) .add( "Refresh", MenuItem.of( menuBean, $m("Refresh"), MenuItem.ICON_REFRESH, "$category_action(item).refresh();")) .add( "Move", MenuItem.of(menuBean, $m("Menu.move")) .addChild( MenuItem.of( menuBean, $m("Menu.up"), MenuItem.ICON_UP, "$category_action(item).move(true, false);")) .addChild( MenuItem.of( menuBean, $m("Menu.up2"), MenuItem.ICON_UP2, "$category_action(item).move(true, true);")) .addChild( MenuItem.of( menuBean, $m("Menu.down"), MenuItem.ICON_DOWN, "$category_action(item).move(false, false);")) .addChild( MenuItem.of( menuBean, $m("Menu.down2"), MenuItem.ICON_DOWN2, "$category_action(item).move(false, true);"))) .add( "Expand", MenuItem.of( menuBean, $m("Tree.expand"), MenuItem.ICON_EXPAND, "$category_action(item).expand();")) .add( "Collapse", MenuItem.of( menuBean, $m("Tree.collapse"), MenuItem.ICON_COLLAPSE, "$category_action(item).collapse();")); final MenuItems items = MenuItems.of(); for (final String k : getContextMenuKeys()) { if ("-".equals(k)) { items.add(MenuItem.sep(menuBean)); } else { items.add((MenuItem) map.get(k)); } } return items; } return null; }