Search in sources :

Example 1 with DefaultHelpBroker

use of javax.help.DefaultHelpBroker in project keystore-explorer by kaikramer.

the class HelpAction method createAndDisplayHelp.

private void createAndDisplayHelp() throws HelpSetException {
    URL hsUrl = getClass().getResource(res.getString("HelpAction.HelpSet"));
    HelpSet hs = new HelpSet(getClass().getClassLoader(), hsUrl);
    if (LnfUtil.isDarculaAvailable()) {
        URL hsDarculaUrl = getClass().getResource(res.getString("HelpAction.DarculaHelpSet"));
        HelpSet hsDarcula = new HelpSet(getClass().getClassLoader(), hsDarculaUrl);
        hs.add(hsDarcula);
    }
    helpBroker = new DefaultHelpBroker(hs);
    WindowPresentation windowPresentation = helpBroker.getWindowPresentation();
    windowPresentation.createHelpWindow();
    // Make window immune to modal dialogs in application
    Window helpWindow = windowPresentation.getHelpWindow();
    helpWindow.setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE);
    // Set help icons - set lots of different sizes to give each OS the most
    // flexibility in choosing an icon for display
    ArrayList<Image> icons = new ArrayList<Image>();
    icons.add(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("HelpAction.image.16x16"))));
    icons.add(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("HelpAction.image.24x24"))));
    icons.add(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("HelpAction.image.32x32"))));
    helpWindow.setIconImages(icons);
    helpBroker.setLocation(new Point(frame.getX() + 25, frame.getY() + 25));
    helpBroker.setSize(new Dimension(850, 600));
    helpBroker.setCurrentID(START_ID);
    helpBroker.setDisplayed(true);
}
Also used : Window(java.awt.Window) HelpSet(javax.help.HelpSet) WindowPresentation(javax.help.WindowPresentation) ArrayList(java.util.ArrayList) DefaultHelpBroker(javax.help.DefaultHelpBroker) Point(java.awt.Point) Dimension(java.awt.Dimension) Image(java.awt.Image) URL(java.net.URL)

Example 2 with DefaultHelpBroker

use of javax.help.DefaultHelpBroker in project edumips64 by lupino3.

the class GUIHelp method showHelp.

/**
 * Shows the EduMIPS64 help window.
 *
 * @param parent the window that owns this help dialog
 * @param helpSetUrl the URL to the directory of the help set.
 */
public static void showHelp(Window parent, URL helpSetUrl, ConfigStore cfg) throws HelpSetException, BadIDException, MalformedURLException {
    // Clean up the URL from spaces.
    String cleanUrl = helpSetUrl.getProtocol() + ":" + helpSetUrl.getPath().replace("%20", " ");
    URL[] aurl = GUIHelp.parseURLs(cleanUrl);
    URLClassLoader urlclassloader = new URLClassLoader(aurl);
    URL url = HelpSet.findHelpSet(urlclassloader, HELPSET);
    int desiredFontSize = cfg.getInt(ConfigKey.UI_FONT_SIZE);
    float windowScalingFactor = desiredFontSize / 12.0f;
    HelpSet helpset = new HelpSet(urlclassloader, url);
    HelpBroker helpBroker = helpset.createHelpBroker();
    helpBroker.initPresentation();
    helpBroker.setSize(new Dimension((int) (800 * windowScalingFactor), (int) (600 * windowScalingFactor)));
    // Update the font.
    helpBroker.setSize(helpBroker.getSize());
    Font newFont = helpBroker.getFont().deriveFont((float) desiredFontSize);
    ((DefaultHelpBroker) helpBroker).setActivationWindow(parent);
    helpBroker.initPresentation();
    helpBroker.setFont(newFont);
    helpBroker.setDisplayed(true);
}
Also used : DefaultHelpBroker(javax.help.DefaultHelpBroker) HelpBroker(javax.help.HelpBroker) HelpSet(javax.help.HelpSet) URLClassLoader(java.net.URLClassLoader) DefaultHelpBroker(javax.help.DefaultHelpBroker) URL(java.net.URL)

Example 3 with DefaultHelpBroker

use of javax.help.DefaultHelpBroker in project bundle-app-ui by astrapi69.

the class DesktopMenu method newHelpMenu.

/**
 * Factory method for create new {@link JMenu} for the help menu.
 *
 * @param listener
 *            the listener
 * @return the j menu
 */
private JMenu newHelpMenu(final ActionListener listener) {
    // Help menu
    // $NON-NLS-1$
    final JMenu menuHelp = new JMenu("Help");
    menuHelp.setMnemonic('H');
    // Help JMenuItems
    // Help content
    // $NON-NLS-1$
    final JMenuItem mihHelpContent = new JMenuItem("Content", 'c');
    MenuExtensions.setCtrlAccelerator(mihHelpContent, 'H');
    menuHelp.add(mihHelpContent);
    // 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 HelpSet hs = getHelpSet();
    final DefaultHelpBroker helpBroker = (DefaultHelpBroker) hs.createHelpBroker();
    final WindowPresentation pres = helpBroker.getWindowPresentation();
    pres.createHelpWindow();
    helpWindow = pres.getHelpWindow();
    helpWindow.setLocationRelativeTo(null);
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (final Exception e1) {
        log.error(e1.getLocalizedMessage(), e1);
    }
    SwingUtilities.updateComponentTreeUI(helpWindow);
    // 2. assign help to components
    CSH.setHelpIDString(mihHelpContent, "Overview");
    // 3. handle events
    final CSH.DisplayHelpFromSource displayHelpFromSource = new CSH.DisplayHelpFromSource(helpBroker);
    mihHelpContent.addActionListener(displayHelpFromSource);
    mihHelpContent.addActionListener(new ShowHelpDialogAction("Content"));
    // Donate
    final JMenuItem mihDonate = new JMenuItem(// $NON-NLS-1$
    Messages.getString("com.find.duplicate.files.menu.item.donate"));
    mihDonate.addActionListener(new OpenBrowserToDonateAction("Donate"));
    menuHelp.add(mihDonate);
    // Licence
    // $NON-NLS-1$
    final JMenuItem mihLicence = new JMenuItem("Licence");
    mihLicence.addActionListener(new ShowLicenseFrameAction("Licence"));
    menuHelp.add(mihLicence);
    // Info
    // $NON-NLS-1$
    final JMenuItem mihInfo = new JMenuItem("Info", 'i');
    MenuExtensions.setCtrlAccelerator(mihInfo, 'I');
    mihInfo.addActionListener(new ShowInfoDialogAction("Info"));
    menuHelp.add(mihInfo);
    return menuHelp;
}
Also used : HelpSet(javax.help.HelpSet) WindowPresentation(javax.help.WindowPresentation) OpenBrowserToDonateAction(de.alpharogroup.bundle.app.actions.OpenBrowserToDonateAction) DefaultHelpBroker(javax.help.DefaultHelpBroker) HelpSetException(javax.help.HelpSetException) ShowHelpDialogAction(de.alpharogroup.bundle.app.actions.ShowHelpDialogAction) ShowInfoDialogAction(de.alpharogroup.bundle.app.actions.ShowInfoDialogAction) ShowLicenseFrameAction(de.alpharogroup.bundle.app.actions.ShowLicenseFrameAction) CSH(javax.help.CSH) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu)

Aggregations

DefaultHelpBroker (javax.help.DefaultHelpBroker)3 HelpSet (javax.help.HelpSet)3 URL (java.net.URL)2 WindowPresentation (javax.help.WindowPresentation)2 OpenBrowserToDonateAction (de.alpharogroup.bundle.app.actions.OpenBrowserToDonateAction)1 ShowHelpDialogAction (de.alpharogroup.bundle.app.actions.ShowHelpDialogAction)1 ShowInfoDialogAction (de.alpharogroup.bundle.app.actions.ShowInfoDialogAction)1 ShowLicenseFrameAction (de.alpharogroup.bundle.app.actions.ShowLicenseFrameAction)1 Dimension (java.awt.Dimension)1 Image (java.awt.Image)1 Point (java.awt.Point)1 Window (java.awt.Window)1 URLClassLoader (java.net.URLClassLoader)1 ArrayList (java.util.ArrayList)1 CSH (javax.help.CSH)1 HelpBroker (javax.help.HelpBroker)1 HelpSetException (javax.help.HelpSetException)1 JMenu (javax.swing.JMenu)1 JMenuItem (javax.swing.JMenuItem)1