private void createHelpModel() { if (model == null) { model = new DefaultHelpModel(helpset); } }
/** * Removes highlights. */ public void removeAllHighlights() { debug("removeAllHighlights"); highlights.setSize(0); fireHighlightsChanged(this); }
protected void fireIDChanged(Object source, ID id, URL url){ fireIDChanged(source, id, url, (String)null, (JHelpNavigator)null); }
/** * Adds a listener for the HelpModelEvent posted after the model has * changed. * * @param l - The listener to add. * @see javax.help.HelpModel#removeHelpModelListener * @throws IllegalArgumentException if l is null. */ public void addHelpModelListener(HelpModelListener l) { debug("addHelpModelListener: "); debug(" l:"+l); if (debug) { try { throw new Exception(""); } catch (Exception ex) { ex.printStackTrace(); } } listenerList.add(HelpModelListener.class, l); }
/** * Sets the current URL. * The current ID changes if there is a matching ID for this URL * and HelpModelListners are notified. * * @param url The url to set the model to. A null URL is a valid url. */ public void setCurrentURL(URL url) { setCurrentURL(url, (String)null, (JHelpNavigator)null); }
/** * 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. * * @param 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. * @exception InvalidHelpSetContextException The ID is not valid for the HelpSet */ public void setCurrentID(ID ident) throws InvalidHelpSetContextException { setCurrentID(ident,(String)null, (JHelpNavigator) null); } /**
/** * Determines which ID is displayed (if any). */ public ID getCurrentID() { return model.getCurrentID(); }
/** * Determines which URL is displayed. */ public URL getCurrentURL() { return model.getCurrentURL(); }
/** * Set highlights. Clear the current Hightlights and set new Highlights * * @param h An array of Hightlights. If h is null it is the same as setting * no highlights */ public void setHighlights(Highlight[] h) { highlights.setSize(0); if (h == null) { return; } for (int i=0; i<h.length; i++) { highlights.addElement(new DefaultHighlight(h[i].getStartOffset(), h[i].getEndOffset())); } if (highlights.size() > 0) { fireHighlightsChanged(this); } }
/** * Adds a listener for the TextHelpModelEvent posted after the model has * changed. * * @param l - The listener to add. * @see javax.help.HelpModel#removeHelpModelListener * @throws IllegalArgumentException if l is null. */ public void addTextHelpModelListener(TextHelpModelListener l) { debug("addTextHelpModelListener: "); debug(" l:"+l); // HERE if (debug) { try { throw new Exception(""); } catch (Exception ex) { ex.printStackTrace(); } } textListenerList.add(TextHelpModelListener.class, l); }
/** * Displays this URL. * HelpVisitListeners are notified. * The currentID changes if there is a mathing ID for this URL * @param url The url to display. A null URL is a valid url. */ public void setCurrentURL(URL url) { model.setCurrentURL(url); }
/** * Displays this ID--HelpVisitListeners are notified. * * @param id a Map.ID indicating the URL to display * @exception InvalidHelpSetContextException if the current helpset does not contain * id.helpset */ public void setCurrentID(ID id) throws InvalidHelpSetContextException { debug("setCurrentID"); model.setCurrentID(id); }
/** * 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; } }
/** * Highlights a range of positions in a document. * * @param pos0 start position * @param pos1 end position */ public void addHighlight(int pos0, int pos1) { debug("addHighlight("+pos0+", "+pos1+")"); highlights.addElement(new DefaultHighlight(pos0, pos1)); fireHighlightsChanged(this); }
protected void fireHighlightsChanged(Object source) { Object[] listeners = textListenerList.getListenerList(); TextHelpModelEvent e = null; for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == TextHelpModelListener.class) { if (e == null) { e = new TextHelpModelEvent(source); } debug("fireHighlightsChanged: "); debug(" "+listeners[i+1]); debug(" "+e); ((TextHelpModelListener)listeners[i+1]).highlightsChanged(e); } } }
fireIDChanged(this, currentID, currentURL, historyName, navigator);
/** * Create a JHelp with a JHelpContentViewer and all Navigators * requested in the HelpSet. * * @param hs The HelpSet. If hs is null the JHelp is created with a * TextHelpModel with no HelpSet. */ public JHelp(HelpSet hs) { this(new DefaultHelpModel(hs), null, hs==null? null : hs.getDefaultPresentation()); }
protected void fireIDChanged(Object source, ID id, URL url, String historyName, JHelpNavigator navigator) { Object[] listeners = listenerList.getListenerList(); HelpModelEvent e = null; for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == HelpModelListener.class) { if (e == null) { e = new HelpModelEvent(source, id, url, historyName, navigator); } debug("fireIDChanged: "); debug(" "+listeners[i+1]); debug(" id="+e.getID() + " url="+e.getURL()); ((HelpModelListener)listeners[i+1]).idChanged(e); } } }
fireIDChanged(this, currentID, currentURL, historyName, navigator);
/** * Changes the HelpSet for this presentation. * @param hs The HelpSet to set for this presentation. * A null hs is valid parameter. */ public void setHelpSet(HelpSet hs) { debug("setHelpSet"); // If we already have a model check if the HelpSet has changed. // If so change the model // This could be made smarter to cache the helpmodels per HelpSet if (hs != null && helpset != hs) { model = new DefaultHelpModel(hs); helpset = hs; } }