|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectfedora.swing.jhelp.SimpleHelpBroker
public class SimpleHelpBroker
Title: SimpleHelpBroker.java
Description:
An impelmentation of the HelpBroker interface.
This is based on DefaultHelpBroker v1.33 (01/25/99) that
comes with JavaHelp, originally written by Roger Brinkley and Eduardo
Pelegri-Llopart.
JavaHelp comes with Java, and is written by Sun Microsystems.
More information on JavaHelp can be found at
http://java.sun.com/products/javahelp/faq.html
I've added a new constructor, which takes an Image (the icon you want to
use for the window), and also a little more intelligent size tracking.
When you close the presentation, it remembers the old size, so subsequent
opens look the same.
There is a lot of extra stuff (like support for java 1.1) where I don't
fully understand what they were doing and what variables they're passing
around and whatnot, but it seems to work fine, and it does what I want
for now, so I'm not gonna futz with it except for adding functionality
as needed.
Also, in createJHelp, this class configures the JHelp such that the content
viewer UI (the panel where the html is displayed) is a
SimpleContentViewerUI instead of a BasicContentViewerUI.
See SimpleContentViewerUI javadoc for why it's better.
----------------------------------------------------------------------------- Portions created by Sun Microsystems are Copyright © Sun Microsystems, originally made available at java.sun.com
-----------------------------------------------------------------------------
| Field Summary | |
|---|---|
protected javax.swing.JDialog |
dialog
The container for modally activated help |
protected java.awt.event.ActionListener |
displayHelpFromFocus
|
protected java.awt.event.ActionListener |
displayHelpFromSource
|
protected java.awt.Font |
font
|
protected javax.swing.JFrame |
frame
|
protected javax.help.HelpSet |
helpset
|
protected javax.help.JHelp |
jhelp
|
protected java.util.Locale |
locale
|
protected boolean |
modallyActivated
The flag for modally activated help. |
protected java.awt.Window |
ownerWindow
The modal Window that activated help |
| Constructor Summary | |
|---|---|
SimpleHelpBroker()
Zero-argument constructor. |
|
SimpleHelpBroker(javax.help.HelpSet hs)
Constructor |
|
SimpleHelpBroker(javax.help.HelpSet hs,
java.awt.Image iconImage)
|
|
| Method Summary | |
|---|---|
void |
enableHelp(java.awt.Component comp,
java.lang.String id,
javax.help.HelpSet hs)
Enables help for a Component. |
void |
enableHelp(java.awt.MenuItem comp,
java.lang.String id,
javax.help.HelpSet hs)
Enables help for a MenuItem. |
void |
enableHelpKey(java.awt.Component comp,
java.lang.String id,
javax.help.HelpSet hs)
Enables the Help key on a Component. |
void |
enableHelpKey(java.awt.Component arg0,
java.lang.String arg1,
javax.help.HelpSet arg2,
java.lang.String arg3,
java.lang.String arg4)
|
void |
enableHelpOnButton(java.awt.Component comp,
java.lang.String id,
javax.help.HelpSet hs)
Enables help for a Component. |
void |
enableHelpOnButton(java.awt.MenuItem comp,
java.lang.String id,
javax.help.HelpSet hs)
Enables help for a MenuItem. |
void |
enableHelpOnButton(java.lang.Object arg0,
java.lang.String arg1,
javax.help.HelpSet arg2,
java.lang.String arg3,
java.lang.String arg4)
|
void |
ensureContentPanelDrawn(javax.help.Map.ID id)
|
javax.help.Map.ID |
getCurrentID()
Determines which ID is displayed (if any). |
java.net.URL |
getCurrentURL()
Determines which URL is displayed. |
java.lang.String |
getCurrentView()
Determines the current navigator. |
protected java.awt.event.ActionListener |
getDisplayHelpFromFocus()
Returns the default DisplayHelpFromFocus listener. |
protected java.awt.event.ActionListener |
getDisplayHelpFromSource()
Returns the default DisplayHelpFromSource listener. |
java.awt.Font |
getFont()
Gets the font for this HelpBroker. |
javax.help.HelpSet |
getHelpSet()
Returns the default HelpSet |
java.util.Locale |
getLocale()
Gets the locale of this component. |
java.awt.Point |
getLocation()
Requests the location of the presentation. |
java.awt.Dimension |
getSize()
Requests the size of the presentation. |
void |
initPresentation()
Initializes the presentation. |
boolean |
isDisplayed()
Determines if the presentation is displayed. |
boolean |
isViewDisplayed()
Determines if the current view is visible. |
void |
keyPressed(java.awt.event.KeyEvent e)
Invoked when a key is pressed. |
void |
keyReleased(java.awt.event.KeyEvent e)
Invoked when a key is released. |
void |
keyTyped(java.awt.event.KeyEvent e)
Invoked when a key is typed. |
void |
setActivationWindow(java.awt.Window window)
Set the activation window. |
void |
setCurrentID(javax.help.Map.ID id)
Displays this ID--HelpVisitListeners are notified. |
void |
setCurrentID(java.lang.String id)
Shows this ID as content relative to the (top) HelpSet for the HelpBroker instance--HelpVisitListeners are notified. |
void |
setCurrentURL(java.net.URL url)
Displays this URL. |
void |
setCurrentView(java.lang.String name)
Set the currentView to the navigator with the same name as the name parameter. |
void |
setDisplayed(boolean b)
Displays the presentation to the user. |
void |
setFont(java.awt.Font f)
Sets the font for this this HelpBroker. |
void |
setHelpSet(javax.help.HelpSet hs)
Changes the HelpSet for this broker. |
void |
setHelpSetPresentation(javax.help.HelpSet.Presentation arg0)
|
void |
setLocale(java.util.Locale l)
Sets the locale of this HelpBroker. |
void |
setLocation(java.awt.Point p)
Requests the presentation be located at a given position. |
void |
setPosition(java.awt.Point p)
|
void |
setSize(java.awt.Dimension d)
Requests the presentation be set to a given size. |
void |
setViewDisplayed(boolean displayed)
Hides/Shows view. |
void |
showID(javax.help.Map.ID arg0,
java.lang.String arg1,
java.lang.String arg2)
|
void |
showID(java.lang.String arg0,
java.lang.String arg1,
java.lang.String arg2)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected javax.help.HelpSet helpset
protected javax.swing.JFrame frame
protected javax.help.JHelp jhelp
protected java.util.Locale locale
protected java.awt.Font font
protected javax.swing.JDialog dialog
protected java.awt.Window ownerWindow
protected boolean modallyActivated
protected java.awt.event.ActionListener displayHelpFromFocus
protected java.awt.event.ActionListener displayHelpFromSource
| Constructor Detail |
|---|
public SimpleHelpBroker(javax.help.HelpSet hs)
public SimpleHelpBroker(javax.help.HelpSet hs,
java.awt.Image iconImage)
public SimpleHelpBroker()
| Method Detail |
|---|
public javax.help.HelpSet getHelpSet()
getHelpSet in interface javax.help.HelpBrokerpublic void setHelpSet(javax.help.HelpSet hs)
setHelpSet in interface javax.help.HelpBrokerhs - The HelpSet to set for this broker.
A null hs is valid parameter.public java.util.Locale getLocale()
getLocale in interface javax.help.HelpBrokersetLocale(java.util.Locale)public void setLocale(java.util.Locale l)
setLocale in interface javax.help.HelpBrokerl - The locale to become this component's locale. A null locale
is the same as the defaultLocale.getLocale()public java.awt.Font getFont()
getFont in interface javax.help.HelpBrokerpublic void setFont(java.awt.Font f)
setFont in interface javax.help.HelpBrokerf - The font.public void setPosition(java.awt.Point p)
public void setCurrentView(java.lang.String name)
setCurrentView in interface javax.help.HelpBrokername - 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.
java.lang.IllegalArgumentException - if nav is null or not a valid Navigator.public java.lang.String getCurrentView()
getCurrentView in interface javax.help.HelpBrokerpublic void initPresentation()
initPresentation in interface javax.help.HelpBrokerpublic void setDisplayed(boolean b)
setDisplayed in interface javax.help.HelpBrokerpublic boolean isDisplayed()
isDisplayed in interface javax.help.HelpBrokerpublic void setLocation(java.awt.Point p)
setLocation in interface javax.help.HelpBrokerpublic java.awt.Point getLocation()
getLocation in interface javax.help.HelpBrokerjavax.help.UnsupportedOperationException - If the underlying implementation
does not allow this.
IllegalComponentStateExcetpion - If the presentation is not
displayed.public void setSize(java.awt.Dimension d)
setSize in interface javax.help.HelpBrokerpublic java.awt.Dimension getSize()
getSize in interface javax.help.HelpBrokerjavax.help.UnsupportedOperationException - If the underlying implementation
does not allow this.
IllegalComponentStateExcetpion - If the presentation is not
displayed.public void setViewDisplayed(boolean displayed)
setViewDisplayed in interface javax.help.HelpBrokerpublic boolean isViewDisplayed()
isViewDisplayed in interface javax.help.HelpBroker
public void setCurrentID(java.lang.String id)
throws javax.help.BadIDException
setCurrentID in interface javax.help.HelpBrokerid - A string that identifies the topic to show for the loaded (top) HelpSet
javax.help.BadIDException - The ID is not valid for the HelpSet
public void setCurrentID(javax.help.Map.ID id)
throws javax.help.InvalidHelpSetContextException
setCurrentID in interface javax.help.HelpBrokerid - a Map.ID indicating the URL to display
javax.help.InvalidHelpSetContextException - if the current helpset does not contain
id.helpsetpublic javax.help.Map.ID getCurrentID()
getCurrentID in interface javax.help.HelpBrokerpublic void setCurrentURL(java.net.URL url)
setCurrentURL in interface javax.help.HelpBrokerurl - The url to display. A null URL is a valid url.public java.net.URL getCurrentURL()
getCurrentURL in interface javax.help.HelpBroker
public void enableHelpKey(java.awt.Component comp,
java.lang.String id,
javax.help.HelpSet hs)
enableHelpKey in interface javax.help.HelpBrokercomp - the Component to enable the keyboard actions on.id - the default HelpID to be displayedhs - the default HelpSet to be displayed. If hs is null the default HelpSet
will be assumed.getHelpKeyActionListenerpublic void keyTyped(java.awt.event.KeyEvent e)
keyTyped in interface java.awt.event.KeyListenerpublic void keyPressed(java.awt.event.KeyEvent e)
keyPressed in interface java.awt.event.KeyListenerpublic void keyReleased(java.awt.event.KeyEvent e)
keyReleased in interface java.awt.event.KeyListener
public void enableHelp(java.awt.Component comp,
java.lang.String id,
javax.help.HelpSet hs)
enableHelp in interface javax.help.HelpBrokercomp - the Component to set the id and hs on.id - the String value of an Map.ID.hs - the HelpSet the id is in. If hs is null the default HelpSet
will be assumed.CSH.setHelpID,
CSH.setHelpSet
public void enableHelp(java.awt.MenuItem comp,
java.lang.String id,
javax.help.HelpSet hs)
enableHelp in interface javax.help.HelpBrokercomp - the MenuItem to set the id and hs on.id - the String value of an Map.ID.hs - the HelpSet the id is in. If hs is null the default HelpSet
will be assumed.CSH.setHelpID,
CSH.setHelpSet
public void enableHelpOnButton(java.awt.Component comp,
java.lang.String id,
javax.help.HelpSet hs)
enableHelpOnButton in interface javax.help.HelpBrokercomp - the Component to set the id and hs on. If the Component is not
a javax.swing.AbstractButton or a
java.awt.Button an IllegalArgumentException is thrown.id - the String value of an Map.ID.hs - the HelpSet the id is in. If hs is null the default HelpSet
will be assumed.
java.lang.IllegalArgumentException - if comp is null.CSH.setHelpID,
CSH.setHelpSet,
AbstractButton,
Button
public void enableHelpOnButton(java.awt.MenuItem comp,
java.lang.String id,
javax.help.HelpSet hs)
enableHelpOnButton in interface javax.help.HelpBrokercomp - the MenuItem to set the id and hs on. If comp is null
an IllegalAgrumentException is thrown.id - the String value of an Map.ID.hs - the HelpSet the id is in. If hs is null the default HelpSet
will be assumed.
java.lang.IllegalArgumentException - if comp is null.CSH.setHelpID,
CSH.setHelpSet,
MenuItemprotected java.awt.event.ActionListener getDisplayHelpFromFocus()
enableHelpKeyprotected java.awt.event.ActionListener getDisplayHelpFromSource()
enableHelppublic void setActivationWindow(java.awt.Window window)
window - the activating windowpublic void ensureContentPanelDrawn(javax.help.Map.ID id)
public void setHelpSetPresentation(javax.help.HelpSet.Presentation arg0)
setHelpSetPresentation in interface javax.help.HelpBroker
public void showID(javax.help.Map.ID arg0,
java.lang.String arg1,
java.lang.String arg2)
throws javax.help.InvalidHelpSetContextException
showID in interface javax.help.HelpBrokerjavax.help.InvalidHelpSetContextException
public void showID(java.lang.String arg0,
java.lang.String arg1,
java.lang.String arg2)
throws javax.help.BadIDException
showID in interface javax.help.HelpBrokerjavax.help.BadIDException
public void enableHelpKey(java.awt.Component arg0,
java.lang.String arg1,
javax.help.HelpSet arg2,
java.lang.String arg3,
java.lang.String arg4)
enableHelpKey in interface javax.help.HelpBroker
public void enableHelpOnButton(java.lang.Object arg0,
java.lang.String arg1,
javax.help.HelpSet arg2,
java.lang.String arg3,
java.lang.String arg4)
throws java.lang.IllegalArgumentException
enableHelpOnButton in interface javax.help.HelpBrokerjava.lang.IllegalArgumentException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||