Edit C:\galaxie\Back\galaxie\navigation\menubar\menubar.jsp
<%@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<SoftwareBean> software = context.getLicenceManager().getSoftwareBeans(); int nbSoft = 0; for (int i=0 ; i<software.size() ; i++) { SoftwareBean sfw = (SoftwareBean)software.elementAt(i); Vector sfwRoleHidden = null; try { sfwRoleHidden = (Vector)sfw.getSfwRoleHidden(); } catch (FieldNotInitializedException fnie) { } ActorBean actBean = ActorHelper.getSessionActor(session); Vector actRoles = null; try { actRoles = (Vector)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 (sfw.isSfwInactive() || sfw.isSfwHidden() || (isSfwRoleHidden)) { continue; } nbSoft++; } MenuBean menuBean = null; SoftwareBean swBean = null; String menuID = flRequest.getRequestParameterOrAttribute("mn"); if (menuID != null) { menuID = flRequest.getRequestParameterOrAttribute("MenID"); } String sfwID = flRequest.getRequestParameterOrAttribute("SfwID"); // First try the menu directly, and get sfwID from that if (menuID != null) { try { menuBean = new MenuBean(menuID, context); try { sfwID = menuBean.getMenSfwID(); } catch (FieldNotInitializedException fnie) { } swBean = new SoftwareBean(sfwID, context); } catch (Exception e) { menuBean = null; swBean = null; } } // Then try the getting the software and pulling the menu from there if (menuBean == null) { try { swBean = new SoftwareBean(sfwID, context); menuBean = menuManager.getMenu(actID, swBean.getID()); } catch (Exception e) { menuBean = null; swBean = null; } } // If we still don't have a menu, try getting it from the default stored in the session if (menuBean == null) { try { menuBean = new MenuBean((String) session.getAttribute("DefaultMenID"), context); swBean = new SoftwareBean(menuBean.getMenSfwID(), context); // Try to affect the first available software and visible for current actor } catch (Exception e) { Vector<SoftwareBean> 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 %> <link href="<fl:webapp/>/css/menubar_css.jsp?sfwCode=<%= sfwCode %>" rel="stylesheet" type="text/css"> <%-- 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 --%> <script language="javascript" type="text/javascript"> var menus = [ <% int xAxis = 90; int xAxisMenuelement = 0; int width, height; StringBuffer jsBuffer = new StringBuffer(); // First one is standard and doesn't change jsBuffer.append("new ypSlideOutMenu(\"menu1\", \"down\", 0, " + MENU_Y_POS); jsBuffer.append(", 91, " + ((NAVMENU_IMAGE_HEIGHT * nbSoft) + (6 + nbSoft)) + ")"); for (absIndex = 0; absIndex < nodes.size(); absIndex++) { menuNode = (MenuTreeNode) menuTree.elementAt(absIndex); nodeLabelDisplay = menuNode.getDisplayString(); jsBuffer.append(",\n"); // Creation of the slide out menu jsBuffer.append("new ypSlideOutMenu(\"menu" + (absIndex + 2)); jsBuffer.append("\", \"down\", "); // Figure out the xPos of the next menu item. Commentary from graphics dude: // // Pour var x : dépend du nombre de lettres de chaque intitulé. Sauf X1 qui est une image donc constant // X0=0 // X1=0+90 // X2=0+90+83+1 (+1 pr alignement sur ':') // X3=0+90+83+3+90+1 // X4=0+90+83+3+90+3+83+1 // X5=0+90+83+3+90+3+83+3+104+1 // X6=0+90+83+3+90+3+83+3+104+3+104+1 // X7=0+90+83+3+90+3+83+3+104+3+104+3+69+1 // X8=0+90+83+3+90+3+83+3+104+3+104+3+69+3+90+1 // X9=0+90+83+3+90+3+83+3+104+3+104+3+69+3+90+3+111+1 xAxisMenuelement = (nodeLabelDisplay.length() * 8) + 11; // Calculate the exact width xAxisMenuelement = 0; char currLetter; for (int charIndex = 0; charIndex < nodeLabelDisplay.length(); ++charIndex) { currLetter = nodeLabelDisplay.charAt(charIndex); if (!Character.isLowerCase(currLetter)) { xAxisMenuelement += MENU_CHARACTER_UPPER_WIDTH; } else { xAxisMenuelement += MENU_CHARACTER_LOWER_WIDTH; // Stupid non fixed point size fonts if (currLetter == 'i' || currLetter == 'l' || currLetter == '.' || currLetter == ',' || currLetter == 't' || currLetter == 'f' || currLetter == 'j' || currLetter == 'r' || currLetter == ' ') { xAxisMenuelement -= 2; } } } // for the space before and after. xAxisMenuelement += MENU_STRING_SPACER + 4; // Height of the menu if (menuNode.getChildCount() > 0) { height = (DROPMENU_ITEM_HEIGHT * menuNode.getChildCount()) + DROPMENU_FOOTER_HEIGHT; } else { height = 0; } // Width of the drop-down menu width = Math.max(((menuNode.getMaxMenuWidth() * DROPMENU_CHARWIDTH) + DROPMENU_PADDING), xAxisMenuelement); // X position (Just a running total), then add this menu's width for next menu jsBuffer.append(xAxis); jsBuffer.append(", " + MENU_Y_POS + ", " + width + ", " + height + ")"); // Add the width of this menu, which will serve as the xPos for the next menu xAxis += xAxisMenuelement; } %><%= jsBuffer.toString() %> ] /* for (var i = 0; i < menus.length; i++) { menus[i].onactivate = new Function("document.getElementById('act" + i + "').className='active';"); menus[i].ondeactivate = new Function("document.getElementById('act" + i + "').className='';"); } */ ypSlideOutMenu.writeCSS(); </script> <% StringBuffer bodyOnLoad = new StringBuffer(); int menuCount = 0; for (int i=0 ; i<software.size() ; i++) { SoftwareBean sfw = (SoftwareBean)software.elementAt(i); Vector sfwRoleHidden = null; try { sfwRoleHidden = (Vector)sfw.getSfwRoleHidden(); } catch (FieldNotInitializedException fnie) { } ActorBean actBean = ActorHelper.getSessionActor(session); Vector actRoles = null; try { actRoles = (Vector)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 (sfw.isSfwInactive() || sfw.isSfwHidden() || (isSfwRoleHidden)) { continue; } if (menuCount++ > 0) { bodyOnLoad.append(','); } String tmpSfwCode = "UNDEFINED"; try { tmpSfwCode = sfw.getSfwCode(); } catch (FieldNotInitializedException e) { } bodyOnLoad.append("'" + contextPath + "/icons/menu/" + tmpSfwCode + "/ddm_over.gif'"); } %> <script language="javascript" type="text/javascript"> MM_preloadImages(<%= bodyOnLoad.toString() %>); </script> <div id="menubar" class="menubar"> <a id="act0" style="position: absolute; left: 0px; width: 0px;" onmouseover="ypSlideOutMenu.showMenu('menu1');window.status=''; return true" onmouseout="ypSlideOutMenu.hideMenu('menu1')" href="#" style="cursor:default"> <img src="<fl:webapp/>/icons/menu/<%= sfwCode %>/ddm_active.gif" width="90" height="46" border="0"></A><% /**************************************************************** * Pour calculer spacer permettant de créer un espace chaque mot * et valeur à retenir pour le placement des sous menus (x) : * 1 majuscule=10px * 1 lettre ou espace=7px * espace droit ou gauche=5px * Par exemple, Annuaires : 10+(9x7)+(2x5)=83px *****************************************************************/ width = 90; for (absIndex = 0; absIndex < nodes.size(); absIndex++) { menuNode = (MenuTreeNode) menuTree.elementAt(absIndex); menuNode = (MenuTreeNode) menuTree.elementAt(absIndex); nodeLabelDisplay = menuNode.getDisplayString(); if (absIndex != 0) { %><img class="menubar_imagesep_pos" style="left: <%= width %>px;" src="<fl:webapp/>/icons/menu/separation_nav.gif"><% width += MENU_COLON_SPACER; } // Calculate the exact width for next column int largWord = 0; char currLetter; for (int charIndex = 0; charIndex < nodeLabelDisplay.length(); ++charIndex) { currLetter = nodeLabelDisplay.charAt(charIndex); if (!Character.isLowerCase(currLetter)) { largWord += MENU_CHARACTER_UPPER_WIDTH; } else { largWord += MENU_CHARACTER_LOWER_WIDTH; // Stupid non fixed point size fonts if (currLetter == 'i' || currLetter == 'l' || currLetter == '.' || currLetter == ',' || currLetter == 't' || currLetter == 'f' || currLetter == 'j' || currLetter == 'r' || currLetter == ' ') { largWord -= 2; } } } String nodeUrl = null; if (menuNode.isOpensNew()) { nodeUrl = "javascript:openNewWindow('" + Utils.formatToJavascript(flRequest.computeURL(menuNode.getUrl(), false, false, false)) + "')"; } else { nodeUrl = menuNode.getUrl(); } %><a class="menubar_link" id="act<%= (absIndex + 1) %>" style="position: absolute; top: <%= NAVMENU_TOP_HEIGHT %>px; left: <%= width %>px; right: <%= width + largWord %>px;width: <%= largWord %>px;" onmouseover="ypSlideOutMenu.showMenu('menu<%= (absIndex + 2) %>'); window.status=''; return true" onmouseout="ypSlideOutMenu.hideMenu('menu<%= (absIndex + 2) %>')" href="<%= nodeUrl %>"><div class="menubar_menutext" style="width: 100%;text-align: center"><%= nodeLabelDisplay %></div></a><% width += largWord; // for the space before and after. width += MENU_STRING_SPACER; } // end for (absIndex....) %></div> <!-- Fin barre navigation horizontale--> <!--Début sous menu Modules --> <iframe id="menu1Shim" name="menu1Shim" scrolling="no" frameborder="0" src="javascript:false"></iframe> <div id="menu1Container" style="top: <%= MENU_Y_POS %>px; z-index:10000; visibility: hidden;"> <div class="menumod" id="menu1Content"> <div class="options"> <table style="border-collapse: collapse; border-spacing: 0px"><% int menuImageYPos = 5;//0; int realMenuCount = 0; for (int i=0 ; i<software.size() ; i++) { SoftwareBean sfw = (SoftwareBean)software.elementAt(i); Vector sfwRoleHidden = null; try { sfwRoleHidden = (Vector)sfw.getSfwRoleHidden(); } catch (FieldNotInitializedException fnie) { } ActorBean actBean = ActorHelper.getSessionActor(session); Vector actRoles = null; try { actRoles = (Vector)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 (sfw.isSfwInactive() || sfw.isSfwHidden() || (isSfwRoleHidden)) { continue; } String fullTitle; String swName; try { if (sfw.isSfwDisplayNameIsCode()) { fullTitle = Utils.getMessage(session, sfw.getSfwDisplayName(), "Libellé indisponible"); } else { fullTitle = sfw.getSfwDisplayName(); } } catch (Exception e) { // If we don't have a menu name, go to the next one //TODO Do Log Here continue; } if (realMenuCount > 0) { menuImageYPos += NAVMENU_IMAGE_HEIGHT + 0; } ++realMenuCount; swName = fullTitle.replace(' ', '_').toLowerCase(); String tmpSfwCode = "UNDEFINED"; try { tmpSfwCode = sfw.getSfwCode(); } catch (FieldNotInitializedException e) { } // style="position: absolute; margin: 0px; border: none; padding: 0px; height: 20px;" %> <tr> <td style="position: absolute;left: -2px; top: <%= menuImageYPos %>px;"><a href="<fl:webapp/>/change_software.fl?SfwID=<%= sfw.getID() %>" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('nav_<%= swName %>','','<fl:webapp/>/icons/menu/<%= tmpSfwCode %>/ddm_over.gif',1)"><img src="<fl:webapp/>/icons/menu/<%= tmpSfwCode %>/ddm_out.gif" alt="<%= fullTitle %>" name="nav_<%= swName %>" border="0"></a></td> </tr><% } %> </table> </div> </div> </div> <%-- Menu containers --%> <% for (absIndex = 0; absIndex < nodes.size(); absIndex++) { node = (MenuElementBean)nodes.elementAt(absIndex); menuNode = (MenuTreeNode) menuTree.elementAt(absIndex); %> <iframe id="menu<%= (absIndex + 2)%>Shim" name="menu<%= (absIndex + 2)%>Shim" scrolling="no" frameborder="0" src="javascript:false"></iframe> <div id="menu<%= (absIndex + 2)%>Container"> <div class="menu" id="menu<%= (absIndex + 2) %>Content"> <div> <% if (!menuNode.isLeaf()) { Enumeration enumera = menuNode.children(); %><table style="border-collapse: collapse;"><% while (enumera.hasMoreElements()) { leafNode = (MenuTreeNode) enumera.nextElement(); %> <tr class="options" <% if (leafNode.isOpensNew()) { %> onmousedown="openNewWindow('<fl:link menu="true" list="false" url="<%= leafNode.getUrl() %>" webapp="false"/>');" <% } else { %> onmousedown="window.location='<fl:link menu="true" list="false" url="<%= leafNode.getUrl() %>" webapp="false"/>'" <% } %> onmouseout="this.style.backgroundColor='#ffffff'" onmouseover="this.style.backgroundColor='#C9D1ED'"> <td class="menubar_dropdown_left"></td> <td><%= leafNode.getDisplayString() %></td> <td class="menubar_dropdown_right"></td> </tr><% } %> <tr> <td style="width: 7px; padding: 0px;"><img src="<fl:webapp/>/icons/menu/<%= sfwCode %>/ddm_lower_left.gif"></td> <td class="menubar_dropdown_footer"></td> <td style="width: 7px; padding: 0px;"><img src="<fl:webapp/>/icons/menu/<%= sfwCode %>/ddm_lower_right.gif"></td> </tr> </table><% } %> </div> </div> </div> <% } %>
Ms-Dos/Windows
Unix
Write backup
jsp File Browser version 1.2 by
www.vonloesch.de