Merge pull request #1109 from JoePfeiffer/fix-1079

Fix 1079
This commit is contained in:
SiboVG 2022-02-10 17:37:32 +01:00 committed by GitHub
commit 1a68225cf3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 255 additions and 73 deletions

View File

@ -1,6 +1,6 @@
OpenRocket - A model rocket simulator
Copyright (C) 2007-2020 Sampo Niskanen and others
Copyright (C) 2007-2022 Sampo Niskanen and others
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@ -69,7 +69,7 @@
<!-- Include metafiles about OR -->
<fileset dir="${basedir}" includes="LICENSE.TXT README.TXT ChangeLog ReleaseNotes fileformat.txt" />
<fileset dir="${basedir}/.." includes="LICENSE.TXT README.md ChangeLog ReleaseNotes.md fileformat.txt" />
</jar>
</target>

View File

@ -4,7 +4,7 @@ build.version=20.11.alpha.16
# The copyright year for the build. Displayed in the about dialog.
# Will show as Copyright 2013-${build.copyright}
build.copyright=2021
build.copyright=2022
# The source of the package. When building a package for a specific
# distribution (Debian, Fedora etc.), this should be changed appropriately!

View File

@ -200,6 +200,10 @@ the .jar file
<copy todir="${resources.dir}/datafiles/presets">
<fileset dir="${resources-src.dir}/datafiles/components/orc"/>
</copy>
<copy
file="${resources-src.dir}/datafiles/components/LICENSE"
todir="${resources.dir}/datafiles/presets">
</copy>
</target>
<!-- DIST-SRC -->

View File

@ -1,16 +1,30 @@
package net.sf.openrocket.gui.components;
import java.awt.Color;
import java.awt.Desktop;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Rectangle;
import java.net.URI;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import javax.swing.JEditorPane;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants;
import javax.swing.SwingUtilities;
import net.sf.openrocket.util.BugException;
@SuppressWarnings("serial")
public class DescriptionArea extends JScrollPane {
@ -65,7 +79,71 @@ public class DescriptionArea extends JScrollPane {
Font font = editorPane.getFont();
editorPane.setFont(font.deriveFont(font.getSize2D() + size));
editorPane.setEditable(false);
editorPane.addHyperlinkListener(new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent e) {
if(e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
URI uri = null;
try {
uri = e.getURL().toURI();
}
catch (Exception ex) {
throw new RuntimeException(ex);
}
// If the uri scheme indicates this is a resource in a jar file,
// extract and write to a temporary file
if (uri.getScheme().equals("jar")) {
// get the resource
final String uriString = uri.toString();
final String resourceName = uriString.substring(uriString.indexOf("!") + 1);
final BufferedInputStream is = new BufferedInputStream(getClass().getResourceAsStream(resourceName));
// construct filename from resource name
String prefix = resourceName.substring(1);
String suffix;
final int dotIndex = prefix.lastIndexOf(".");
if (dotIndex > 0) {
prefix = resourceName.substring(0, dotIndex);
suffix = resourceName.substring(dotIndex+1);
} else {
// if there is no suffix, assume it's a raw text file.
suffix = ".txt";
}
// create temporary file and copy resource to it
File of = null;
BufferedOutputStream os = null;
try {
of = File.createTempFile(prefix, suffix);
os = new BufferedOutputStream(new FileOutputStream(of));
}
catch (Exception ex) {
throw new RuntimeException(ex);
}
of.deleteOnExit();
uri = of.toURI();
try {
byte buffer[] = is.readAllBytes();
os.write(buffer);
os.close();
}
catch (Exception ex) {
throw new RuntimeException(ex);
}
}
try {
Desktop.getDesktop().browse(uri);
}
catch (Exception ex) {
throw new RuntimeException(ex);
}
}
}
});
if (!opaque) {
Color bg = new JPanel().getBackground();
editorPane.setBackground(new Color(bg.getRed(), bg.getGreen(), bg.getBlue()));
@ -84,7 +162,6 @@ public class DescriptionArea extends JScrollPane {
Dimension dim = editorPane.getPreferredSize();
dim.height = lineheight * rows + extraheight + 2;
this.setPreferredSize(dim);
this.setViewportView(editorPane);
this.setText(text);

View File

@ -25,42 +25,58 @@ import net.sf.openrocket.gui.widgets.SelectColorButton;
@SuppressWarnings("serial")
public class AboutDialog extends JDialog {
public static final String OPENROCKET_URL = "http://openrocket.info/";
private static final Translator trans = Application.getTranslator();
public final String OPENROCKET_URL = "http://openrocket.info/";
private final Translator trans = Application.getTranslator();
private static final String CREDITS = "<html><center>" +
"<font size=\"+1\"><b>OpenRocket has been developed by:</b></font><br><br>" +
"Sampo Niskanen (main developer)<br>" +
"Doug Pedrick (RockSim file format, printing)<br>" +
"Kevin Ruland (Android version)<br>" +
"Bill Kuker (3D visualization)<br>" +
"Boris du Reau (internationalization, translation lead)<br>" +
"Richard Graham (geodetic computations)<br>" +
"Jason Blood (finset import)<br>" +
"Daniel Williams (pod support, maintainer)<br>" +
"Joe Pfeiffer (maintainer)<br>" +
"Billy Olsen (maintainer)<br>" +
"Neil Weinstock (tester, icons, forum support)<br>" +
"H. Craig Miller (tester)<br><br>" +
"<b>Translations by:</b><br><br>" +
"Tripoli France (French)<br>" +
"Stefan Lobas / ERIG e.V. (German)<br>" +
"Tripoli Spain (Spanish)<br>" +
"Sky Dart Team (Russian)<br>" +
"Mauro Biasutti (Italian)<br>" +
"Vladimir Beran (Czech)<br>" +
"Polish Rocketry Society / \u0141ukasz & Alex Kazanski (Polish)<br>" +
"Sibo Van Gool (Dutch)<br><br>" +
"See all contributors at <br>https://github.com/openrocket/openrocket/graphs/contributors<br><br>" +
"<b>OpenRocket utilizes the following libraries:</b><br><br>" +
"MiG Layout (http://www.miglayout.com/)<br>" +
"JFreeChart (http://www.jfree.org/jfreechart/)<br>" +
"iText (http://www.itextpdf.com/)<br>" +
"exp4j (http://projects.congrace.de/exp4j/index.html)<br>" +
"JOGL (http://jogamp.org/jogl/www/)<br>" +
"Guava (https://github.com/google/guava)<br>" +
"Opencsv (http://opencsv.sourceforge.net/)<br>" +
"Simple Logging Facade for Java (http://www.slf4j.org/)";
private final String CREDITS = "<html><center>" +
"<font size=\"+1\"><b>OpenRocket has been developed by:</b></font><br>" +
"<br>" +
"Sampo Niskanen (main developer)<br>" +
"Doug Pedrick (RockSim file format, printing)<br>" +
"Kevin Ruland (Android version)<br>" +
"Bill Kuker (3D visualization)<br>" +
"Boris du Reau (internationalization, translation lead)<br>" +
"Richard Graham (geodetic computations)<br>" +
"Jason Blood (finset import)<br>" +
"Daniel Williams (pod support, maintainer)<br>" +
"Joe Pfeiffer (maintainer)<br>" +
"Billy Olsen (maintainer)<br>" +
"Neil Weinstock (tester, icons, forum support)<br>" +
"H. Craig Miller (tester)<br><br>" +
"<b>Translations by:</b><br><br>" +
"Tripoli France (French)<br>" +
"Stefan Lobas / ERIG e.V. (German)<br>" +
"Tripoli Spain (Spanish)<br>" +
"Sky Dart Team (Russian)<br>" +
"Mauro Biasutti (Italian)<br>" +
"Vladimir Beran (Czech)<br>" +
"Polish Rocketry Society / \u0141ukasz & Alex Kazanski (Polish)<br>" +
"Sibo Van Gool (Dutch)<br>" +
"<br>" +
"See all contributors at <br>" +
href("https://github.com/openrocket/openrocket/graphs/contributors") + "<br>" +
"<br>" +
"<b>OpenRocket utilizes the following libraries:</b><br>" +
"<br>" +
"MiG Layout (" + href("http://www.miglayout.com/") + ")<br>" +
"JFreeChart (" + href("http://www.jfree.org/jfreechart/") + ")<br>" +
"iText (" + href("http://www.itextpdf.com/") + ")<br>" +
"exp4j (" + href("http://projects.congrace.de/exp4j/index.html") + ")<br>" +
"JOGL (" + href("http://jogamp.org/jogl/www/") + ")<br>" +
"Guava (" + href("https://github.com/google/guava") + ")<br>" +
"Opencsv (" + href("http://opencsv.sourceforge.net/") + ")<br>" +
"Simple Logging Facade for Java (" + href("http://www.slf4j.org/") + ")<br>" +
"Java library for parsing and rendering CommonMark (" + href("https://github.com/commonmark/commonmark-java") + ")<br>" +
"<br>" +
"<b>OpenRocket gratefully acknowledges our use of the following databases:</b><br>" +
"<br>" +
"Rocket Motor Data (" + href("https://www.thrustcurve.org/") + ")<br>" +
"Enhanced components database for OpenRocket" + href("https://github.com/dbcook/openrocket-database/") + ")<br>";
private String href(String url) {
return "<a href=\"" + url + "\">" + url + "</a>";
}
public AboutDialog(JFrame parent) {
super(parent, true);

View File

@ -3,66 +3,151 @@ package net.sf.openrocket.gui.dialogs;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URL;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import net.miginfocom.swing.MigLayout;
import net.sf.openrocket.gui.components.DescriptionArea;
import net.sf.openrocket.gui.components.StyledLabel;
import net.sf.openrocket.gui.util.GUIUtil;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.startup.Application;
import net.sf.openrocket.gui.util.Icons;
import net.sf.openrocket.gui.widgets.SelectColorButton;
import net.sf.openrocket.util.BuildProperties;
import net.sf.openrocket.util.Chars;
public class LicenseDialog extends JDialog {
private static final String LICENSE_FILENAME = "LICENSE.TXT";
private static final Translator trans = Application.getTranslator();
private static final String DEFAULT_LICENSE_TEXT =
"\n" +
"Error: Unable to load " + LICENSE_FILENAME + "!\n" +
"\n" +
"OpenRocket is licensed under the GNU GPL version 3, with additional permissions.\n" +
"See http://openrocket.sourceforge.net/ for details.";
public LicenseDialog(JFrame parent) {
super(parent, true);
JPanel panel = new JPanel(new MigLayout("fill"));
panel.add(new StyledLabel("OpenRocket license", 10), "ax 50%, wrap para");
String licenseText;
try {
BufferedReader reader = new BufferedReader(
new InputStreamReader(ClassLoader.getSystemResourceAsStream(LICENSE_FILENAME)));
StringBuffer sb = new StringBuffer();
for (String s = reader.readLine(); s != null; s = reader.readLine()) {
sb.append(s);
sb.append('\n');
}
licenseText = sb.toString();
} catch (IOException e) {
licenseText = DEFAULT_LICENSE_TEXT;
}
// OpenRocket logo
panel.add(new JLabel(Icons.loadImageIcon("pix/icon/icon-about.png", "OpenRocket")), "top");
JTextArea text = new JTextArea(licenseText);
text.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
text.setRows(20);
text.setColumns(80);
text.setEditable(false);
panel.add(new JScrollPane(text),"grow, wrap para");
panel.add(new StyledLabel("Software Licenses", 10), "ax 50%, wrap para");
final String jarUrl = "jar:" + getClass().getProtectionDomain().getCodeSource().getLocation().toString();
final String copyrightYear = BuildProperties.getCopyrightYear();
/*****************************************************************************************************************************/
/* */
/* LICENSE TEXT: each of the licenses we're using is described here. At the end, they are all concatenated for insertion */
/* in the description window */
/* */
/*****************************************************************************************************************************/
/*****************************************************************************************************************************/
/* GPL: overall project */
/*****************************************************************************************************************************/
final String orLicense = "<strong>GNU GENERAL PUBLIC LICENSE</strong>" + "<br>" +
"<br>" +
"OpenRocket - A model rocket simulator<br>" +
"Copyright " + Chars.COPY + " 2007-" + copyrightYear + " Sampo Niskanen and others<br>" +
"Project page: <a href=\"https://openrocket.info/\">https://openrocket.info/</a><br>" +
"<br>" +
"This program 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, either version 3 " +
"of the License, or any later version. " +
"The license may be viewed " +
"<a href=\"" + jarUrl + "!/LICENSE.TXT\">here</a>.<br>" +
"<br>" +
"This program 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.<br>" +
"<br>" +
"You should have received a copy of the GNU Public License along with this program. If not, you may obtain a copy at " +
"<a href=\"https://www.gnu.org/licenses/gpl-3.0.html\">https://www.gnu.org/licenses/gpl-3.0.html</a><br>" +
"<br>" +
"OpenRocket developers may be contacted electronically at:<br>" +
"<a href=\"mailto:openrocket-devel@lists.sourceforge.net\">mailto:openrocket-devel@lists.sourceforge.net</a><br>" +
"<a href=\"https://openrocket.slack.com\">https://openrocket.slack.com</a><br>" +
"<a href=\"https://github.com/openrocket\">https://github.com/openrocket</a><br>" +
"<br>";
/*****************************************************************************************************************************/
/* APACHE: components library */
/*****************************************************************************************************************************/
final String componentsLicense =
"<strong>APACHE LICENSE</strong><br>" +
"<br>" +
"OpenRocket features the enhanced components database created by David B. Cook<br>" +
"Copyright " + Chars.COPY + " 2015-" + copyrightYear + " David B. Cook<br>" +
"Project page: <a href=\"https://github.com/dbcook/openrocket-database\">https://github.com/dbcook/openrocket-database</a><br>" +
"<br>" +
"Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this work except in compliance with the License. " +
"You may view the License " +
"<a href=\"" + jarUrl + "!/datafiles/presets/LICENSE\">here</a>.<br>" +
"You may also obtain a copy of the License at " +
"<a href=\"http://www.apache.org/licenses/LICENSE-2.0\">http://www.apache.org/licenses/LICENSE-2.0</a><br>" +
"<br>" +
"OpenRocket uses the Work or Derivative Works of Ant, a product which includes software developed by the Apache " +
"Software Foundation<br>" +
"<br>" +
"Ant also includes software developed by:" +
"<ul style=\"margin-top: 0;\">" +
"<li>the W3C Consortium (<a href=\"http://www.w3c.org\">http://www.w3c.org</a>)</li>" +
"<li>the SAX project (<a href=\"http://www.saxproject.org\">http://www.saxproject.org</a></li>" +
"</ul>" +
"The names \"Ant\" and \"Apache Software Foundation\" must not be used to endorse or " +
"promote products derived from this software without prior written permission. For written permission, "+
"please contact <a href=\"mailto:apache@apache.org\">apache@apache.org</a>.<br>" +
"<br>";
/*****************************************************************************************************************************/
/* BITSTREAM VERA: Deja Vu font */
/*****************************************************************************************************************************/
final String fontLicense =
"<strong>BITSTREAM VERA FONT LICENSE</strong><br>" +
"<br>" +
"OpenRocket makes use of the DejaVu Serif Font<br>" +
"Fonts are Copyright " + Chars.COPY + " 2003 by Bitstream, Inc. All Rights Reserved. " +
"Bitstream Vera is a trademark of Bitstream, Inc.<br>" +
"DejaVu changes are in the public domain<br>" +
"Glyphs imported from Arev Fonts Copyright " + Chars.COPY + " 2006 by Tavmjong Bah. All Rights Reserved.<br>" +
"Project page: <a href=\"https://github.com/dejavu-fonts/dejavu-fonts/\">https://github.com/dejavu-fonts/dejavu-fonts/<a/><br>" +
"<br>" +
"Licensed according to the Bitstream Vera Font License which may be found " +
"<a href=\"" + jarUrl + "!/dejavu-font/LICENSE\">here</a>." +
"<br>" +
"You may also obtain a copy of the License at " +
"<a href=\"https://github.com/dejavu-fonts/dejavu-fonts/blob/master/LICENSE\">https://github.com/dejavu-fonts/dejavu-fonts/blob/master/LICENSE</a><br>" +
"<br>";
/*****************************************************************************************************************************/
/* BSD 2-Clause: commonmark-java library */
/*****************************************************************************************************************************/
final String commonmarkLicense =
"<strong>BSD 2-Clause License</strong><br>" +
"<br>" +
"OpenRocket makes use of the Commonmark-Java Library<br>" +
"Copyright " + Chars.COPY + " 2015-2016 Atlassian Pty Ltd. All rights reserved.<br>" +
"Project page: <a href=\"https://github.com/commonmark/commonmark-java/\">https://github.com/commonmark/commonmark-java/<a/><br>" +
"<br>" +
"You may obtain a copy of the License at <a href=\"https://github.com/commonmark/commonmark-java/blob/main/LICENSE.txt\">https://github.com/commonmark/commonmark-java/blob/main/LICENSE.txt</a>." +
"<br>";
/*****************************************************************************************************************************/
/* End of license text */
/*****************************************************************************************************************************/
DescriptionArea info = new DescriptionArea(20);
info.setText(orLicense + componentsLicense + fontLicense + commonmarkLicense);
panel.add(info, "newline, width 600lp, height 150lp, grow, spanx, wrap para");
//Close button
JButton close = new SelectColorButton(trans.get("dlg.but.close"));