org.openide.util
Class HelpCtx

java.lang.Object
  extended by org.openide.util.HelpCtx

public final class HelpCtx
extends java.lang.Object

Provides help for any window or other feature in the system. It is designed to be JavaHelp-compatible and to use the same tactics when assigning help to JComponent instances.

Author:
Petr Hamernik, Jaroslav Tulach, Jesse Glick
See Also:
JavaHelp Integration API

Nested Class Summary
static interface HelpCtx.Provider
          An object implementing this interface is willing to answer the HelpCtx.findHelp() query itself.
 
Field Summary
static HelpCtx DEFAULT_HELP
          Default help page.
 
Constructor Summary
HelpCtx(java.lang.Class clazz)
          Create a help context by class.
HelpCtx(java.lang.String helpID)
          Create a help context by tag.
HelpCtx(java.net.URL helpCtx)
          Deprecated. Does not work nicely with JavaHelp.
 
Method Summary
 boolean equals(java.lang.Object o)
           
static HelpCtx findHelp(java.awt.Component comp)
          Find the help ID for a component.
static HelpCtx findHelp(java.lang.Object instance)
          Finds help context for a generic object.
 java.net.URL getHelp()
          Get a URL to the help page, if applicable.
 java.lang.String getHelpID()
          Get the ID of the help page, if applicable.
 int hashCode()
           
static void setHelpIDString(javax.swing.JComponent comp, java.lang.String helpID)
          Set the help ID for a component.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_HELP

public static final HelpCtx DEFAULT_HELP
Default help page. This (hopefully) points to a note explaining to the user that no help is available. Precisely, the Help ID is set to org.openide.util.HelpCtx.DEFAULT_HELP.

Constructor Detail

HelpCtx

@Deprecated
public HelpCtx(java.net.URL helpCtx)
Deprecated. Does not work nicely with JavaHelp.

Create a help context by URL.

Parameters:
helpCtx - URL to point help to

HelpCtx

public HelpCtx(java.lang.String helpID)
Create a help context by tag. You must provide an ID of the desired help for the item. The ID should refer to an already installed help; this can be easily installed by specifying a JavaHelp help set for the module (see the Modules API for details).

Parameters:
helpID - the JavaHelp ID of the help

HelpCtx

public HelpCtx(java.lang.Class clazz)
Create a help context by class. Assigns the name of a class as the ID.

Parameters:
clazz - the class to take the name from
Method Detail

getHelp

public java.net.URL getHelp()
Get a URL to the help page, if applicable.

Returns:
a URL to the page, or null if the target was specified by ID

getHelpID

public java.lang.String getHelpID()
Get the ID of the help page, if applicable.

Returns:
the JavaHelp ID string, or null if specified by URL

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

setHelpIDString

public static void setHelpIDString(javax.swing.JComponent comp,
                                   java.lang.String helpID)
Set the help ID for a component.

Parameters:
comp - the visual component to associate help to
helpID - help ID, or null if the help ID should be removed

findHelp

public static HelpCtx findHelp(java.awt.Component comp)
Find the help ID for a component. If the component implements HelpCtx.Provider, its method HelpCtx.Provider.getHelpCtx() is called. If the component has help attached by setHelpIDString(javax.swing.JComponent, java.lang.String), it returns that. Otherwise it checks the parent component recursively.

Parameters:
comp - the component to find help for
Returns:
the help for that component (never null)

findHelp

public static HelpCtx findHelp(java.lang.Object instance)
Finds help context for a generic object. Right now checks for HelpCtx.Provider and handles java.awt.Component in a special way compatible with JavaHelp. Also BeanDescriptor's are checked for a string-valued attribute helpID, as per the JavaHelp specification (but no help sets will be loaded).

Parameters:
instance - to search help for
Returns:
the help for the object or HelpCtx.DEFAULT_HELP if HelpCtx cannot be found
Since:
4.3