Search in sources :

Example 1 with JHelp

use of javax.help.JHelp in project logisim-evolution by reds-heig.

the class MenuHelp method loadBroker.

private void loadBroker() {
    String helpUrl = Strings.get("helpsetUrl");
    if (helpUrl == null) {
        helpUrl = "doc/doc_en.hs";
    }
    if (helpSet == null || helpFrame == null || !helpUrl.equals(helpSetUrl)) {
        ClassLoader loader = MenuHelp.class.getClassLoader();
        try {
            URL hsURL = HelpSet.findHelpSet(loader, helpUrl);
            if (hsURL == null) {
                disableHelp();
                JOptionPane.showMessageDialog(menubar.getParentWindow(), Strings.get("helpNotFoundError"));
                return;
            }
            helpSetUrl = helpUrl;
            helpSet = new HelpSet(null, hsURL);
            helpComponent = new JHelp(helpSet);
            if (helpFrame == null) {
                helpFrame = new LFrame();
                helpFrame.setTitle(Strings.get("helpWindowTitle"));
                helpFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
                helpFrame.getContentPane().add(helpComponent);
                helpFrame.setPreferredSize(new Dimension((int) Toolkit.getDefaultToolkit().getScreenSize().getWidth() >> 1, (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight() >> 1));
                helpFrame.pack();
            } else {
                helpFrame.getContentPane().removeAll();
                helpFrame.getContentPane().add(helpComponent);
                helpComponent.revalidate();
            }
        } catch (Exception e) {
            disableHelp();
            e.printStackTrace();
            JOptionPane.showMessageDialog(menubar.getParentWindow(), Strings.get("helpUnavailableError"));
            return;
        }
    }
}
Also used : HelpSet(javax.help.HelpSet) LFrame(com.cburch.logisim.gui.generic.LFrame) Dimension(java.awt.Dimension) URL(java.net.URL) JHelp(javax.help.JHelp)

Example 2 with JHelp

use of javax.help.JHelp in project ffx by mjschnie.

the class MainPanel method help.

/**
 * <p>
 * help</p>
 */
public void help() {
    String helpHS = "ffx/help/jhelpset.hs";
    ClassLoader cl = getClass().getClassLoader();
    HelpSet hs = null;
    try {
        URL hsURL = HelpSet.findHelpSet(cl, helpHS);
        hs = new HelpSet(null, hsURL);
    } catch (Exception e) {
        logger.warning("HelpSet not found: " + e);
        return;
    }
    JHelp jhelp = new JHelp(hs);
    JFrame helpFrame = new JFrame();
    JFrame.setDefaultLookAndFeelDecorated(true);
    helpFrame.add(jhelp);
    helpFrame.setTitle("Force Field X Help");
    helpFrame.setSize(jhelp.getPreferredSize());
    helpFrame.setVisible(true);
    jhelp.setCurrentID("ForceFieldXBook");
    helpFrame.toFront();
}
Also used : HelpSet(javax.help.HelpSet) JFrame(javax.swing.JFrame) ForceFieldString(ffx.potential.parameters.ForceField.ForceFieldString) URL(java.net.URL) UnsupportedLookAndFeelException(javax.swing.UnsupportedLookAndFeelException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) MalformedURLException(java.net.MalformedURLException) JHelp(javax.help.JHelp)

Example 3 with JHelp

use of javax.help.JHelp in project logisim-evolution by reds-heig.

the class Startup method eventDispatched.

@Override
public void eventDispatched(AWTEvent event) {
    if (event instanceof ContainerEvent) {
        ContainerEvent containerEvent = (ContainerEvent) event;
        if (containerEvent.getID() == ContainerEvent.COMPONENT_ADDED) {
            Component container = containerEvent.getChild();
            if ((container instanceof JButton) || (container instanceof JCheckBox) || (container instanceof JComboBox) || (container instanceof JLabel) || (container instanceof JMenu) || (container instanceof JMenuItem) || (container instanceof JRadioButton) || (container instanceof JRadioButtonMenuItem) || (container instanceof JSpinner) || (container instanceof JTabbedPane) || (container instanceof JTextField) || (container instanceof JHelp) || (container instanceof JFileChooser) || ((container instanceof JScrollPane) && (!(container instanceof CanvasPane))) || (container instanceof JFontChooser) || (container instanceof JCheckBoxMenuItem)) {
                AppPreferences.setScaledFonts(((JComponent) container).getComponents());
                try {
                    container.setFont(AppPreferences.getScaledFont(containerEvent.getChild().getFont()));
                    container.revalidate();
                    container.repaint();
                } catch (Exception e) {
                }
            }
            if (container instanceof JOptionPane) {
                JOptionPane pane = (JOptionPane) container;
                if (HasIcon(pane)) {
                    ImageIcon icon;
                    switch(pane.getMessageType()) {
                        case JOptionPane.ERROR_MESSAGE:
                            icon = new ImageIcon(getClass().getClassLoader().getResource("resources/logisim/error.png"));
                            pane.setIcon(AppPreferences.getScaledImageIcon(icon, (float) 3));
                            break;
                        case JOptionPane.QUESTION_MESSAGE:
                            icon = new ImageIcon(getClass().getClassLoader().getResource("resources/logisim/question.png"));
                            pane.setIcon(AppPreferences.getScaledImageIcon(icon, (float) 3));
                            break;
                        case JOptionPane.PLAIN_MESSAGE:
                            icon = new ImageIcon(getClass().getClassLoader().getResource("resources/logisim/plain.png"));
                            pane.setIcon(AppPreferences.getScaledImageIcon(icon, (float) 3));
                            break;
                        case JOptionPane.INFORMATION_MESSAGE:
                            icon = new ImageIcon(getClass().getClassLoader().getResource("resources/logisim/info.png"));
                            pane.setIcon(AppPreferences.getScaledImageIcon(icon, (float) 3));
                            break;
                        case JOptionPane.WARNING_MESSAGE:
                            icon = new ImageIcon(getClass().getClassLoader().getResource("resources/logisim/warning.png"));
                            pane.setIcon(AppPreferences.getScaledImageIcon(icon, (float) 3));
                            break;
                    }
                }
            }
        }
    }
// TODO Auto-generated method stub
}
Also used : ContainerEvent(java.awt.event.ContainerEvent) JScrollPane(javax.swing.JScrollPane) ImageIcon(javax.swing.ImageIcon) JRadioButton(javax.swing.JRadioButton) JComboBox(javax.swing.JComboBox) JTabbedPane(javax.swing.JTabbedPane) CanvasPane(com.cburch.logisim.gui.generic.CanvasPane) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JTextField(javax.swing.JTextField) JOptionPane(javax.swing.JOptionPane) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) URISyntaxException(java.net.URISyntaxException) FileNotFoundException(java.io.FileNotFoundException) LoadFailedException(com.cburch.logisim.file.LoadFailedException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) JCheckBox(javax.swing.JCheckBox) JFileChooser(javax.swing.JFileChooser) JFontChooser(com.connectina.swing.fontchooser.JFontChooser) JSpinner(javax.swing.JSpinner) Component(java.awt.Component) JComponent(javax.swing.JComponent) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu) JHelp(javax.help.JHelp)

Aggregations

JHelp (javax.help.JHelp)3 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 MalformedURLException (java.net.MalformedURLException)2 URL (java.net.URL)2 HelpSet (javax.help.HelpSet)2 LoadFailedException (com.cburch.logisim.file.LoadFailedException)1 CanvasPane (com.cburch.logisim.gui.generic.CanvasPane)1 LFrame (com.cburch.logisim.gui.generic.LFrame)1 JFontChooser (com.connectina.swing.fontchooser.JFontChooser)1 ForceFieldString (ffx.potential.parameters.ForceField.ForceFieldString)1 Component (java.awt.Component)1 Dimension (java.awt.Dimension)1 ContainerEvent (java.awt.event.ContainerEvent)1 URISyntaxException (java.net.URISyntaxException)1 ImageIcon (javax.swing.ImageIcon)1 JButton (javax.swing.JButton)1 JCheckBox (javax.swing.JCheckBox)1 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)1 JComboBox (javax.swing.JComboBox)1