Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/ToolbarData.java')
-rw-r--r--org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/ToolbarData.java119
1 files changed, 119 insertions, 0 deletions
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/ToolbarData.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/ToolbarData.java
new file mode 100644
index 000000000..0d251ab7c
--- /dev/null
+++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/ToolbarData.java
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.help.internal.webapp.data;
+
+import java.util.*;
+
+import javax.servlet.*;
+import javax.servlet.http.*;
+
+/**
+ * Control for a toolbar.
+ */
+public class ToolbarData extends RequestData {
+
+ ToolbarButton[] buttons;
+
+ public ToolbarData(ServletContext context, HttpServletRequest request,
+ HttpServletResponse response) {
+ super(context, request, response);
+ loadButtons();
+ }
+
+ /*
+ * Returns whether or not this toolbar has a menu button (has an arrow with drop
+ * down menu).
+ */
+ public boolean hasMenu() {
+ for (int i=0;i<buttons.length;++i) {
+ if ("menu".equals(buttons[i].getAction())) { //$NON-NLS-1$
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private void loadButtons() {
+ String[] names = request.getParameterValues("name"); //$NON-NLS-1$
+ String[] tooltips = request.getParameterValues("tooltip"); //$NON-NLS-1$
+ String[] images = request.getParameterValues("image"); //$NON-NLS-1$
+ String[] actions = request.getParameterValues("action"); //$NON-NLS-1$
+ String[] params = request.getParameterValues("param"); //$NON-NLS-1$
+ String[] states = request.getParameterValues("state"); //$NON-NLS-1$
+
+ if (names == null || tooltips == null || images == null
+ || actions == null || params == null || states == null
+ || names.length != tooltips.length
+ || names.length != images.length
+ || names.length != actions.length
+ || names.length != params.length
+ || names.length != states.length) {
+ buttons = new ToolbarButton[0];
+ return;
+ }
+
+ List buttonList = new ArrayList();
+ for (int i = 0; i < names.length; i++) {
+ if ("".equals(names[i])) //$NON-NLS-1$
+ buttonList.add(new ToolbarButton());
+ else
+ buttonList.add(new ToolbarButton(names[i], ServletResources
+ .getString(tooltips[i], request), preferences
+ .getImagesDirectory()
+ + "/" + images[i], //$NON-NLS-1$
+ actions[i], params[i], states[i]));
+ }
+ // add implicit maximize/restore button on all toolbars
+ if (isIE() || isMozilla()
+ && "1.2.1".compareTo(getMozillaVersion()) <= 0 //$NON-NLS-1$
+ || (isSafari() && "120".compareTo(getSafariVersion()) <= 0)) { //$NON-NLS-1$
+ buttonList.add(new ToolbarButton("maximize_restore", //$NON-NLS-1$
+ getMaximizeTooltip(), preferences.getImagesDirectory()
+ + "/" + "maximize.gif", //$NON-NLS-1$ //$NON-NLS-2$
+ "restore_maximize", null, "off")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ buttons = (ToolbarButton[]) buttonList
+ .toArray(new ToolbarButton[buttonList.size()]);
+ }
+
+ public ToolbarButton[] getButtons() {
+ return buttons;
+ }
+
+ public String getName() {
+ if (request.getParameter("view") == null) //$NON-NLS-1$
+ return ""; //$NON-NLS-1$
+ return request.getParameter("view"); //$NON-NLS-1$
+ }
+
+ public String getTitle() {
+ if (request.getParameter("view") == null) //$NON-NLS-1$
+ return ""; //$NON-NLS-1$
+ return ServletResources.getString(request.getParameter("view"), //$NON-NLS-1$
+ request);
+ }
+
+ public String getScript() {
+ return request.getParameter("script"); //$NON-NLS-1$
+ }
+ public String getMaximizeImage() {
+ return preferences.getImagesDirectory() + "/e_maximize.gif"; //$NON-NLS-1$
+ }
+ public String getRestoreImage() {
+ return preferences.getImagesDirectory() + "/e_restore.gif"; //$NON-NLS-1$
+ }
+ public String getMaximizeTooltip() {
+ return ServletResources.getString("maximize", request); //$NON-NLS-1$
+ }
+ public String getRestoreTooltip() {
+ return ServletResources.getString("restore", request); //$NON-NLS-1$
+ }
+}

Back to the top