<%@page session="true" import="com.edeal.frontline.*, java.util.*"%><%@ page import="javax.swing.tree.DefaultTreeModel" %><%@ page import="com.edeal.frontline.helper.custom.ActorHelper" %><%@ page import="com.edeal.frontline.MenuTreeNode" %><%@ page import="java.util.Hashtable" %><%@ page import="com.edeal.frontline.FieldNotInitializedException" %><%@ page import="com.edeal.frontline.MenuManager" %><%@ page import="com.edeal.frontline.navigation.FlRequest" %><%@taglib uri="http://www.e-deal.com/taglib/fl" prefix="fl" %><% String contextPath = (String)session.getAttribute("contextPath"); MenuManager menuManager = context.getMenuManager(); Vector software = context.getLicenceManager().getSoftwareBeans(); int nbSoft = 0; for (int i=0 ; i softwareBeans = flRequest.getContext().getLicenceManager().getSoftwareBeans(); for (SoftwareBean softwareBean : softwareBeans) { Vector sfwRoleHidden = null; try { sfwRoleHidden = (Vector)softwareBean.getSfwRoleHidden(); } catch (FieldNotInitializedException fnie) { } ActorBean actBean = ActorHelper.getSessionActor(session); Vector actRoles = null; try { actRoles = actBean.getActRoles(); } catch (FieldNotInitializedException fnie) { } Boolean isSfwRoleHidden = true; if (sfwRoleHidden != null && actRoles != null) { for (int j = 0; j < actRoles.size(); j++) { if (!sfwRoleHidden.contains(actRoles.elementAt(j))) { // if at least one of my role allows me to see a software so I can see it isSfwRoleHidden = false; break; } } } else { isSfwRoleHidden = false; } if (softwareBean.isSfwInactive() || softwareBean.isSfwHidden() || (isSfwRoleHidden)) { continue; } swBean = softwareBean; menuBean = menuManager.getMenu(actID, swBean.getID()); flRequest.setAttribute("SfwID", softwareBean.getSfwID()); break; } } } // If we STILL don't have a menu, just do the sales menu. If this doesn't exist, we have bigger problems if (menuBean == null) { swBean = (SoftwareBean)software.elementAt(0); menuBean = menuManager.getMenu(actID, swBean.getID()); } Vector nodes = menuManager.getNodesByMenu(menuBean.getID()); Vector leaves = menuManager.getLeavesByMenu(menuBean.getID()); // These variables are used throughout the jsp as temporary variables MenuElementBean node; String nodeID; String nodeLabelDisplay; String leafLabelDisplay; String iconName = ""; String link = ""; MenuTreeNode menuNode; MenuTreeNode leafNode; int leavesIndex = 0; int absIndex; // Constants used in menu creation and spacing final int MENU_CHARACTER_UPPER_WIDTH = 10; final int MENU_CHARACTER_LOWER_WIDTH = 9; final int MENU_Y_POS = 32; final int MENU_STRING_SPACER = 10; final int MENU_COLON_SPACER = 5; final int NAVMENU_IMAGE_HEIGHT = 40; final int NAVMENU_TOP_HEIGHT = 11; final int DROPMENU_ITEM_HEIGHT = 20; final int DROPMENU_FOOTER_HEIGHT = 5; // It was 7 but a bit too high. changed to 5 (JSA) final int DROPMENU_PADDING = 25; final int DROPMENU_CHARWIDTH = 5; // The name of the menu, used for backgrounds, images, etc String softwareName = Utils.getMessage(session, menuBean.getMenTitle(), "Sales"); softwareName = softwareName.replace(' ', '_').toLowerCase(); String sfwCode = ""; try { sfwCode = swBean.getSfwCode(); } catch (FieldNotInitializedException e) { } if (sfwCode.equals("")) { sfwCode = "UNDEFINED"; } // Create our menu tree now, as we'll need it throughout for sizing references Vector menuTree = new Vector(); for (absIndex = 0; absIndex < nodes.size(); absIndex++) { int maxChars = 0; node = (MenuElementBean)nodes.elementAt(absIndex); menuNode = new MenuTreeNode(); try { nodeLabelDisplay = node.isMelLabelIsCode() ? Utils.getMessage(session, node.getMelLabel(), false, true, "Libellé indisponible") : node.getMelLabel(); } catch (FieldNotInitializedException e) { nodeLabelDisplay = "Undefined" + (absIndex + 1); } menuNode.setDisplayString(nodeLabelDisplay); try { menuNode.setIconName(node.getMelIconName()); } catch (FieldNotInitializedException e) { } try { menuNode.setOpensNew(node.isMelOpensNew()); } catch (FieldNotInitializedException e) { } try { String url = node.getMelLink(); if (! url.startsWith("http")) { url = flRequest.computeURL(url); } menuNode.setUrl(url); } catch (FieldNotInitializedException e) { } // Recuperate sub menu urls, icons, etc for this menu while (leavesIndex < leaves.size()) { leafNode = new MenuTreeNode(); MenuElementBean leaf = (MenuElementBean)leaves.elementAt(leavesIndex); String leafParentID = null; try { leafParentID = leaf.getMelParentID(); } catch (FieldNotInitializedException e) { } //if this leaf belongs to current node, add it if (leafParentID.equals(node.getID())) { try { leafLabelDisplay = leaf.isMelLabelIsCode() ? Utils.getMessage(session, leaf.getMelLabel(), false, true, "Libellé indisponible") : leaf.getMelLabel(); } catch (FieldNotInitializedException e) { leafLabelDisplay = "Undefined " + leavesIndex; } leafNode.setDisplayString(leafLabelDisplay); try { leafNode.setIconName(leaf.getMelIconName()); } catch (FieldNotInitializedException e) { } try { String url = leaf.getMelLink(); if (! url.startsWith("http")) { url = contextPath + url; } leafNode.setUrl(url); } catch (FieldNotInitializedException e) { } try { leafNode.setOpensNew(leaf.isMelOpensNew()); } catch (FieldNotInitializedException e) { } maxChars = Math.max(maxChars, leafLabelDisplay.length()); menuNode.add(leafNode); leavesIndex++; } else { break; } } //end of while on leaves menuNode.setMaxMenuWidth(maxChars); menuTree.add(menuNode); } // end of menu creation %> <%-- les claques sous menus : Pour var larg : fonction du nombre de lettre du plus grand intitulé. 1 lettre ou espace = 5 px lorsque l'intitulé est supérieur à 15 lettres et 6 px si inférieur D'où un mot de 20 lettres aura une une lageur d'environs 114px. On arrondit au pixel supérieur si décimal. La largeur de la table sera 7(image bordure tableau)+84+7(image bordure tableau)=114px Si la largeur trouvée est inféreure à la largeur du spacer contenu dans la cellule au dessus de l'intitulé alors on utilise la largeur du spacer+(2*3px). --%> <%-- JavaScript Menu Object Creation --%> <% StringBuffer bodyOnLoad = new StringBuffer(); int menuCount = 0; for (int i=0 ; i 0) { bodyOnLoad.append(','); } String tmpSfwCode = "UNDEFINED"; try { tmpSfwCode = sfw.getSfwCode(); } catch (FieldNotInitializedException e) { } bodyOnLoad.append("'" + contextPath + "/icons/menu/" + tmpSfwCode + "/ddm_over.gif'"); } %> <%-- Menu containers --%> <% for (absIndex = 0; absIndex < nodes.size(); absIndex++) { node = (MenuElementBean)nodes.elementAt(absIndex); menuNode = (MenuTreeNode) menuTree.elementAt(absIndex); %> <% } %>