Search in sources :

Example 1 with SimpleUserAgentContext

use of org.lobobrowser.html.test.SimpleUserAgentContext in project pcgen by PCGen.

the class PCGenFrame method showMatureDialog.

private void showMatureDialog(String text) {
    Logging.errorPrint("Warning: The following datasets contains mature themes. User discretion is advised.");
    Logging.errorPrint(text);
    final JDialog aFrame = new JDialog(this, LanguageBundle.getString("in_matureTitle"), true);
    final JPanel jPanel1 = new JPanel();
    final JPanel jPanel3 = new JPanel();
    final JLabel jLabel1 = new //$NON-NLS-1$
    JLabel(//$NON-NLS-1$
    LanguageBundle.getString("in_matureWarningLine1"), SwingConstants.CENTER);
    final JLabel jLabel2 = new //$NON-NLS-1$
    JLabel(//$NON-NLS-1$
    LanguageBundle.getString("in_matureWarningLine2"), SwingConstants.CENTER);
    //$NON-NLS-1$
    final JCheckBox jCheckBox1 = new JCheckBox(LanguageBundle.getString("in_licShowOnLoad"));
    //$NON-NLS-1$
    final JButton jClose = new JButton(LanguageBundle.getString("in_close"));
    //$NON-NLS-1$
    jClose.setMnemonic(LanguageBundle.getMnemonic("in_mn_close"));
    jPanel1.setLayout(new BorderLayout());
    jPanel1.add(jLabel1, BorderLayout.NORTH);
    jPanel1.add(jLabel2, BorderLayout.SOUTH);
    HtmlPanel htmlPanel = new HtmlPanel();
    HtmlRendererContext theRendererContext = new SimpleHtmlRendererContext(htmlPanel, new SimpleUserAgentContext());
    htmlPanel.setHtml(text, "", theRendererContext);
    jPanel3.add(jCheckBox1);
    jPanel3.add(jClose);
    final PropertyContext context = PCGenSettings.OPTIONS_CONTEXT;
    jCheckBox1.setSelected(context.getBoolean(PCGenSettings.OPTION_SHOW_MATURE_ON_LOAD));
    jClose.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            aFrame.dispose();
        }
    });
    jCheckBox1.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent evt) {
            context.setBoolean(PCGenSettings.OPTION_SHOW_MATURE_ON_LOAD, jCheckBox1.isSelected());
        }
    });
    aFrame.getContentPane().setLayout(new BorderLayout());
    aFrame.getContentPane().add(jPanel1, BorderLayout.NORTH);
    aFrame.getContentPane().add(htmlPanel, BorderLayout.CENTER);
    aFrame.getContentPane().add(jPanel3, BorderLayout.SOUTH);
    aFrame.setSize(new Dimension(456, 176));
    Utility.setComponentRelativeLocation(this, aFrame);
    aFrame.setVisible(true);
}
Also used : SimpleHtmlRendererContext(org.lobobrowser.html.test.SimpleHtmlRendererContext) HtmlRendererContext(org.lobobrowser.html.HtmlRendererContext) SimpleHtmlRendererContext(org.lobobrowser.html.test.SimpleHtmlRendererContext) JPanel(javax.swing.JPanel) ItemEvent(java.awt.event.ItemEvent) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) SimpleUserAgentContext(org.lobobrowser.html.test.SimpleUserAgentContext) Dimension(java.awt.Dimension) JCheckBox(javax.swing.JCheckBox) BorderLayout(java.awt.BorderLayout) ActionListener(java.awt.event.ActionListener) HtmlPanel(org.lobobrowser.html.gui.HtmlPanel) PropertyContext(pcgen.system.PropertyContext) ItemListener(java.awt.event.ItemListener) JDialog(javax.swing.JDialog)

Example 2 with SimpleUserAgentContext

use of org.lobobrowser.html.test.SimpleUserAgentContext in project pcgen by PCGen.

the class PCGenFrame method showLicenseDialog.

private void showLicenseDialog(String title, String htmlString) {
    if (htmlString == null) {
        //$NON-NLS-1$
        htmlString = LanguageBundle.getString("in_licNoInfo");
    }
    final PropertyContext context = PCGenSettings.OPTIONS_CONTEXT;
    final JDialog aFrame = new JDialog(this, title, true);
    //$NON-NLS-1$
    final JButton jClose = new JButton(LanguageBundle.getString("in_close"));
    //$NON-NLS-1$
    jClose.setMnemonic(LanguageBundle.getMnemonic("in_mn_close"));
    final JPanel jPanel = new JPanel();
    //$NON-NLS-1$
    final JCheckBox jCheckBox = new JCheckBox(LanguageBundle.getString("in_licShowOnLoad"));
    jPanel.add(jCheckBox);
    jCheckBox.setSelected(context.getBoolean(PCGenSettings.OPTION_SHOW_LICENSE));
    jCheckBox.addItemListener(evt -> context.setBoolean(PCGenSettings.OPTION_SHOW_LICENSE, jCheckBox.isSelected()));
    jPanel.add(jClose);
    jClose.addActionListener(evt -> aFrame.dispose());
    HtmlPanel htmlPanel = new HtmlPanel();
    HtmlRendererContext theRendererContext = new SimpleHtmlRendererContext(htmlPanel, new SimpleUserAgentContext());
    htmlPanel.setHtml(htmlString, "", theRendererContext);
    aFrame.getContentPane().setLayout(new BorderLayout());
    aFrame.getContentPane().add(htmlPanel, BorderLayout.CENTER);
    aFrame.getContentPane().add(jPanel, BorderLayout.SOUTH);
    aFrame.setSize(new Dimension(700, 500));
    aFrame.setLocationRelativeTo(this);
    Utility.setComponentRelativeLocation(this, aFrame);
    aFrame.getRootPane().setDefaultButton(jClose);
    Utility.installEscapeCloseOperation(aFrame);
    aFrame.setVisible(true);
}
Also used : JCheckBox(javax.swing.JCheckBox) SimpleHtmlRendererContext(org.lobobrowser.html.test.SimpleHtmlRendererContext) HtmlRendererContext(org.lobobrowser.html.HtmlRendererContext) SimpleHtmlRendererContext(org.lobobrowser.html.test.SimpleHtmlRendererContext) JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) PropertyContext(pcgen.system.PropertyContext) HtmlPanel(org.lobobrowser.html.gui.HtmlPanel) JButton(javax.swing.JButton) SimpleUserAgentContext(org.lobobrowser.html.test.SimpleUserAgentContext) Dimension(java.awt.Dimension) JDialog(javax.swing.JDialog)

Example 3 with SimpleUserAgentContext

use of org.lobobrowser.html.test.SimpleUserAgentContext in project pcgen by PCGen.

the class PCGenFrame method showSponsorsDialog.

public void showSponsorsDialog() {
    Collection<Sponsor> sponsors = Globals.getGlobalContext().getReferenceContext().getConstructedCDOMObjects(Sponsor.class);
    if (sponsors.size() <= 1) {
        return;
    }
    //$NON-NLS-1$
    String title = LanguageBundle.getString("in_sponsorTitle");
    final JDialog aFrame = new JDialog(this, title, true);
    //$NON-NLS-1$
    final JButton jClose = new JButton(LanguageBundle.getString("in_close"));
    //$NON-NLS-1$
    jClose.setMnemonic(LanguageBundle.getMnemonic("in_mn_close"));
    final JPanel jPanel = new JPanel();
    //$NON-NLS-1$
    final JCheckBox jCheckBox = new JCheckBox(LanguageBundle.getString("in_licShowOnLoad"));
    jPanel.add(jCheckBox);
    final PropertyContext context = PCGenSettings.OPTIONS_CONTEXT;
    jCheckBox.setSelected(context.getBoolean(PCGenSettings.OPTION_SHOW_SPONSORS_ON_LOAD));
    jCheckBox.addItemListener(evt -> context.setBoolean(PCGenSettings.OPTION_SHOW_SPONSORS_ON_LOAD, jCheckBox.isSelected()));
    jPanel.add(jClose);
    jClose.addActionListener(evt -> aFrame.dispose());
    StringBuilder sb = new StringBuilder(500);
    sb.append("<html>");
    for (Sponsor sponsor : sponsors) {
        if (!"PCGEN".equals(sponsor.getKeyName())) {
            continue;
        }
        sb.append("<img src='").append(sponsor.getBannerImage()).append("'><br>");
    }
    String s = "";
    if (sponsors.size() > 2) {
        s = "s";
    }
    sb.append("<H2><CENTER>").append(LanguageBundle.getString("in_sponsorThanks")).append(//$NON-NLS-1$
    s).append(":</CENTER></h2>");
    int size = 172;
    for (Sponsor sponsor : sponsors) {
        if ("PCGEN".equals(sponsor.getKeyName())) {
            continue;
        }
        size += 70;
        sb.append("<img src='").append(sponsor.getBannerImage()).append("'><br>");
    }
    sb.append("</html>");
    HtmlPanel htmlPanel = new HtmlPanel();
    HtmlRendererContext theRendererContext = new SimpleHtmlRendererContext(htmlPanel, new SimpleUserAgentContext());
    htmlPanel.setHtml(sb.toString(), "", theRendererContext);
    aFrame.getContentPane().setLayout(new BorderLayout());
    aFrame.getContentPane().add(htmlPanel, BorderLayout.CENTER);
    aFrame.getContentPane().add(jPanel, BorderLayout.SOUTH);
    aFrame.setSize(new Dimension(505, size));
    Utility.setComponentRelativeLocation(this, aFrame);
    aFrame.setVisible(true);
}
Also used : SimpleHtmlRendererContext(org.lobobrowser.html.test.SimpleHtmlRendererContext) HtmlRendererContext(org.lobobrowser.html.HtmlRendererContext) SimpleHtmlRendererContext(org.lobobrowser.html.test.SimpleHtmlRendererContext) JPanel(javax.swing.JPanel) JButton(javax.swing.JButton) Sponsor(pcgen.cdom.content.Sponsor) SimpleUserAgentContext(org.lobobrowser.html.test.SimpleUserAgentContext) Dimension(java.awt.Dimension) JCheckBox(javax.swing.JCheckBox) BorderLayout(java.awt.BorderLayout) PropertyContext(pcgen.system.PropertyContext) HtmlPanel(org.lobobrowser.html.gui.HtmlPanel) JDialog(javax.swing.JDialog)

Aggregations

BorderLayout (java.awt.BorderLayout)3 Dimension (java.awt.Dimension)3 JButton (javax.swing.JButton)3 JCheckBox (javax.swing.JCheckBox)3 JDialog (javax.swing.JDialog)3 JPanel (javax.swing.JPanel)3 HtmlRendererContext (org.lobobrowser.html.HtmlRendererContext)3 HtmlPanel (org.lobobrowser.html.gui.HtmlPanel)3 SimpleHtmlRendererContext (org.lobobrowser.html.test.SimpleHtmlRendererContext)3 SimpleUserAgentContext (org.lobobrowser.html.test.SimpleUserAgentContext)3 PropertyContext (pcgen.system.PropertyContext)3 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 ItemEvent (java.awt.event.ItemEvent)1 ItemListener (java.awt.event.ItemListener)1 JLabel (javax.swing.JLabel)1 Sponsor (pcgen.cdom.content.Sponsor)1