diff options
author | Jiri Vanek <[email protected]> | 2013-07-17 18:59:39 +0200 |
---|---|---|
committer | Jiri Vanek <[email protected]> | 2013-07-17 18:59:39 +0200 |
commit | 0fe719f17d81f95491b939f23b5d5c3111f7c427 (patch) | |
tree | 25f1bbb19fb3b6f9d7d83c62881bbf5bbb664703 /netx/net/sourceforge/jnlp | |
parent | 26dd00c0e206323d17c4b84adeda1cb43084a7a2 (diff) |
About dialogue made accessible from plugin
Diffstat (limited to 'netx/net/sourceforge/jnlp')
5 files changed, 88 insertions, 11 deletions
diff --git a/netx/net/sourceforge/jnlp/about/AboutDialog.java b/netx/net/sourceforge/jnlp/about/AboutDialog.java index 136b53e..8a14384 100644 --- a/netx/net/sourceforge/jnlp/about/AboutDialog.java +++ b/netx/net/sourceforge/jnlp/about/AboutDialog.java @@ -40,6 +40,7 @@ package net.sourceforge.jnlp.about; import static net.sourceforge.jnlp.runtime.Translator.R; import java.awt.Dimension; +import java.awt.Frame; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.event.ActionEvent; @@ -48,7 +49,7 @@ import java.io.IOException; import java.net.URL; import javax.swing.JButton; -import javax.swing.JFrame; +import javax.swing.JDialog; import javax.swing.JPanel; import javax.swing.SwingUtilities; import javax.swing.UIManager; @@ -64,17 +65,17 @@ public class AboutDialog extends JPanel implements Runnable, ActionListener { private static final String copying_url = "/net/sourceforge/jnlp/resources/COPYING.html"; private static final String news_url = "/net/sourceforge/jnlp/resources/NEWS.html"; - private JFrame frame; + private JDialog frame; private JPanel contentPane; private HTMLPanel aboutPanel, authorsPanel, newsPanel, changelogPanel, copyingPanel; private JButton aboutButton, authorsButton, newsButton, changelogButton, copyingButton; - public AboutDialog() throws IOException { + public AboutDialog(boolean modal) throws IOException { super(new GridBagLayout()); - frame = new JFrame("About IcedTea-Web"); + frame = new JDialog((Frame)null, R("AboutDialogueTabAbout") + " IcedTea-Web", modal); frame.setContentPane(this); - frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + frame.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); URL res_about = getClass().getResource(about_url); URL res_authors = getClass().getResource(authors_url); @@ -186,7 +187,10 @@ public class AboutDialog extends JPanel implements Runnable, ActionListener { } public static void display() throws IOException { - SwingUtilities.invokeLater(new AboutDialog()); + display(false); + } + public static void display(boolean modal) throws IOException { + SwingUtilities.invokeLater(new AboutDialog(modal)); } } diff --git a/netx/net/sourceforge/jnlp/about/HTMLPanel.java b/netx/net/sourceforge/jnlp/about/HTMLPanel.java index 67c1733..c68321a 100644 --- a/netx/net/sourceforge/jnlp/about/HTMLPanel.java +++ b/netx/net/sourceforge/jnlp/about/HTMLPanel.java @@ -56,7 +56,13 @@ public class HTMLPanel extends JPanel { public HTMLPanel(URL url, String identifier) throws IOException { super(new BorderLayout()); id = identifier; - JEditorPane pane = new JEditorPane(url); + JEditorPane pane = new JEditorPane(); + try{ + pane = new JEditorPane(url); + } catch(Exception ex){ + //no need to have invalid url fatal + ex.printStackTrace(); + } pane.setContentType("text/html"); pane.setEditable(false); pane.addHyperlinkListener(new UrlHyperlinkListener()); diff --git a/netx/net/sourceforge/jnlp/splashscreen/impls/DefaultSplashScreens2012Commons.java b/netx/net/sourceforge/jnlp/splashscreen/impls/DefaultSplashScreens2012Commons.java index a22d943..8888217 100644 --- a/netx/net/sourceforge/jnlp/splashscreen/impls/DefaultSplashScreens2012Commons.java +++ b/netx/net/sourceforge/jnlp/splashscreen/impls/DefaultSplashScreens2012Commons.java @@ -42,6 +42,7 @@ import java.awt.event.ComponentEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.Observable; +import net.sourceforge.jnlp.about.AboutDialog; import net.sourceforge.jnlp.splashscreen.impls.defaultsplashscreen2012.BasePainter; import net.sourceforge.jnlp.splashscreen.parts.BasicComponentSplashScreen; @@ -63,6 +64,19 @@ public final class DefaultSplashScreens2012Commons { parent.repaint(); } }); + parent.addMouseListener(new MouseAdapter() { + + @Override + public void mouseClicked(MouseEvent e) { + if (e.getY() < painter.getAboutOfset().y && e.getX() > (painter.getAboutOfset().x)) { + try { + AboutDialog.display(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } + }); // Add a new listener for resizes parent.addComponentListener(new ComponentAdapter() { // Re-adjust variables based on size diff --git a/netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainter.java b/netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainter.java index 2b14085..510ae00 100644 --- a/netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainter.java +++ b/netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainter.java @@ -36,13 +36,16 @@ obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ package net.sourceforge.jnlp.splashscreen.impls.defaultsplashscreen2012; +import java.awt.BasicStroke; import net.sourceforge.jnlp.splashscreen.impls.*; import java.awt.Color; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Graphics2D; +import java.awt.Point; import java.awt.RenderingHints; +import java.awt.Stroke; import java.awt.Toolkit; import java.awt.font.TextAttribute; import java.awt.image.BufferedImage; @@ -54,6 +57,7 @@ import java.util.Observable; import java.util.Observer; import javax.swing.SwingUtilities; +import net.sourceforge.jnlp.runtime.Translator; import net.sourceforge.jnlp.splashscreen.SplashUtils.SplashReason; import net.sourceforge.jnlp.splashscreen.parts.BasicComponentSplashScreen; import net.sourceforge.jnlp.splashscreen.parts.InfoItem; @@ -115,6 +119,14 @@ public class BasePainter implements Observer { protected TextWithWaterLevel twl; protected TextWithWaterLevel oldTwl; protected boolean canWave = true; + private Point aboutOfset = new Point(); + + private final static float dash1[] = {10.0f}; + private final static BasicStroke dashed = + new BasicStroke(1.0f, + BasicStroke.CAP_BUTT, + BasicStroke.JOIN_MITER, + 10.0f, dash1, 0.0f); protected void paintNiceTexts(Graphics2D g2d) { //the only animated stuff @@ -510,11 +522,22 @@ public class BasePainter implements Observer { g2d.setColor(plainTextColor); FontMetrics fm = g2d.getFontMetrics(); if (version != null) { - String niceVersion=stripCommitFromVersion(version); + String aboutPrefix = Translator.R("AboutDialogueTabAbout") + ": "; + int aboutPrefixWidth = fm.stringWidth(aboutPrefix); + String niceVersion = stripCommitFromVersion(version); int y = master.getSplashWidth() - fm.stringWidth(niceVersion + " "); if (y < 0) { y = 0; } + if (y > aboutPrefixWidth) { + niceVersion = aboutPrefix + niceVersion; + y -= aboutPrefixWidth; + } + aboutOfset = new Point(y, fm.getHeight()); + Stroke backup = g2d.getStroke(); + g2d.setStroke(dashed); + g2d.drawRect(aboutOfset.x-1,1, master.getSplashWidth()-aboutOfset.x-1, aboutOfset.y+1); + g2d.setStroke(backup); g2d.drawString(niceVersion, y, fm.getHeight()); } return fm; @@ -550,4 +573,16 @@ public class BasePainter implements Observer { ex.printStackTrace(); } } + + public BasicComponentSplashScreen getMaster() { + return master; + } + + public Point getAboutOfset() { + return aboutOfset; + } + + + + } diff --git a/netx/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialog.java b/netx/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialog.java index 5d1e349..e7e1779 100644 --- a/netx/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialog.java +++ b/netx/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialog.java @@ -63,6 +63,7 @@ import javax.swing.WindowConstants; import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkListener; import net.sourceforge.jnlp.LaunchException; +import net.sourceforge.jnlp.about.AboutDialog; import net.sourceforge.jnlp.runtime.Translator; public class JEditorPaneBasedExceptionDialog extends JDialog implements HyperlinkListener { @@ -71,6 +72,7 @@ public class JEditorPaneBasedExceptionDialog extends JDialog implements Hyperlin private JButton closeButton; private JButton closeAndCopyButton; private JButton homeButton; + private JButton aboutButton; private JEditorPane htmlErrorAndHelpPanel; private JLabel exceptionLabel; private JLabel iconLabel; @@ -138,6 +140,7 @@ public class JEditorPaneBasedExceptionDialog extends JDialog implements Hyperlin htmlPaneScroller = new JScrollPane(); htmlErrorAndHelpPanel = new JEditorPane(); homeButton = new JButton(); + aboutButton = new JButton(); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); @@ -162,9 +165,9 @@ public class JEditorPaneBasedExceptionDialog extends JDialog implements Hyperlin GroupLayout jPanel2Layout = new GroupLayout(topPanel); topPanel.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( - jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(jPanel2Layout.createSequentialGroup().addContainerGap().addComponent(closeButton).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 314, Short.MAX_VALUE).addComponent(closeAndCopyButton).addContainerGap())); + jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(jPanel2Layout.createSequentialGroup().addContainerGap().addComponent(closeButton).addContainerGap().addComponent(aboutButton).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 314, Short.MAX_VALUE).addComponent(closeAndCopyButton).addContainerGap())); jPanel2Layout.setVerticalGroup( - jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup().addContainerGap(24, Short.MAX_VALUE).addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(closeButton).addComponent(closeAndCopyButton)).addContainerGap())); + jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup().addContainerGap(24, Short.MAX_VALUE).addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(closeButton).addComponent(aboutButton).addComponent(closeAndCopyButton)).addContainerGap())); exceptionLabel.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N exceptionLabel.setHorizontalAlignment(SwingConstants.CENTER); @@ -186,13 +189,28 @@ public class JEditorPaneBasedExceptionDialog extends JDialog implements Hyperlin } }); + + aboutButton.setText(Translator.R("AboutDialogueTabAbout")); + aboutButton.addActionListener(new java.awt.event.ActionListener() { + + @Override + public void actionPerformed(java.awt.event.ActionEvent evt) { + try{ + AboutDialog.display(true); + }catch(Exception ex){ + ex.printStackTrace(); + JOptionPane.showConfirmDialog(JEditorPaneBasedExceptionDialog.this, ex); + } + } + }); + GroupLayout jPanel1Layout = new GroupLayout(mainPanel); mainPanel.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addComponent(iconLabel, GroupLayout.PREFERRED_SIZE, 71, GroupLayout.PREFERRED_SIZE).addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addComponent(exceptionLabel, GroupLayout.DEFAULT_SIZE, 503, Short.MAX_VALUE).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(homeButton, GroupLayout.PREFERRED_SIZE, 101, GroupLayout.PREFERRED_SIZE).addContainerGap()).addComponent(bottomPanel, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 723, Short.MAX_VALUE)); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(iconLabel, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE).addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(exceptionLabel, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE).addComponent(homeButton, GroupLayout.PREFERRED_SIZE, 64, GroupLayout.PREFERRED_SIZE))).addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addComponent(bottomPanel, GroupLayout.DEFAULT_SIZE, 158, Short.MAX_VALUE))); - + GroupLayout layout = new GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( |