Package javax.help
Class DefaultHelpBroker
- java.lang.Object
-
- javax.help.DefaultHelpBroker
-
- All Implemented Interfaces:
java.awt.event.KeyListener,java.util.EventListener,HelpBroker
public class DefaultHelpBroker extends java.lang.Object implements HelpBroker, java.awt.event.KeyListener
An implmentation of the HelpBroker interface
-
-
Field Summary
Fields Modifier and Type Field Description protected java.awt.event.ActionListenerdisplayHelpFromFocusprotected java.awt.event.ActionListenerdisplayHelpFromSource
-
Constructor Summary
Constructors Constructor Description DefaultHelpBroker()Zero-argument constructor.DefaultHelpBroker(HelpSet hs)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidenableHelp(java.awt.Component comp, java.lang.String id, HelpSet hs)Enables help for a Component.voidenableHelp(java.awt.MenuItem comp, java.lang.String id, HelpSet hs)Enables help for a MenuItem.voidenableHelpKey(java.awt.Component comp, java.lang.String id, HelpSet hs)Enables the Help key on a Component.voidenableHelpKey(java.awt.Component comp, java.lang.String id, HelpSet hs, java.lang.String presentation, java.lang.String presentationName)Enables the Help key on a Component.voidenableHelpOnButton(java.awt.Component comp, java.lang.String id, HelpSet hs)Enables help for a Component.voidenableHelpOnButton(java.awt.MenuItem comp, java.lang.String id, HelpSet hs)Enables help for a MenuItem.voidenableHelpOnButton(java.lang.Object obj, java.lang.String id, HelpSet hs, java.lang.String presentation, java.lang.String presentationName)Enables help for a Component.Map.IDgetCurrentID()Determines which ID is displayed (if any).java.net.URLgetCurrentURL()Determines which URL is displayed.java.lang.StringgetCurrentView()Determines the current navigator.protected java.awt.event.ActionListenergetDisplayHelpFromFocus()Returns the default DisplayHelpFromFocus listener.protected java.awt.event.ActionListenergetDisplayHelpFromSource()Returns the default DisplayHelpFromSource listener.java.awt.FontgetFont()Gets the font for this HelpBroker.HelpSetgetHelpSet()Returns the default HelpSetjava.util.LocalegetLocale()Gets the locale of this component.java.awt.PointgetLocation()Requests the location of the presentation.intgetScreen()Requests the screen of the presentation.java.awt.DimensiongetSize()Requests the size of the presentation.WindowPresentationgetWindowPresentation()Get the WindowPresentation for this HelpBrokervoidinitPresentation()Initializes the presentation.booleanisDisplayed()Determines if the presentation is displayed.booleanisViewDisplayed()Determines if the current view is visible.voidkeyPressed(java.awt.event.KeyEvent e)Invoked when a key is pressed.voidkeyReleased(java.awt.event.KeyEvent e)Invoked when a key is released.voidkeyTyped(java.awt.event.KeyEvent e)Invoked when a key is typed.voidsetActivationObject(java.lang.Object comp)Set the activation window from given Component or MenuItem.voidsetActivationWindow(java.awt.Window window)Set the activation window.voidsetCurrentID(java.lang.String id)Shows this ID as content relative to the (top) HelpSet for the HelpBroker instance--HelpVisitListeners are notified.voidsetCurrentID(Map.ID id)Displays this ID--HelpVisitListeners are notified.voidsetCurrentURL(java.net.URL url)Displays this URL.voidsetCurrentView(java.lang.String name)Set the currentView to the navigator with the same name as the name parameter.voidsetDisplayed(boolean b)Displays the presentation to the user.voidsetFont(java.awt.Font f)Sets the font for this this HelpBroker.voidsetHelpSet(HelpSet hs)Changes the HelpSet for this broker.voidsetHelpSetPresentation(HelpSet.Presentation hsPres)Set the presentation attributes from a HelpSet.Presentation.voidsetLocale(java.util.Locale l)Sets the locale of this HelpBroker.voidsetLocation(java.awt.Point p)Requests the presentation be located at a given position.voidsetScreen(int screen)Requests the presentation be set to a given screen.voidsetSize(java.awt.Dimension d)Requests the presentation be set to a given size.voidsetViewDisplayed(boolean displayed)Hides/Shows view.voidshowID(java.lang.String id, java.lang.String presentation, java.lang.String presentationName)Shows this ID.voidshowID(Map.ID id, java.lang.String presentation, java.lang.String presentationName)Show this ID.
-
-
-
Constructor Detail
-
DefaultHelpBroker
public DefaultHelpBroker(HelpSet hs)
Constructor
-
DefaultHelpBroker
public DefaultHelpBroker()
Zero-argument constructor. It should be followed by a setHelpSet() invocation.
-
-
Method Detail
-
getWindowPresentation
public WindowPresentation getWindowPresentation()
Get the WindowPresentation for this HelpBroker
-
getHelpSet
public HelpSet getHelpSet()
Returns the default HelpSet- Specified by:
getHelpSetin interfaceHelpBroker- Returns:
- The HelpSet this JavaHelp is presenting.
-
setHelpSet
public void setHelpSet(HelpSet hs)
Changes the HelpSet for this broker.- Specified by:
setHelpSetin interfaceHelpBroker- Parameters:
hs- The HelpSet to set for this broker. A null hs is valid parameter.
-
setHelpSetPresentation
public void setHelpSetPresentation(HelpSet.Presentation hsPres)
Set the presentation attributes from a HelpSet.Presentation. The HelpSet.Presentation must be in the current HelpSet.- Specified by:
setHelpSetPresentationin interfaceHelpBroker- Parameters:
hsPres- The HelpSet.Presentation- Since:
- 2.0
-
getLocale
public java.util.Locale getLocale()
Gets the locale of this component.- Specified by:
getLocalein interfaceHelpBroker- Returns:
- This component's locale. If this component does not have a locale, the defaultLocale is returned.
- See Also:
setLocale(java.util.Locale)
-
setLocale
public void setLocale(java.util.Locale l)
Sets the locale of this HelpBroker. The locale is propagated to the presentation.- Specified by:
setLocalein interfaceHelpBroker- Parameters:
l- The locale to become this component's locale. A null locale is the same as the defaultLocale.- See Also:
getLocale()
-
getFont
public java.awt.Font getFont()
Gets the font for this HelpBroker.- Specified by:
getFontin interfaceHelpBroker
-
setFont
public void setFont(java.awt.Font f)
Sets the font for this this HelpBroker.- Specified by:
setFontin interfaceHelpBroker- Parameters:
f- The font.
-
setCurrentView
public void setCurrentView(java.lang.String name)
Set the currentView to the navigator with the same name as the name parameter.- Specified by:
setCurrentViewin interfaceHelpBroker- Parameters:
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:
java.lang.IllegalArgumentException- if nav is null or not a valid Navigator.
-
getCurrentView
public java.lang.String getCurrentView()
Determines the current navigator.- Specified by:
getCurrentViewin interfaceHelpBroker- Returns:
- The name of the current navigational view.
-
initPresentation
public void initPresentation()
Initializes the presentation. This method allows the presentation to be initialized but not displayed. Typically this would be done in a separate thread to reduce the intialization time.- Specified by:
initPresentationin interfaceHelpBroker
-
setDisplayed
public void setDisplayed(boolean b)
Displays the presentation to the user.- Specified by:
setDisplayedin interfaceHelpBroker- Parameters:
b- Makes the presentation visible or not.
-
isDisplayed
public boolean isDisplayed()
Determines if the presentation is displayed.- Specified by:
isDisplayedin interfaceHelpBroker- Returns:
- Whether the presentation is currently visible.
-
setLocation
public void setLocation(java.awt.Point p)
Requests the presentation be located at a given position.- Specified by:
setLocationin interfaceHelpBroker
-
getLocation
public java.awt.Point getLocation()
Requests the location of the presentation.- Specified by:
getLocationin interfaceHelpBroker
-
setSize
public void setSize(java.awt.Dimension d)
Requests the presentation be set to a given size.- Specified by:
setSizein interfaceHelpBroker
-
getSize
public java.awt.Dimension getSize() throws UnsupportedOperationExceptionRequests the size of the presentation.- Specified by:
getSizein interfaceHelpBroker- Throws:
UnsupportedOperationException
-
setScreen
public void setScreen(int screen)
Requests the presentation be set to a given screen.- Specified by:
setScreenin interfaceHelpBroker
-
getScreen
public int getScreen() throws UnsupportedOperationExceptionRequests the screen of the presentation.- Specified by:
getScreenin interfaceHelpBroker- Throws:
UnsupportedOperationException
-
setViewDisplayed
public void setViewDisplayed(boolean displayed)
Hides/Shows view.- Specified by:
setViewDisplayedin interfaceHelpBroker- Parameters:
displayed- Make the navigational views visible or not.
-
isViewDisplayed
public boolean isViewDisplayed()
Determines if the current view is visible.- Specified by:
isViewDisplayedin interfaceHelpBroker- Returns:
- Whether the navigational views are visible.
-
showID
public void showID(java.lang.String id, java.lang.String presentation, java.lang.String presentationName) throws BadIDExceptionShows this ID.- Specified by:
showIDin interfaceHelpBroker- Parameters:
id- A string that identifies the topic to show for the loaded (top) HelpSetpresentation- The Presentation class to display the Help in.presentationName- The name of a Presentation section from a HelpSet to use. For some Presentations this will also be the name to apply to the Presentation.- Throws:
BadIDException- The ID is not valid for the HelpSetjava.lang.IllegalArgumentException- if presentation is not valid- See Also:
Presentation
-
showID
public void showID(Map.ID id, java.lang.String presentation, java.lang.String presentationName) throws InvalidHelpSetContextException
Show this ID.- Specified by:
showIDin interfaceHelpBroker- Parameters:
id- a Map.ID indicating the URL to displaypresentation- The Presentation class to display the Help in.presentationName- The name of a Presentation section from a HelpSet to use. For some Presentations this will also be the name to apply to the Presentation.- Throws:
InvalidHelpSetContextException- if the current helpset does not contain id.helpset- See Also:
Presentation
-
setCurrentID
public void setCurrentID(java.lang.String id) throws BadIDExceptionShows this ID as content relative to the (top) HelpSet for the HelpBroker instance--HelpVisitListeners are notified.- Specified by:
setCurrentIDin interfaceHelpBroker- Parameters:
id- A string that identifies the topic to show for the loaded (top) HelpSet- Throws:
BadIDException- The ID is not valid for the HelpSet
-
setCurrentID
public void setCurrentID(Map.ID id) throws InvalidHelpSetContextException
Displays this ID--HelpVisitListeners are notified.- Specified by:
setCurrentIDin interfaceHelpBroker- Parameters:
id- a Map.ID indicating the URL to display- Throws:
InvalidHelpSetContextException- if the current helpset does not contain id.helpset- See Also:
HelpModel.setCurrentID(javax.help.Map.ID)
-
getCurrentID
public Map.ID getCurrentID()
Determines which ID is displayed (if any).- Specified by:
getCurrentIDin interfaceHelpBroker- Returns:
- The ID being shown.
-
setCurrentURL
public void setCurrentURL(java.net.URL url)
Displays this URL. HelpVisitListeners are notified. The currentID changes if there is a mathing ID for this URL- Specified by:
setCurrentURLin interfaceHelpBroker- Parameters:
url- The url to display. A null URL is a valid url.
-
getCurrentURL
public java.net.URL getCurrentURL()
Determines which URL is displayed.- Specified by:
getCurrentURLin interfaceHelpBroker- Returns:
- The URL being shown.
-
enableHelpKey
public void enableHelpKey(java.awt.Component comp, java.lang.String id, HelpSet hs)Enables the Help key on a Component. This method works best when the component is the rootPane of a JFrame in Swing implementations, or a java.awt.Window (or subclass thereof) in AWT implementations. This method sets the default helpID and HelpSet for the Component and registers keyboard actions to trap the "Help" keypress. When the "Help" key is pressed, if the object with the current focus has a helpID, the helpID is displayed. otherwise the default helpID is displayed.- Specified by:
enableHelpKeyin interfaceHelpBroker- Parameters:
comp- 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.- See Also:
getHelpKeyActionListener
-
enableHelpKey
public void enableHelpKey(java.awt.Component comp, java.lang.String id, HelpSet hs, java.lang.String presentation, java.lang.String presentationName)Enables the Help key on a Component. This method works best when the component is the rootPane of a JFrame in Swing implementations, or a java.awt.Window (or subclass thereof) in AWT implementations. This method sets the default helpID and HelpSet for the Component and registers keyboard actions to trap the "Help" keypress. When the "Help" key is pressed, if the object with the current focus has a helpID, the helpID is displayed. otherwise the default helpID is displayed.- Specified by:
enableHelpKeyin interfaceHelpBroker- Parameters:
comp- 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 from the HelpBroker is assummed. null is not valid if presenation is not null.presentation- The Presentation class to display the content in. If presentation is null the HelpBroker is used to display the content.presentationName- The name of a Presentation section to control the display of the content. Also for some Presenations this will be used to "name" the Presentation.- Throws:
java.lang.IllegalArgumentException- if presentation != null and hs == null- See Also:
getHelpKeyActionListener
-
keyTyped
public void keyTyped(java.awt.event.KeyEvent e)
Invoked when a key is typed. This event occurs when a key press is followed by a key release. Not intended to be overridden or extended.- Specified by:
keyTypedin interfacejava.awt.event.KeyListener
-
keyPressed
public void keyPressed(java.awt.event.KeyEvent e)
Invoked when a key is pressed. Not intended to be overridden or extended.- Specified by:
keyPressedin interfacejava.awt.event.KeyListener
-
keyReleased
public void keyReleased(java.awt.event.KeyEvent e)
Invoked when a key is released. Not intended to be overridden or extended.- Specified by:
keyReleasedin interfacejava.awt.event.KeyListener
-
enableHelp
public void enableHelp(java.awt.Component comp, java.lang.String id, HelpSet hs)Enables help for a Component. This method sets a component's helpID and HelpSet.- Specified by:
enableHelpin interfaceHelpBroker- Parameters:
comp- 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.- See Also:
CSH.setHelpID,CSH.setHelpSet
-
enableHelp
public void enableHelp(java.awt.MenuItem comp, java.lang.String id, HelpSet hs)Enables help for a MenuItem. This method sets a component's helpID and HelpSet.- Specified by:
enableHelpin interfaceHelpBroker- Parameters:
comp- 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.- See Also:
CSH.setHelpID,CSH.setHelpSet
-
enableHelpOnButton
public void enableHelpOnButton(java.awt.Component comp, java.lang.String id, HelpSet hs)Enables help for a Component. This method sets a Component's helpID and HelpSet and adds an ActionListener. When an action is performed it displays the Component's helpID and HelpSet in the default viewer.- Specified by:
enableHelpOnButtonin interfaceHelpBroker- Parameters:
comp- 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.- Throws:
java.lang.IllegalArgumentException- if comp is null.- See Also:
CSH.setHelpID,CSH.setHelpSet,AbstractButton,Button
-
enableHelpOnButton
public void enableHelpOnButton(java.awt.MenuItem comp, java.lang.String id, HelpSet hs)Enables help for a MenuItem. This method sets a Component's helpID and HelpSet and adds an ActionListener. When an action is performed it displays the Component's helpID and HelpSet in the default viewer.- Specified by:
enableHelpOnButtonin interfaceHelpBroker- Parameters:
comp- 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.- Throws:
java.lang.IllegalArgumentException- if comp is null.- See Also:
CSH.setHelpID,CSH.setHelpSet,MenuItem
-
enableHelpOnButton
public void enableHelpOnButton(java.lang.Object obj, java.lang.String id, HelpSet hs, java.lang.String presentation, java.lang.String presentationName)Enables help for a Component. This method sets a Component's helpID and HelpSet and adds an ActionListener. When an action is performed it displays the Component's helpID and HelpSet in the default viewer.- Specified by:
enableHelpOnButtonin interfaceHelpBroker- Parameters:
comp- 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.- Throws:
java.lang.IllegalArgumentException- if comp is null.- See Also:
CSH.setHelpID,CSH.setHelpSet,AbstractButton,Button
-
getDisplayHelpFromFocus
protected java.awt.event.ActionListener getDisplayHelpFromFocus()
Returns the default DisplayHelpFromFocus listener.
-
getDisplayHelpFromSource
protected java.awt.event.ActionListener getDisplayHelpFromSource()
Returns the default DisplayHelpFromSource listener.
-
setActivationObject
public void setActivationObject(java.lang.Object comp)
Set the activation window from given Component or MenuItem. It find Window component in the component tree from given Component or MenuItem end callsetActivationWindow
.- Since:
- 1.1
- See Also:
setActivationWindow(java.awt.Window)
-
setActivationWindow
public void setActivationWindow(java.awt.Window window)
Set the activation window. If the window is an instance of a Dialog and the is modal, modallyActivated help is set to true and ownerDialog is set to the window. In all other instances modallyActivated is set to false and ownerDialog is set to null.- Parameters:
window- the activating window- Since:
- 1.1
-
-