Merge pull request #1918 from SiboVG/unstable

Uniform bug report info section + add user-defined thrust curves location
This commit is contained in:
Joe Pfeiffer 2022-12-24 10:56:23 -07:00 committed by GitHub
commit bf8ddca6ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 51 additions and 53 deletions

View File

@ -27,6 +27,7 @@ import net.miginfocom.swing.MigLayout;
import net.sf.openrocket.gui.components.StyledLabel; import net.sf.openrocket.gui.components.StyledLabel;
import net.sf.openrocket.gui.components.URLLabel; import net.sf.openrocket.gui.components.URLLabel;
import net.sf.openrocket.gui.util.GUIUtil; import net.sf.openrocket.gui.util.GUIUtil;
import net.sf.openrocket.gui.util.SwingPreferences;
import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.logging.LogLevelBufferLogger; import net.sf.openrocket.logging.LogLevelBufferLogger;
import net.sf.openrocket.logging.LogLine; import net.sf.openrocket.logging.LogLine;
@ -44,6 +45,7 @@ public class BugReportDialog extends JDialog {
private static final String REPORT_EMAIL_URL = "mailto:" + REPORT_EMAIL; private static final String REPORT_EMAIL_URL = "mailto:" + REPORT_EMAIL;
private static final Translator trans = Application.getTranslator(); private static final Translator trans = Application.getTranslator();
private static final SwingPreferences preferences = (SwingPreferences) Application.getPreferences();
public BugReportDialog(Window parent, String labelText, final String message, final boolean sendIfUnchanged) { public BugReportDialog(Window parent, String labelText, final String message, final boolean sendIfUnchanged) {
@ -108,31 +110,10 @@ public class BugReportDialog extends JDialog {
* @param parent the parent window (may be null). * @param parent the parent window (may be null).
*/ */
public static void showBugReportDialog(Window parent) { public static void showBugReportDialog(Window parent) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("<html>---------- Bug report ----------\n"); // ---------- Bug report ----------
sb.append('\n'); addBugReportInformation(sb);
sb.append("<b>Include detailed steps on how to trigger the bug:</b>\n");
sb.append("<i>(You can edit text directly in this window)</i>\n");
sb.append('\n');
sb.append("1. \n");
sb.append("2. \n");
sb.append("3. \n");
sb.append('\n');
sb.append("<b>What does the software do and what in your opinion should it do in the " +
"case described above:</b>\n");
sb.append('\n');
sb.append('\n');
sb.append('\n');
sb.append("Include your email address (optional; it helps if we can " +
"contact you in case we need additional information):\n");
sb.append('\n');
sb.append('\n');
sb.append('\n');
sb.append("(Do not modify anything below this line.)\n"); sb.append("(Do not modify anything below this line.)\n");
sb.append("---------- System information ----------\n"); sb.append("---------- System information ----------\n");
@ -158,27 +139,8 @@ public class BugReportDialog extends JDialog {
public static void showExceptionDialog(Window parent, Thread t, Throwable e) { public static void showExceptionDialog(Window parent, Thread t, Throwable e) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("<html>---------- Bug report ----------\n"); // ---------- Bug report ----------
sb.append('\n'); addBugReportInformation(sb);
sb.append("<b style='color:rgb(210, 20, 5)'>Please include a description about what actions you were " +
"performing when the exception occurred:</b>\n");
sb.append("<i>(You can edit text directly in this window)</i>\n");
sb.append('\n');
sb.append("1. \n");
sb.append("2. \n");
sb.append("3. \n");
sb.append("\n");
sb.append("<b>If possible, please send us the .ork file that caused the bug.</b>\n");
sb.append('\n');
sb.append("Include your email address (optional; it helps if we can " +
"contact you in case we need additional information):\n");
sb.append('\n');
sb.append('\n');
sb.append('\n');
sb.append('\n');
sb.append("(Do not modify anything below this line.)\n"); sb.append("(Do not modify anything below this line.)\n");
sb.append("---------- Exception stack trace ----------\n"); sb.append("---------- Exception stack trace ----------\n");
@ -212,11 +174,36 @@ public class BugReportDialog extends JDialog {
reportDialog.setVisible(true); reportDialog.setVisible(true);
} }
private static void addBugReportInformation(StringBuilder sb) {
sb.append("<html>---------- Bug report ----------\n");
sb.append('\n');
sb.append("<b style='color:rgb(210, 20, 5)'>Please include a description about what actions you were " +
"performing when the exception occurred:</b>\n");
sb.append("<i>(You can edit text directly in this window)</i>\n");
sb.append('\n');
sb.append("1. \n");
sb.append("2. \n");
sb.append("3. \n");
sb.append("\n");
sb.append("<b>If possible, please send us the .ork file that caused the bug.</b>\n");
sb.append('\n');
sb.append("Include your email address (optional; it helps if we can " +
"contact you in case we need additional information):\n");
sb.append('\n');
sb.append('\n');
sb.append('\n');
sb.append('\n');
}
private static void addSystemInformation(StringBuilder sb) { private static void addSystemInformation(StringBuilder sb) {
StringBuilder sbTemp = new StringBuilder(); StringBuilder sbTemp = new StringBuilder();
sbTemp.append("OpenRocket version: " + BuildProperties.getVersion() + "\n"); sbTemp.append("OpenRocket version: " + BuildProperties.getVersion() + "\n");
sbTemp.append("OpenRocket source: " + BuildProperties.getBuildSource() + "\n"); sbTemp.append("OpenRocket source: " + BuildProperties.getBuildSource() + "\n");
sbTemp.append("OpenRocket location: " + JarUtil.getCurrentJarFile() + "\n"); sbTemp.append("OpenRocket location: " + JarUtil.getCurrentJarFile() + "\n");
sbTemp.append("User-defined thrust curves location: " + preferences.getUserThrustCurveFilesAsString() + "\n");
sbTemp.append("JOGL version: " + JoglVersion.getInstance().getImplementationVersion() + "\n"); sbTemp.append("JOGL version: " + JoglVersion.getInstance().getImplementationVersion() + "\n");
sbTemp.append("Current default locale: " + Locale.getDefault() + "\n"); sbTemp.append("Current default locale: " + Locale.getDefault() + "\n");
sbTemp.append("System properties:\n"); sbTemp.append("System properties:\n");

View File

@ -86,14 +86,7 @@ public class GeneralPreferencesPanel extends PreferencesPanel {
//// User-defined thrust curves: //// User-defined thrust curves:
this.add(new JLabel(trans.get("pref.dlg.lbl.User-definedthrust")), "spanx, wrap"); this.add(new JLabel(trans.get("pref.dlg.lbl.User-definedthrust")), "spanx, wrap");
final JTextField field = new JTextField(); final JTextField field = new JTextField();
List<File> files = preferences.getUserThrustCurveFiles(); String str = preferences.getUserThrustCurveFilesAsString();
String str = "";
for (File file : files) {
if (str.length() > 0) {
str += ";";
}
str += file.getAbsolutePath();
}
field.setText(str); field.setText(str);
field.getDocument().addDocumentListener(new DocumentListener() { field.getDocument().addDocumentListener(new DocumentListener() {
@Override @Override

View File

@ -305,6 +305,24 @@ public class SwingPreferences extends net.sf.openrocket.startup.Preferences {
return list; return list;
} }
/**
* Returns the files/directories to be loaded as custom thrust curves, formatting as a string. If there are multiple
* locations, they are separated by a semicolon.
*
* @return a list of files to load as thrust curves, formatted as a semicolon separated string.
*/
public String getUserThrustCurveFilesAsString() {
List<File> files = getUserThrustCurveFiles();
StringBuilder sb = new StringBuilder();
for (File file : files) {
if (sb.length() > 0) {
sb.append(";");
}
sb.append(file.getAbsolutePath());
}
return sb.toString();
}
public File getDefaultUserThrustCurveFile() { public File getDefaultUserThrustCurveFile() {
File appdir = SystemInfo.getUserApplicationDirectory(); File appdir = SystemInfo.getUserApplicationDirectory();
File tcdir = new File(appdir, "ThrustCurves"); File tcdir = new File(appdir, "ThrustCurves");