From 75ee86cad9f42b975194b9870aa1decadae88d9c Mon Sep 17 00:00:00 2001 From: Jiri Vanek Date: Wed, 10 Jul 2013 18:31:48 +0200 Subject: Implemented new about dialogue (by Andrew Azores). Andrew added to authors --- netx/net/sourceforge/jnlp/about/AboutDialog.java | 192 +++++++++++++++++++++ netx/net/sourceforge/jnlp/about/HTMLPanel.java | 84 +++++++++ .../sourceforge/jnlp/resources/Messages.properties | 12 ++ netx/net/sourceforge/jnlp/resources/about.html | 44 +++++ netx/net/sourceforge/jnlp/resources/about.jnlp | 17 -- netx/net/sourceforge/jnlp/resources/itw_logo.png | Bin 0 -> 2191 bytes netx/net/sourceforge/jnlp/resources/jamIcon.jpg | Bin 0 -> 10580 bytes netx/net/sourceforge/jnlp/runtime/Boot.java | 72 +++----- 8 files changed, 360 insertions(+), 61 deletions(-) create mode 100644 netx/net/sourceforge/jnlp/about/AboutDialog.java create mode 100644 netx/net/sourceforge/jnlp/about/HTMLPanel.java create mode 100644 netx/net/sourceforge/jnlp/resources/about.html delete mode 100644 netx/net/sourceforge/jnlp/resources/about.jnlp create mode 100644 netx/net/sourceforge/jnlp/resources/itw_logo.png create mode 100644 netx/net/sourceforge/jnlp/resources/jamIcon.jpg (limited to 'netx/net/sourceforge') diff --git a/netx/net/sourceforge/jnlp/about/AboutDialog.java b/netx/net/sourceforge/jnlp/about/AboutDialog.java new file mode 100644 index 0000000..7ae32bc --- /dev/null +++ b/netx/net/sourceforge/jnlp/about/AboutDialog.java @@ -0,0 +1,192 @@ +/* Main.java + Copyright (C) 2008 Red Hat, Inc. + +This file is part of IcedTea. + +IcedTea is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License as published by +the Free Software Foundation, version 2. + +IcedTea is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with IcedTea; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. +*/ + +package net.sourceforge.jnlp.about; + +import static net.sourceforge.jnlp.runtime.Translator.R; + +import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.IOException; +import java.net.URL; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.border.EmptyBorder; + +import net.sourceforge.jnlp.util.ScreenFinder; + +public class AboutDialog extends JPanel implements Runnable, ActionListener { + + private static final String about_url = "/net/sourceforge/jnlp/resources/about.html"; + private static final String authors_url = "/net/sourceforge/jnlp/resources/AUTHORS.html"; + private static final String changelog_url = "/net/sourceforge/jnlp/resources/ChangeLog.html"; + 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 JPanel contentPane; + private HTMLPanel aboutPanel, authorsPanel, newsPanel, changelogPanel, copyingPanel; + private JButton aboutButton, authorsButton, newsButton, changelogButton, copyingButton; + + public AboutDialog() throws IOException { + super(new GridBagLayout()); + + frame = new JFrame("About IcedTea-Web"); + frame.setContentPane(this); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + + URL res_about = getClass().getResource(about_url); + URL res_authors = getClass().getResource(authors_url); + URL res_news = getClass().getResource(news_url); + URL res_changelog = getClass().getResource(changelog_url); + URL res_copying = getClass().getResource(copying_url); + + aboutPanel = new HTMLPanel(res_about, R("AboutDialogueTabAbout")); + authorsPanel = new HTMLPanel(res_authors, R("AboutDialogueTabAuthors")); + newsPanel = new HTMLPanel(res_news, R("News")); + changelogPanel = new HTMLPanel(res_changelog, R("AboutDialogueTabChangelog")); + copyingPanel = new HTMLPanel(res_copying, R("AboutDialogueTabGPLv2")); + + aboutButton = new JButton(aboutPanel.getIdentifier()); + aboutButton.setActionCommand(aboutPanel.getIdentifier()); + aboutButton.addActionListener(this); + + authorsButton = new JButton(authorsPanel.getIdentifier()); + authorsButton.setActionCommand(authorsPanel.getIdentifier()); + authorsButton.addActionListener(this); + + newsButton = new JButton(newsPanel.getIdentifier()); + newsButton.setActionCommand(newsPanel.getIdentifier()); + newsButton.addActionListener(this); + + changelogButton = new JButton(changelogPanel.getIdentifier()); + changelogButton.setActionCommand(changelogPanel.getIdentifier()); + changelogButton.addActionListener(this); + + copyingButton = new JButton(copyingPanel.getIdentifier()); + copyingButton.setActionCommand(copyingPanel.getIdentifier()); + copyingButton.addActionListener(this); + + contentPane = aboutPanel; + } + + @Override + public void actionPerformed(ActionEvent e) { + String action = e.getActionCommand(); + if (action.equals(((HTMLPanel) contentPane).getIdentifier())) + return; + + if (action.equals(aboutPanel.getIdentifier())) { + contentPane = aboutPanel; + } else if (action.equals(authorsPanel.getIdentifier())) { + contentPane = authorsPanel; + } else if (action.equals(newsPanel.getIdentifier())) { + contentPane = newsPanel; + } else if (action.equals(changelogPanel.getIdentifier())) { + contentPane = changelogPanel; + } else if (action.equals(copyingPanel.getIdentifier())) { + contentPane = copyingPanel; + } + + layoutWindow(); + } + + private void layoutWindow() { + this.removeAll(); + + GridBagConstraints gbc = new GridBagConstraints(); + + gbc.fill = GridBagConstraints.BOTH; + gbc.gridy = 0; + gbc.gridx = 0; + gbc.gridwidth = 5; + gbc.weightx = 1.0; + gbc.weighty = 1.0; + this.add(contentPane, gbc); + + gbc.gridy = 1; + gbc.gridx = 0; + gbc.gridwidth = 1; + gbc.ipady = 16; + this.add(aboutButton, gbc); + + gbc.gridx = 1; + this.add(authorsButton, gbc); + + gbc.gridx = 2; + this.add(newsButton, gbc); + + gbc.gridx = 3; + this.add(changelogButton, gbc); + + gbc.gridx = 4; + this.add(copyingButton, gbc); + + Dimension contentSize = new Dimension(640, 480); + contentPane.setMinimumSize(contentSize); + contentPane.setPreferredSize(contentSize); + contentPane.setBorder(new EmptyBorder(0, 0, 8, 0)); + + this.setBorder(new EmptyBorder(8, 8, 8, 8)); + + frame.pack(); + } + + @Override + public void run() { + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } catch (Exception e) { + } + + layoutWindow(); + ScreenFinder.centerWindowsToCurrentScreen(frame); + frame.setVisible(true); + } + + public static void display() throws IOException { + SwingUtilities.invokeLater(new AboutDialog()); + } + +} diff --git a/netx/net/sourceforge/jnlp/about/HTMLPanel.java b/netx/net/sourceforge/jnlp/about/HTMLPanel.java new file mode 100644 index 0000000..67c1733 --- /dev/null +++ b/netx/net/sourceforge/jnlp/about/HTMLPanel.java @@ -0,0 +1,84 @@ +/* HTMLPanel.java + Copyright (C) 2008 Red Hat, Inc. + +This file is part of IcedTea. + +IcedTea is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License as published by +the Free Software Foundation, version 2. + +IcedTea is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with IcedTea; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. +*/ + +package net.sourceforge.jnlp.about; + +import java.awt.BorderLayout; +import java.awt.Desktop; +import java.io.IOException; +import java.net.URISyntaxException; +import java.net.URL; + +import javax.swing.JEditorPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.event.HyperlinkEvent; +import javax.swing.event.HyperlinkListener; + +public class HTMLPanel extends JPanel { + + private String id; + + public HTMLPanel(URL url, String identifier) throws IOException { + super(new BorderLayout()); + id = identifier; + JEditorPane pane = new JEditorPane(url); + pane.setContentType("text/html"); + pane.setEditable(false); + pane.addHyperlinkListener(new UrlHyperlinkListener()); + JScrollPane scroller = new JScrollPane(pane); + this.add(scroller, BorderLayout.CENTER); + } + + public String getIdentifier() { + return id; + } + + private class UrlHyperlinkListener implements HyperlinkListener { + @Override + public void hyperlinkUpdate(HyperlinkEvent event) { + if (Desktop.isDesktopSupported() && event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { + try { + Desktop.getDesktop().browse(event.getURL().toURI()); + } catch (URISyntaxException ex) { + } catch (IOException ex) { + } + } + } + } + +} diff --git a/netx/net/sourceforge/jnlp/resources/Messages.properties b/netx/net/sourceforge/jnlp/resources/Messages.properties index d0de783..232f7d0 100644 --- a/netx/net/sourceforge/jnlp/resources/Messages.properties +++ b/netx/net/sourceforge/jnlp/resources/Messages.properties @@ -33,6 +33,13 @@ Username=Username: Value=Value Version=Version +#about dialogue +AboutDialogueTabAbout=About +AboutDialogueTabAuthors=Authors +AboutDialogueTabChangelog=Changelog +AboutDialogueTabNews=News +AboutDialogueTabGPLv2=GPLv2 + # LS - Severity LSMinor=Minor LSFatal=Fatal @@ -138,6 +145,7 @@ PBadHeapSize=Invalid value for heap size ({0}) # Runtime BLaunchAbout=Launching about window... +BLaunchAboutFailure=Was not able to launch About window BNeedsFile=Must specify a .jnlp file RNoAboutJnlp=Unable to find about.jnlp BFileLoc=JNLP file location @@ -172,6 +180,10 @@ RProxyFirefoxOptionNotImplemented=Browser proxy option "{0}" ({1}) not supported RBrowserLocationPromptTitle=Browser Location RBrowserLocationPromptMessage=Specify Browser Location RBrowserLocationPromptMessageWithReason=Specify Browser Location (the browser command "{0}" is invalid). +BAboutITW=The IcedTea-Web project provides a Free Software web browser plugin running applets written in the Java programming language and an implementation of Java Web Start, originally based on the NetX project. Visit the IcedTea-Web homepage: http://icedtea.classpath.org/wiki/IcedTea-Web . Use "man javaws" or "javaws -help" for more information. +BFileInfoAuthors=Names and email addresses of contributors to this project can be found in the file AUTHORS in the IcedTea-Web root directory. +BFileInfoCopying=The full GPLv2 license of this project can be found in the file COPYING in the IcedTea-Web root directory. +BFileInfoNews=News about releases of this project can be found in the file NEWS in the IcedTea-Web root directory. # Boot options, message should be shorter than this ----------------> BOUsage=javaws [-run-options] diff --git a/netx/net/sourceforge/jnlp/resources/about.html b/netx/net/sourceforge/jnlp/resources/about.html new file mode 100644 index 0000000..73674d2 --- /dev/null +++ b/netx/net/sourceforge/jnlp/resources/about.html @@ -0,0 +1,44 @@ + + + + + + + +
IcedTea-Web Logo

+ IcedTea-Web provides a Free Software web browser plugin running applets + written in the Java programming language and an implementation of Java Web Start, originally based on the NetX project. +

NetX allows Java applets and applications to be downloaded over the + network, cached, and (by default) run in a secure sandbox environment. Subsequent runs of the applet + download the latest version automatically. Update and security settings, among others, can be set using the itw-settings command. +
IcedTea-Web also includes a plugin to enable Java applets + within web browsers. +

+

+ Features of NetX: +

+ + Visit the IcedTea project wiki + or specifically the IcedTea-Web home pages for more information. +
Help with common issues with IcedTea-Web can be found here. +

+ Contributing: +

+
+ A QuickStart guide for the IcedTea project is available on the wiki. + Code style guidelines and + Eclipse setup instructions for IcedTea-Web + are available as well. Patches should be accompanied by unit tests and + reproducers before being sent to + the mailing list. + + + diff --git a/netx/net/sourceforge/jnlp/resources/about.jnlp b/netx/net/sourceforge/jnlp/resources/about.jnlp deleted file mode 100644 index 44763b6..0000000 --- a/netx/net/sourceforge/jnlp/resources/about.jnlp +++ /dev/null @@ -1,17 +0,0 @@ - - - - About window for NetX - NetX - - Displays information about NetX - - - - - - - - - - diff --git a/netx/net/sourceforge/jnlp/resources/itw_logo.png b/netx/net/sourceforge/jnlp/resources/itw_logo.png new file mode 100644 index 0000000..1886f0f Binary files /dev/null and b/netx/net/sourceforge/jnlp/resources/itw_logo.png differ diff --git a/netx/net/sourceforge/jnlp/resources/jamIcon.jpg b/netx/net/sourceforge/jnlp/resources/jamIcon.jpg new file mode 100644 index 0000000..6a827c7 Binary files /dev/null and b/netx/net/sourceforge/jnlp/resources/jamIcon.jpg differ diff --git a/netx/net/sourceforge/jnlp/runtime/Boot.java b/netx/net/sourceforge/jnlp/runtime/Boot.java index 76a95ce..76b89b4 100644 --- a/netx/net/sourceforge/jnlp/runtime/Boot.java +++ b/netx/net/sourceforge/jnlp/runtime/Boot.java @@ -19,6 +19,7 @@ package net.sourceforge.jnlp.runtime; import static net.sourceforge.jnlp.runtime.Translator.R; import java.io.File; +import java.io.IOException; import java.net.URL; import java.security.AccessController; import java.security.PrivilegedAction; @@ -31,6 +32,7 @@ import java.util.Map; import net.sourceforge.jnlp.LaunchException; import net.sourceforge.jnlp.Launcher; import net.sourceforge.jnlp.ParserSettings; +import net.sourceforge.jnlp.about.AboutDialog; import net.sourceforge.jnlp.cache.CacheUtil; import net.sourceforge.jnlp.cache.UpdatePolicy; import net.sourceforge.jnlp.security.viewer.CertificateViewer; @@ -58,12 +60,6 @@ public final class Boot implements PrivilegedAction { public static final String name = Boot.class.getPackage().getImplementationTitle(); public static final String version = Boot.class.getPackage().getImplementationVersion(); - /** the text to display before launching the about link */ - private static final String aboutMessage = "" - + name + " " + version - + "\n" - + R("BLaunchAbout"); - private static final String miniLicense = "\n" + " netx - an open-source JNLP client.\n" + " Copyright (C) 2001-2003 Jon A. Maxwell (JAM)\n" @@ -83,6 +79,17 @@ public final class Boot implements PrivilegedAction { + " Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n" + "\n"; + private static final String itwInfoMessage = "" + + name + " " + version + + "\n\n* " + + R("BAboutITW") + + "\n* " + + R("BFileInfoAuthors") + + "\n* " + + R("BFileInfoNews") + + "\n* " + + R("BFileInfoCopying"); + private static final String helpMessage = "\n" + "Usage: " + R("BOUsage") + "\n" + " " + R("BOUsage2") + "\n" @@ -143,8 +150,21 @@ public final class Boot implements PrivilegedAction { System.exit(0); } - if (null != getOption("-about")) - System.out.println(aboutMessage); + if (null != getOption("-about")) { + System.out.println(itwInfoMessage); + if (null != getOption("-headless")) { + System.exit(0); + } else { + System.out.println(R("BLaunchAbout")); + try { + AboutDialog.display(); + return; + } catch (IOException e) { + System.out.println(R("BLaunchAboutFailure")); + throw new RuntimeException(e); + } + } + } if (null != getOption("-verbose")) JNLPRuntime.setDebug(true); @@ -233,33 +253,6 @@ public final class Boot implements PrivilegedAction { System.exit(1); } - /** - * Returns the location of the about.jnlp file or null if this file - * does not exist. - */ - private static String getAboutFile() { - ClassLoader cl = Boot.class.getClassLoader(); - if (cl == null) { - cl = ClassLoader.getSystemClassLoader(); - } - try { - //extracts full path to about.jnlp - String s = cl.getResource("net/sourceforge/jnlp/runtime/Boot.class").toString(); - s=s.substring(0,s.indexOf("!")); - s=s.substring(s.indexOf(":")+1); - s=s.substring(s.indexOf(":")+1); - s="file://"+s.replace("netx.jar","about.jnlp"); - if (JNLPRuntime.isDebug()){ - System.out.println("Using " + s + " as about.jnlp URL"); - } - - return s; - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - /** * Returns the url of file to open; does not return if no file was * specified, or if the file location was invalid. @@ -268,15 +261,6 @@ public final class Boot implements PrivilegedAction { String location = getJNLPFile(); - // override -jnlp with aboutFile - if (getOption("-about") != null) { - location = getAboutFile(); - if (location == null) - fatalError(R("RNoAboutJnlp")); - } else { - location = getJNLPFile(); - } - if (location == null) { System.out.println(helpMessage); System.exit(1); -- cgit v1.2.3