Merge pull request #1116 from SiboVG/fix-license-layout
Fix layout issues license dialog
This commit is contained in:
commit
0c03f631ba
@ -12,19 +12,16 @@ import java.io.BufferedInputStream;
|
|||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
|
import javax.swing.JTextPane;
|
||||||
import javax.swing.event.HyperlinkEvent;
|
import javax.swing.event.HyperlinkEvent;
|
||||||
import javax.swing.event.HyperlinkListener;
|
import javax.swing.event.HyperlinkListener;
|
||||||
import javax.swing.JEditorPane;
|
import javax.swing.JEditorPane;
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.ScrollPaneConstants;
|
import javax.swing.ScrollPaneConstants;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
import net.sf.openrocket.util.BugException;
|
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class DescriptionArea extends JScrollPane {
|
public class DescriptionArea extends JScrollPane {
|
||||||
|
|
||||||
@ -180,5 +177,17 @@ public class DescriptionArea extends JScrollPane {
|
|||||||
});
|
});
|
||||||
editorPane.scrollRectToVisible(new Rectangle(0, 0, 1, 1));
|
editorPane.scrollRectToVisible(new Rectangle(0, 0, 1, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the font to use for the text pane. If null, then the default font from OR is used.
|
||||||
|
* @param font font to use
|
||||||
|
*/
|
||||||
|
public void setTextFont(Font font) {
|
||||||
|
if (editorPane == null) return;
|
||||||
|
editorPane.putClientProperty(JTextPane.HONOR_DISPLAY_PROPERTIES, true);
|
||||||
|
if (font != null) {
|
||||||
|
editorPane.setFont(font);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,8 +18,8 @@ import javax.swing.JEditorPane;
|
|||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JTextArea;
|
|
||||||
import javax.swing.JTextPane;
|
import javax.swing.JTextPane;
|
||||||
|
import javax.swing.UIManager;
|
||||||
|
|
||||||
import com.jogamp.opengl.JoglVersion;
|
import com.jogamp.opengl.JoglVersion;
|
||||||
|
|
||||||
@ -73,6 +73,7 @@ public class BugReportDialog extends JDialog {
|
|||||||
|
|
||||||
final JEditorPane editorPane = new JEditorPane("text/html", formatNewlineHTML(message));
|
final JEditorPane editorPane = new JEditorPane("text/html", formatNewlineHTML(message));
|
||||||
editorPane.putClientProperty(JTextPane.HONOR_DISPLAY_PROPERTIES, true);
|
editorPane.putClientProperty(JTextPane.HONOR_DISPLAY_PROPERTIES, true);
|
||||||
|
editorPane.setFont(UIManager.getFont("Label.font"));
|
||||||
editorPane.setPreferredSize(new Dimension(600, 400));
|
editorPane.setPreferredSize(new Dimension(600, 400));
|
||||||
editorPane.setEditable(true);
|
editorPane.setEditable(true);
|
||||||
editorPane.setCaretPosition(0); // Scroll to the top by default
|
editorPane.setCaretPosition(0); // Scroll to the top by default
|
||||||
@ -180,7 +181,8 @@ public class BugReportDialog extends JDialog {
|
|||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
PrintWriter pw = new PrintWriter(sw);
|
PrintWriter pw = new PrintWriter(sw);
|
||||||
e.printStackTrace(pw);
|
e.printStackTrace(pw);
|
||||||
sb.append(sw.getBuffer());
|
String stackTrace = unformatHTML(String.valueOf(sw.getBuffer()));
|
||||||
|
sb.append(stackTrace);
|
||||||
sb.append('\n');
|
sb.append('\n');
|
||||||
|
|
||||||
|
|
||||||
@ -207,39 +209,47 @@ public class BugReportDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void addSystemInformation(StringBuilder sb) {
|
private static void addSystemInformation(StringBuilder sb) {
|
||||||
sb.append("OpenRocket version: " + BuildProperties.getVersion() + "\n");
|
StringBuilder sbTemp = new StringBuilder();
|
||||||
sb.append("OpenRocket source: " + BuildProperties.getBuildSource() + "\n");
|
sbTemp.append("OpenRocket version: " + BuildProperties.getVersion() + "\n");
|
||||||
sb.append("OpenRocket location: " + JarUtil.getCurrentJarFile() + "\n");
|
sbTemp.append("OpenRocket source: " + BuildProperties.getBuildSource() + "\n");
|
||||||
sb.append("JOGL version: " + JoglVersion.getInstance().getImplementationVersion() + "\n");
|
sbTemp.append("OpenRocket location: " + JarUtil.getCurrentJarFile() + "\n");
|
||||||
sb.append("Current default locale: " + Locale.getDefault() + "\n");
|
sbTemp.append("JOGL version: " + JoglVersion.getInstance().getImplementationVersion() + "\n");
|
||||||
sb.append("System properties:\n");
|
sbTemp.append("Current default locale: " + Locale.getDefault() + "\n");
|
||||||
|
sbTemp.append("System properties:\n");
|
||||||
|
|
||||||
// Sort the keys
|
// Sort the keys
|
||||||
SortedSet<String> keys = new TreeSet<String>();
|
SortedSet<String> keys = new TreeSet<String>();
|
||||||
for (Object key : System.getProperties().keySet()) {
|
for (Object key : System.getProperties().keySet()) {
|
||||||
keys.add((String) key);
|
keys.add((String) key);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String key : keys) {
|
for (String key : keys) {
|
||||||
String value = System.getProperty(key);
|
String value = System.getProperty(key);
|
||||||
sb.append(" " + key + "=");
|
sbTemp.append(" " + key + "=");
|
||||||
if (key.equals("line.separator")) {
|
if (key.equals("line.separator")) {
|
||||||
for (char c : value.toCharArray()) {
|
for (char c : value.toCharArray()) {
|
||||||
sb.append(String.format("\\u%04x", (int) c));
|
sbTemp.append(String.format("\\u%04x", (int) c));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sb.append(value);
|
sbTemp.append(value);
|
||||||
}
|
}
|
||||||
sb.append('\n');
|
sbTemp.append('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String message = unformatHTML(sbTemp.toString());
|
||||||
|
sb.append(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addErrorLog(StringBuilder sb) {
|
private static void addErrorLog(StringBuilder sb) {
|
||||||
|
StringBuilder sbTemp = new StringBuilder();
|
||||||
LogLevelBufferLogger buffer = LoggingSystemSetup.getBufferLogger();
|
LogLevelBufferLogger buffer = LoggingSystemSetup.getBufferLogger();
|
||||||
List<LogLine> logs = buffer.getLogs();
|
List<LogLine> logs = buffer.getLogs();
|
||||||
for (LogLine l : logs) {
|
for (LogLine l : logs) {
|
||||||
sb.append(l.toString()).append('\n');
|
sbTemp.append(l.toString()).append('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String message = unformatHTML(sbTemp.toString());
|
||||||
|
sb.append(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -252,5 +262,14 @@ public class BugReportDialog extends JDialog {
|
|||||||
private static String formatNewlineHTML(String text) {
|
private static String formatNewlineHTML(String text) {
|
||||||
return text.replaceAll("\n(.*?)(?=(\n|$))", "<p style=\"margin-top: 0\">$1</p>");
|
return text.replaceAll("\n(.*?)(?=(\n|$))", "<p style=\"margin-top: 0\">$1</p>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Makes text HTML unformatted by replacing '<' and '>' by the HTML character equivalent
|
||||||
|
* @param text text to be replaced
|
||||||
|
* @return HTML unformatted text
|
||||||
|
*/
|
||||||
|
private static String unformatHTML(String text) {
|
||||||
|
return text.replace("<", "<").replace(">", ">");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,21 +1,14 @@
|
|||||||
package net.sf.openrocket.gui.dialogs;
|
package net.sf.openrocket.gui.dialogs;
|
||||||
|
|
||||||
import java.awt.Font;
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
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.JButton;
|
||||||
import javax.swing.JDialog;
|
import javax.swing.JDialog;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.JTextArea;
|
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import net.sf.openrocket.gui.components.DescriptionArea;
|
import net.sf.openrocket.gui.components.DescriptionArea;
|
||||||
@ -39,7 +32,7 @@ public class LicenseDialog extends JDialog {
|
|||||||
// OpenRocket logo
|
// OpenRocket logo
|
||||||
panel.add(new JLabel(Icons.loadImageIcon("pix/icon/icon-about.png", "OpenRocket")), "top");
|
panel.add(new JLabel(Icons.loadImageIcon("pix/icon/icon-about.png", "OpenRocket")), "top");
|
||||||
|
|
||||||
panel.add(new StyledLabel("Software Licenses", 10), "ax 50%, wrap para");
|
panel.add(new StyledLabel("Software Licenses", 10), "ax 50%, pushx, wrap para");
|
||||||
|
|
||||||
final String jarUrl = "jar:" + getClass().getProtectionDomain().getCodeSource().getLocation().toString();
|
final String jarUrl = "jar:" + getClass().getProtectionDomain().getCodeSource().getLocation().toString();
|
||||||
final String copyrightYear = BuildProperties.getCopyrightYear();
|
final String copyrightYear = BuildProperties.getCopyrightYear();
|
||||||
@ -146,8 +139,9 @@ public class LicenseDialog extends JDialog {
|
|||||||
/*****************************************************************************************************************************/
|
/*****************************************************************************************************************************/
|
||||||
|
|
||||||
DescriptionArea info = new DescriptionArea(20);
|
DescriptionArea info = new DescriptionArea(20);
|
||||||
|
info.setTextFont(UIManager.getFont("Label.font"));
|
||||||
info.setText(orLicense + componentsLicense + fontLicense + commonmarkLicense);
|
info.setText(orLicense + componentsLicense + fontLicense + commonmarkLicense);
|
||||||
panel.add(info, "newline, width 600lp, height 150lp, grow, spanx, wrap para");
|
panel.add(info, "newline, width 700lp, height 250lp, pushy, grow, spanx, wrap para");
|
||||||
|
|
||||||
//Close button
|
//Close button
|
||||||
JButton close = new SelectColorButton(trans.get("dlg.but.close"));
|
JButton close = new SelectColorButton(trans.get("dlg.but.close"));
|
||||||
@ -157,7 +151,7 @@ public class LicenseDialog extends JDialog {
|
|||||||
LicenseDialog.this.dispose();
|
LicenseDialog.this.dispose();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
panel.add(close, "right");
|
panel.add(close, "spanx, right");
|
||||||
|
|
||||||
this.add(panel);
|
this.add(panel);
|
||||||
this.setTitle("OpenRocket license");
|
this.setTitle("OpenRocket license");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user