Display user-defined thrust curves location in bug report

This commit is contained in:
SiboVG 2022-12-24 03:35:33 +01:00
parent 17d7df8511
commit 19ba08a20e
3 changed files with 22 additions and 8 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.URLLabel;
import net.sf.openrocket.gui.util.GUIUtil;
import net.sf.openrocket.gui.util.SwingPreferences;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.logging.LogLevelBufferLogger;
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 Translator trans = Application.getTranslator();
private static final SwingPreferences preferences = (SwingPreferences) Application.getPreferences();
public BugReportDialog(Window parent, String labelText, final String message, final boolean sendIfUnchanged) {
@ -201,6 +203,7 @@ public class BugReportDialog extends JDialog {
sbTemp.append("OpenRocket version: " + BuildProperties.getVersion() + "\n");
sbTemp.append("OpenRocket source: " + BuildProperties.getBuildSource() + "\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("Current default locale: " + Locale.getDefault() + "\n");
sbTemp.append("System properties:\n");

View File

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

View File

@ -304,6 +304,24 @@ public class SwingPreferences extends net.sf.openrocket.startup.Preferences {
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() {
File appdir = SystemInfo.getUserApplicationDirectory();