/** * Sets the current help set. If the current help broker is not null, the help set will be assigned to it. * Otherwise, a help broker will be created from the given help set. * <p/> * This method can be used to switch to an other helpset. * * @param helpSet the help set to be set */ private static void set(HelpSet helpSet) { if (helpBroker == null) { helpBroker = new DefaultHelpBroker(helpSet); } helpBroker.setHelpSet(helpSet); } }
/** * If the help system is initialised this method shows the given help theme. * * @param helpId the help theme */ public static void showTheme(String helpId) { if (isInitialized()) { helpBroker.setCurrentID(helpId); helpBroker.setDisplayed(true); } }
/** * 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 - ID"); mw.setCurrentID(id); }
helpBroker = new DefaultHelpBroker(hs); WindowPresentation windowPresentation = helpBroker.getWindowPresentation(); windowPresentation.createHelpWindow(); helpBroker.setLocation(new Point(frame.getX() + 25, frame.getY() + 25)); helpBroker.setSize(new Dimension(850, 600)); helpBroker.setCurrentID(START_ID); helpBroker.setDisplayed(true);
protected Window newHelpWindow(final DefaultHelpBroker helpBroker) { // found bug with the javax.help // Exception in thread "main" java.lang.SecurityException: no manifiest // section for signature file entry // com/sun/java/help/impl/TagProperties.class // Solution is to remove the rsa files from the jar final WindowPresentation pres = helpBroker.getWindowPresentation(); pres.createHelpWindow(); Window helpWindow = pres.getHelpWindow(); helpWindow.setLocationRelativeTo(null); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (final Exception e) { String title = e.getLocalizedMessage(); String htmlMessage = "<html><body width='650'>" + "<h2>" + title + "</h2>" + "<p>" + e.getMessage(); JOptionPane.showMessageDialog(this.getParent(), htmlMessage, title, JOptionPane.ERROR_MESSAGE); log.log(Level.SEVERE, e.getMessage(), e); } SwingUtilities.updateComponentTreeUI(helpWindow); return helpWindow; }
/** * Do action. */ @Override protected void doAction() { try { if (helpBroker != null) { if (helpBroker.isDisplayed()) { return; // Help already displayed } helpBroker.setDisplayed(true); // Help already created but // hidden - redisplay return; } createAndDisplayHelp(); } catch (HelpSetException ex) { DError.displayError(frame, ex); } }
/** * Show this ID. * * @param id a Map.ID indicating the URL to display * @param presentation The Presentation class to display the Help in. * @param 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. * @exception InvalidHelpSetContextException if the current helpset does not contain * id.helpset * @see Presentation */ public void showID(ID id, String presentation, String presentationName) throws InvalidHelpSetContextException { debug("showID - ID"); Presentation pres = getPresentation(presentation, presentationName); if (pres != null) { pres.setCurrentID(id); pres.setDisplayed(true); } }
/** * Invoked when a key is released. Not intended to be overridden or extended. */ public void keyReleased(KeyEvent e) { // simulate what is done in JComponents registerKeyboardActions. int code = e.getKeyCode(); if (code == KeyEvent.VK_F1 || code == KeyEvent.VK_HELP) { ActionListener al = null; if (helpKeyHS != null) { al = new CSH.DisplayHelpFromFocus(helpKeyHS, helpKeyPresentation, helpKeyPresentationName); } else { al = getDisplayHelpFromFocus(); } al.actionPerformed(new ActionEvent(e.getComponent(), ActionEvent.ACTION_PERFORMED, null)); } }
/** * 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. * * @param comp the Component to enable the keyboard actions on. * @param id the default HelpID to be displayed * @param hs the default HelpSet to be displayed. If hs is null the default HelpSet * will be assumed. * * @see getHelpKeyActionListener * @see enableHelpKey(Component, String, HelpSet, String, String); */ public void enableHelpKey(Component comp, String id, HelpSet hs) { enableHelpKey(comp, id, hs, null, null); }
/** * Disposes the application help system. */ public static void dispose() { if (isInitialized()) { Window helpWindow = helpBroker.getWindowPresentation().getHelpWindow(); if (helpWindow != null) { helpWindow.dispose(); } helpBroker = null; } }
/** * Shows this ID. * * @param id A string that identifies the topic to show for the loaded (top) HelpSet * @param presentation The Presentation class to display the Help in. * @param 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. * @exception BadIDException The ID is not valid for the HelpSet * @exception IllegalArgumentException if presentation is not valid * @see Presentation */ public void showID(String id, String presentation, String presentationName) throws BadIDException { debug("showID - string"); Presentation pres = getPresentation(presentation, presentationName); if (pres != null) { pres.setCurrentID(id); pres.setDisplayed(true); } }
ActionListener al = null; if (presentation == null) { al = getDisplayHelpFromFocus(); } else { al = new CSH.DisplayHelpFromFocus(hs, presentation,
public void run() throws HelpSetException, MalformedURLException { HelpBroker broker = Application.getInstance().getContext().getHelpBroker(); CSH.DisplayHelpFromFocus helpFromFocus = new CSH.DisplayHelpFromFocus(broker); helpFromFocus.actionPerformed(getEvent()); final Window window = ((DefaultHelpBroker) broker).getWindowPresentation().getHelpWindow(); window.setIconImage(WindowHelper.getFrame().getIconImage()); if (window instanceof JFrame) { JRootPane rootPane = ((JFrame) window).getRootPane(); rootPane.registerKeyboardAction(new ActionListener() { public void actionPerformed(ActionEvent e) { window.setVisible(false); } }, getKeyStroke(VK_ESCAPE, 0), WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); } } }
/** * 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) { debug ("setHelpSet"); mw.setHelpSet(hs); }
/** * Set the presentation attributes from a HelpSet.Presentation. * The HelpSet.Presentation must be in the current HelpSet. * * @param hsPres The HelpSet.Presentation * @since 2.0 */ public void setHelpSetPresentation(HelpSet.Presentation hsPres) { debug ("setHelpSetPresentation"); mw.setHelpSetPresentation(hsPres); }
/** * Shows this ID as content relative to the (top) HelpSet for the HelpBroker * instance--HelpVisitListeners are notified. * * @param id A string that identifies the topic to show for the loaded (top) HelpSet * @exception BadIDException The ID is not valid for the HelpSet */ public void setCurrentID(String id) throws BadIDException { debug("setCurrentID - string"); mw.setCurrentID(id); }
/** * Displays the presentation to the user. */ public void setDisplayed(boolean b) { debug("setDisplayed"); mw.setDisplayed(b); }
/** * 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) { debug ("setCurrentURL"); mw.setCurrentURL(url); }