Package javax.help
Class DefaultHelpModel
- java.lang.Object
-
- javax.help.DefaultHelpModel
-
- All Implemented Interfaces:
java.io.Serializable,HelpModel,TextHelpModel
public class DefaultHelpModel extends java.lang.Object implements TextHelpModel, java.io.Serializable
This class implements the javax.help.HelpModel API and notifies the JHelpModel listeners when changes occur.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDefaultHelpModel.DefaultHighlightA default implementation of TextHelpModel.Highlight-
Nested classes/interfaces inherited from interface javax.help.TextHelpModel
TextHelpModel.Highlight
-
-
Field Summary
Fields Modifier and Type Field Description protected java.beans.PropertyChangeSupportchangesprotected EventListenerListlistenerListprotected EventListenerListtextListenerList
-
Constructor Summary
Constructors Constructor Description DefaultHelpModel(HelpSet hs)Constructs a HelpModel from a HelpSet
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddHelpModelListener(HelpModelListener l)Adds a listener for the HelpModelEvent posted after the model has changed.voidaddHighlight(int pos0, int pos1)Highlights a range of positions in a document.voidaddPropertyChangeListener(java.beans.PropertyChangeListener l)Adds a listener to changes to the properties in this model.voidaddTextHelpModelListener(TextHelpModelListener l)Adds a listener for the TextHelpModelEvent posted after the model has changed.protected voidfireHighlightsChanged(java.lang.Object source)protected voidfireIDChanged(java.lang.Object source, Map.ID id, java.net.URL url)protected voidfireIDChanged(java.lang.Object source, Map.ID id, java.net.URL url, java.lang.String historyName, JHelpNavigator navigator)Map.IDgetCurrentID()Gets the current ID.java.net.URLgetCurrentURL()Returns the current URLjava.lang.StringgetDocumentTitle()Gets the document title.HelpSetgetHelpSet()Gets the backing HelpSet.TextHelpModel.Highlight[]getHighlights()Geta all the highlights currently active.voidremoveAllHighlights()Removes highlights.voidremoveHelpModelListener(HelpModelListener l)Removes a listener previously added with addHelpListenervoidremovePropertyChangeListener(java.beans.PropertyChangeListener l)Removes a listener to changes to the properties in this model.voidremoveTextHelpModelListener(TextHelpModelListener l)Removes a listener previously added with addHelpListenervoidsetCurrentID(Map.ID ident)Sets the current ID.voidsetCurrentID(Map.ID ident, java.lang.String historyName, JHelpNavigator navigator)Sets the current ID relative to some HelpSet HelpModelListeners and HelpVisitListeners are notifiedvoidsetCurrentURL(java.net.URL url)Sets the current URL.voidsetCurrentURL(java.net.URL url, java.lang.String historyName, JHelpNavigator navigator)Sets the current URL and the name wich will appear in history list.voidsetDocumentTitle(java.lang.String title)Assigns the document title.voidsetHelpSet(HelpSet hs)Sets the HelpSet for this HelpModel.voidsetHighlights(TextHelpModel.Highlight[] h)Set highlights.
-
-
-
Field Detail
-
listenerList
protected EventListenerList listenerList
-
textListenerList
protected EventListenerList textListenerList
-
changes
protected java.beans.PropertyChangeSupport changes
-
-
Method Detail
-
setHelpSet
public void setHelpSet(HelpSet hs)
Sets the HelpSet for this HelpModel. A null hs is valid.- Specified by:
setHelpSetin interfaceHelpModel
-
getHelpSet
public HelpSet getHelpSet()
Gets the backing HelpSet.- Specified by:
getHelpSetin interfaceHelpModel- Returns:
- the helpset. A null hs is valid.
-
setCurrentID
public void setCurrentID(Map.ID ident) throws InvalidHelpSetContextException
Sets the current ID. HelpModelListeners and HelpVisitListeners are notified. If the parameter ident is null, the homeID of the current HelpSet is used unless it is also null in which case the method returns without setting the currentID.- Specified by:
setCurrentIDin interfaceHelpModel- Parameters:
ident- The ID to set. If ident is null set the currentID to the HelpSet's HomeID. If the HomeID doesn't exist the currentID is set to null.- Throws:
InvalidHelpSetContextException- The ID is not valid for the HelpSet
-
setCurrentID
public void setCurrentID(Map.ID ident, java.lang.String historyName, JHelpNavigator navigator) throws InvalidHelpSetContextException
Sets the current ID relative to some HelpSet HelpModelListeners and HelpVisitListeners are notified- Specified by:
setCurrentIDin interfaceHelpModel- Parameters:
id- the ID used to sethistoryName- the name for history storagenavigator- the name of the navigator for history- Throws:
InvalidHelpSetContextException- The HelpSet of the ID is not valid for the HelpSet currently loaded in the model
-
getCurrentID
public Map.ID getCurrentID()
Gets the current ID.- Specified by:
getCurrentIDin interfaceHelpModel- Returns:
- the current ID. A null ID is a valid id. If no ID has been set a null ID is returned.
-
setCurrentURL
public void setCurrentURL(java.net.URL url)
Sets the current URL. The current ID changes if there is a matching ID for this URL and HelpModelListners are notified.- Specified by:
setCurrentURLin interfaceHelpModel- Parameters:
url- The url to set the model to. A null URL is a valid url.
-
setCurrentURL
public void setCurrentURL(java.net.URL url, java.lang.String historyName, JHelpNavigator navigator)Sets the current URL and the name wich will appear in history list. HelpModelListeners are notified. The current ID changes if there is a matching id for this URL- Specified by:
setCurrentURLin interfaceHelpModel- Parameters:
url- The URL to set.historyName- The name to set for historynavigator- The name of the navigator for history
-
getCurrentURL
public java.net.URL getCurrentURL()
Returns the current URL- Specified by:
getCurrentURLin interfaceHelpModel- Returns:
- The current URL. A null URL is a valid URL. If no URL has been previously set a null URL will be returned.
-
addHighlight
public void addHighlight(int pos0, int pos1)Highlights a range of positions in a document.- Specified by:
addHighlightin interfaceTextHelpModel- Parameters:
pos0- start positionpos1- end position
-
removeAllHighlights
public void removeAllHighlights()
Removes highlights.- Specified by:
removeAllHighlightsin interfaceTextHelpModel
-
setHighlights
public void setHighlights(TextHelpModel.Highlight[] h)
Set highlights. Clear the current Hightlights and set new Highlights- Specified by:
setHighlightsin interfaceTextHelpModel- Parameters:
h- An array of Hightlights. If h is null it is the same as setting no highlights
-
getHighlights
public TextHelpModel.Highlight[] getHighlights()
Geta all the highlights currently active.- Specified by:
getHighlightsin interfaceTextHelpModel- Returns:
- An array of highlights
-
addHelpModelListener
public void addHelpModelListener(HelpModelListener l)
Adds a listener for the HelpModelEvent posted after the model has changed.- Specified by:
addHelpModelListenerin interfaceHelpModel- Parameters:
l- - The listener to add.- Throws:
java.lang.IllegalArgumentException- if l is null.- See Also:
HelpModel.removeHelpModelListener(javax.help.event.HelpModelListener)
-
removeHelpModelListener
public void removeHelpModelListener(HelpModelListener l)
Removes a listener previously added with addHelpListener- Specified by:
removeHelpModelListenerin interfaceHelpModel- Parameters:
l- - The listener to remove. If l is not in the list of listeners it is ignored.- Throws:
java.lang.IllegalArgumentException- if l is null.- See Also:
HelpModel.addHelpModelListener(javax.help.event.HelpModelListener)
-
addTextHelpModelListener
public void addTextHelpModelListener(TextHelpModelListener l)
Adds a listener for the TextHelpModelEvent posted after the model has changed.- Specified by:
addTextHelpModelListenerin interfaceTextHelpModel- Parameters:
l- - The listener to add.- Throws:
java.lang.IllegalArgumentException- if l is null.- See Also:
HelpModel.removeHelpModelListener(javax.help.event.HelpModelListener)
-
removeTextHelpModelListener
public void removeTextHelpModelListener(TextHelpModelListener l)
Removes a listener previously added with addHelpListener- Specified by:
removeTextHelpModelListenerin interfaceTextHelpModel- Parameters:
l- - The listener to remove. If l is not on the list of listeners it is ignored.- Throws:
java.lang.IllegalArgumentException- if l is null.- See Also:
HelpModel.addHelpModelListener(javax.help.event.HelpModelListener)
-
addPropertyChangeListener
public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Adds a listener to changes to the properties in this model.- Specified by:
addPropertyChangeListenerin interfaceHelpModel- Parameters:
l- the listener to add
-
removePropertyChangeListener
public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Removes a listener to changes to the properties in this model.- Specified by:
removePropertyChangeListenerin interfaceHelpModel- Parameters:
l- the listener to remove. If l is not on the list of listeners it is ignored.
-
setDocumentTitle
public void setDocumentTitle(java.lang.String title)
Assigns the document title.- Specified by:
setDocumentTitlein interfaceTextHelpModel- Parameters:
title- the Title for the document currently being shown. A null title is valid.
-
getDocumentTitle
public java.lang.String getDocumentTitle()
Gets the document title.- Specified by:
getDocumentTitlein interfaceTextHelpModel- Returns:
- The title for the current document. A null title is valid. If the title has not be previously set it will be null.
-
fireIDChanged
protected void fireIDChanged(java.lang.Object source, Map.ID id, java.net.URL url, java.lang.String historyName, JHelpNavigator navigator)
-
fireIDChanged
protected void fireIDChanged(java.lang.Object source, Map.ID id, java.net.URL url)
-
fireHighlightsChanged
protected void fireHighlightsChanged(java.lang.Object source)
-
-