mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
- Issue 120: Improve version and build ID in Crash Reports.
* forge.error.ErrorViewer now uses BuildInfo.toPrettyString() to display the version. * Fixed some CheckStyle violations in ErrorViewer. * Added forge.model.BuildInfo.toPrettyString method. * Removed obsolete VERSION field from forge.properties.NewConstants. (Java) * Removed obsolete property "program/version" from res/main.properties. Bug: 120
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
program/howToReportBugsURL=http://tinyurl.com/3zzrnyb
|
||||
program/version=Forge -- official beta: $Date$, SVN revision: $Revision$
|
||||
|
||||
showdeck/2color=false
|
||||
showdeck/3color=false
|
||||
|
||||
@@ -30,6 +30,7 @@ import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.properties.NewConstants;
|
||||
|
||||
|
||||
@@ -153,7 +154,9 @@ public class ErrorViewer implements NewConstants, NewConstants.LANG.ErrorViewer
|
||||
|
||||
//Button is not modified, String gets the automatic listener to hide the dialog
|
||||
Object[] options = {
|
||||
new JButton(new BugzAction(area)), new JButton(new SaveAction(area)), getLocalized(BUTTON_CLOSE), new JButton(new ExitAction())};
|
||||
new JButton(new BugzAction(area)), new JButton(new SaveAction(area)), getLocalized(BUTTON_CLOSE),
|
||||
new JButton(new ExitAction())};
|
||||
|
||||
JOptionPane pane = new JOptionPane(new JScrollPane(area), ERROR_MESSAGE, DEFAULT_OPTION, null, options,
|
||||
options[1]);
|
||||
dlg = pane.createDialog(null, getLocalized(TITLE));
|
||||
@@ -176,7 +179,8 @@ public class ErrorViewer implements NewConstants, NewConstants.LANG.ErrorViewer
|
||||
ex.printStackTrace();
|
||||
|
||||
pw.printf(getLocalized(MESSAGE), getProperty(HOW_TO_REPORT_BUGS_URL),
|
||||
message != null ? message : ex.getMessage(), getProperty(VERSION),
|
||||
message != null ? message : ex.getMessage(),
|
||||
Singletons.getModel().getBuildInfo().toPrettyString(),
|
||||
System.getProperty(NAME_OS), System.getProperty(VERSION_OS), System.getProperty(ARCHITECTURE_OS),
|
||||
System.getProperty(VERSION_JAVA), System.getProperty(VENDOR_JAVA));
|
||||
ex.printStackTrace(pw);
|
||||
@@ -191,7 +195,8 @@ public class ErrorViewer implements NewConstants, NewConstants.LANG.ErrorViewer
|
||||
private static void printError(final PrintWriter pw, final String message) {
|
||||
System.err.println(message);
|
||||
|
||||
pw.printf(getLocalized(MESSAGE), getProperty(HOW_TO_REPORT_BUGS_URL), message, getProperty(VERSION),
|
||||
pw.printf(getLocalized(MESSAGE), getProperty(HOW_TO_REPORT_BUGS_URL), message,
|
||||
Singletons.getModel().getBuildInfo().toPrettyString(),
|
||||
System.getProperty(NAME_OS), System.getProperty(VERSION_OS), System.getProperty(ARCHITECTURE_OS),
|
||||
System.getProperty(VERSION_JAVA), System.getProperty(VENDOR_JAVA));
|
||||
Map<Thread, StackTraceElement[]> traces = Thread.getAllStackTraces();
|
||||
@@ -251,13 +256,13 @@ public class ErrorViewer implements NewConstants, NewConstants.LANG.ErrorViewer
|
||||
|
||||
private JTextArea area;
|
||||
|
||||
public BugzAction(JTextArea area) {
|
||||
public BugzAction(final JTextArea neoArea) {
|
||||
putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(VK_B, CTRL_DOWN_MASK));
|
||||
putValue(NAME, "Report Bug");
|
||||
this.area = area;
|
||||
this.area = neoArea;
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
BugzReporter br = new BugzReporter();
|
||||
br.setDumpText(area.getText());
|
||||
br.setVisible(true);
|
||||
|
||||
@@ -231,4 +231,34 @@ public class BuildInfo {
|
||||
return atts.getValue(manifestAttrName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a user-friendly string describing the version and build ID.
|
||||
*
|
||||
* This replaces the old system property program/version.
|
||||
*
|
||||
* @return a user-friendly string describing the version and build ID
|
||||
*/
|
||||
public final String toPrettyString() {
|
||||
final String rawVersion = getVersion();
|
||||
final String rawBuildID = getBuildID();
|
||||
|
||||
String version;
|
||||
if (rawVersion == null) {
|
||||
version = "Unknown";
|
||||
}
|
||||
else {
|
||||
version = rawVersion;
|
||||
}
|
||||
|
||||
String buildID;
|
||||
if (rawBuildID == null) {
|
||||
buildID = "Unknown";
|
||||
}
|
||||
else {
|
||||
buildID = rawBuildID;
|
||||
}
|
||||
|
||||
return "Forge version " + version + ", build ID " + buildID;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@ public interface NewConstants {
|
||||
//General properties
|
||||
/** Constant <code>HOW_TO_REPORT_BUGS_URL = "program/howToReportBugsURL"</code>. */
|
||||
String HOW_TO_REPORT_BUGS_URL = "program/howToReportBugsURL";
|
||||
/** Constant <code>VERSION="program/version"</code>. */
|
||||
String VERSION = "program/version";
|
||||
|
||||
/** Constant <code>SHOW2CDECK="showdeck/2color"</code>. */
|
||||
String SHOW2CDECK = "showdeck/2color";
|
||||
|
||||
Reference in New Issue
Block a user