javax.help.ServletHelpBroker Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javahelp Show documentation
Show all versions of javahelp Show documentation
The JavaHelp API provides a platform-independent help framework.
The newest version!
/*
* @(#)ServletHelpBroker.java 1.3 06/10/30
*
* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package javax.help;
import java.util.Enumeration;
import java.util.Hashtable;
import java.net.URL;
import java.net.MalformedURLException;
import java.awt.*;
import java.awt.event.*;
import javax.help.Map.ID;
import java.util.Locale;
import java.awt.Font;
import java.awt.Dimension;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspWriter;
import javax.swing.tree.DefaultMutableTreeNode;
import java.io.IOException;
/**
* An implmentation of the HelpBroker interface for Servlets
*
* @author Roger Brinkley
* @version 1.3 10/30/06
*/
public class ServletHelpBroker implements HelpBroker {
protected HelpSet helpset = null;
protected DefaultHelpModel model = null;
protected NavigatorView curNav = null;
protected boolean viewDisplayed = true;
protected Locale locale=null;
protected Font font;
/**
* Zero-argument constructor.
* It should be followed by a setHelpSet() invocation.
*/
public ServletHelpBroker() {
}
/**
* Returns the default HelpSet
*/
public HelpSet getHelpSet() {
return helpset;
}
/**
* Changes the HelpSet for this broker.
* @param hs The HelpSet to set for this broker.
* A null hs is valid parameter.
*/
public void setHelpSet(HelpSet hs) {
if (hs != null && helpset != hs) {
model = new DefaultHelpModel(hs);
helpset = hs;
}
}
/**
* Gets the locale of this component.
* @return This component's locale. If this component does not
* have a locale, the defaultLocale is returned.
* @see #setLocale
*/
public Locale getLocale() {
if (locale == null) {
return Locale.getDefault();
}
return locale;
}
/**
* Sets the locale of this HelpBroker. The locale is propagated to
* the presentation.
* @param l The locale to become this component's locale. A null locale
* is the same as the defaultLocale.
* @see #getLocale
*/
public void setLocale(Locale l) {
locale = l;
}
/**
* Gets the font for this HelpBroker.
*/
public Font getFont () {
return font;
}
/**
* Sets the font for this this HelpBroker.
* @param f The font.
*/
public void setFont (Font f) {
font = f;
}
/**
* Set the currentView to the navigator with the same
* name as the name parameter.
*
* @param name The name of the navigator to set as the
* current view. If nav is null or not a valid Navigator
* in this HelpBroker then an
* IllegalArgumentException is thrown.
* @throws IllegalArgumentException if nav is null or not a valid Navigator.
*/
public void setCurrentView(String name) {
NavigatorView views[] = helpset.getNavigatorViews();
for (int i=0; i