1 11 package org.eclipse.help.internal.webapp.data; 12 13 import java.util.*; 14 15 import javax.servlet.*; 16 import javax.servlet.http.*; 17 18 21 public class ToolbarData extends RequestData { 22 23 ToolbarButton[] buttons; 24 25 public ToolbarData(ServletContext context, HttpServletRequest request, 26 HttpServletResponse response) { 27 super(context, request, response); 28 loadButtons(); 29 } 30 31 35 public boolean hasMenu() { 36 for (int i=0;i<buttons.length;++i) { 37 if ("menu".equals(buttons[i].getAction())) { return true; 39 } 40 } 41 return false; 42 } 43 44 private void loadButtons() { 45 String [] names = request.getParameterValues("name"); String [] tooltips = request.getParameterValues("tooltip"); String [] images = request.getParameterValues("image"); String [] actions = request.getParameterValues("action"); String [] params = request.getParameterValues("param"); String [] states = request.getParameterValues("state"); 52 if (names == null || tooltips == null || images == null 53 || actions == null || params == null || states == null 54 || names.length != tooltips.length 55 || names.length != images.length 56 || names.length != actions.length 57 || names.length != params.length 58 || names.length != states.length) { 59 buttons = new ToolbarButton[0]; 60 return; 61 } 62 63 List buttonList = new ArrayList(); 64 for (int i = 0; i < names.length; i++) { 65 if ("".equals(names[i])) buttonList.add(new ToolbarButton()); 67 else 68 buttonList.add(new ToolbarButton(names[i], ServletResources 69 .getString(tooltips[i], request), preferences 70 .getImagesDirectory() 71 + "/" + images[i], actions[i], params[i], states[i])); 73 } 74 if (isIE() || isMozilla() 76 && "1.2.1".compareTo(getMozillaVersion()) <= 0 || (isSafari() && "120".compareTo(getSafariVersion()) <= 0)) { buttonList.add(new ToolbarButton("maximize_restore", getMaximizeTooltip(), preferences.getImagesDirectory() 80 + "/" + "maximize.gif", "restore_maximize", null, "off")); } 83 buttons = (ToolbarButton[]) buttonList 84 .toArray(new ToolbarButton[buttonList.size()]); 85 } 86 87 public ToolbarButton[] getButtons() { 88 return buttons; 89 } 90 91 public String getName() { 92 if (request.getParameter("view") == null) return ""; return request.getParameter("view"); } 96 97 public String getTitle() { 98 if (request.getParameter("view") == null) return ""; return ServletResources.getString(request.getParameter("view"), request); 102 } 103 104 public String getScript() { 105 return request.getParameter("script"); } 107 public String getMaximizeImage() { 108 return preferences.getImagesDirectory() + "/e_maximize.gif"; } 110 public String getRestoreImage() { 111 return preferences.getImagesDirectory() + "/e_restore.gif"; } 113 public String getMaximizeTooltip() { 114 return ServletResources.getString("maximize", request); } 116 public String getRestoreTooltip() { 117 return ServletResources.getString("restore", request); } 119 } 120 | Popular Tags |