checkstyle

This commit is contained in:
jendave
2011-10-26 20:10:53 +00:00
parent 108609c6c1
commit 071f3fe598
4 changed files with 495 additions and 522 deletions

View File

@@ -1,30 +1,31 @@
package forge.error;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.MalformedURLException;
import java.net.URL;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import forge.Singletons;
import forge.model.BuildInfo;
import forge.properties.ForgePreferences;
import javax.swing.JLabel;
import javax.swing.JCheckBox;
import javax.swing.JOptionPane;
import javax.swing.SwingConstants;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.JTextArea;
import java.awt.Dimension;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;
import org.apache.log4j.Logger;
import org.mantisbt.connect.Enumeration;
import org.mantisbt.connect.MCException;
import org.mantisbt.connect.axis.MCSession;
import org.mantisbt.connect.model.CustomFieldValue;
@@ -34,14 +35,14 @@ import org.mantisbt.connect.model.IMCAttribute;
import org.mantisbt.connect.model.IProjectVersion;
import org.mantisbt.connect.model.MCAttribute;
import org.mantisbt.connect.ui.DefaultSubmitter;
import org.mantisbt.connect.Enumeration;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.net.MalformedURLException;
import java.net.URL;
import java.awt.event.ActionListener;
import forge.Singletons;
import forge.model.BuildInfo;
import forge.properties.ForgePreferences;
/**
* The Class BugzReporter.
*/
public class BugzReporter extends JDialog {
/**
@@ -60,6 +61,8 @@ public class BugzReporter extends JDialog {
private JTextArea txtErrorDump = new JTextArea();
private JComboBox cboVersion = new JComboBox();
private JComboBox cboSeverity = new JComboBox();
/** The chk report anonymously. */
final JCheckBox chkReportAnonymously = new JCheckBox("Report Anonymously");
private JTextField txtSVN;
private JLabel lblAddInfo = new JLabel();
@@ -67,12 +70,15 @@ public class BugzReporter extends JDialog {
private static BugzReporter dialog = null;
private IMCAttribute Severities[];
private IMCAttribute[] Severities;
/**
* Launch the application.
*
* @param args
* the arguments
*/
public static void main(String[] args) {
public static void main(final String[] args) {
// try {
dialog.setVisible(true);
// } catch (Exception e) {
@@ -80,7 +86,13 @@ public class BugzReporter extends JDialog {
// }
}
public void setDumpText(String dump) {
/**
* Sets the dump text.
*
* @param dump
* the new dump text
*/
public final void setDumpText(final String dump) {
txtErrorDump.setText(dump);
lblAddInfo.setText("Crash Report");
cboCategory.setSelectedItem("New Crash Report");
@@ -95,26 +107,29 @@ public class BugzReporter extends JDialog {
setResizable(false);
// Init Logger for Axis, which is used by Mantis Library
org.apache.log4j.ConsoleAppender appCON = new org.apache.log4j.ConsoleAppender(new org.apache.log4j.SimpleLayout(), "System.out");
org.apache.log4j.ConsoleAppender appCON = new org.apache.log4j.ConsoleAppender(
new org.apache.log4j.SimpleLayout(), "System.out");
org.apache.log4j.Logger logAxis = Logger.getLogger("org.apache.axis");
logAxis.addAppender(appCON);
logAxis.setLevel(org.apache.log4j.Level.ERROR);
// Init Logger
//System.out.println(System.getProperties().toString().replace(", ", "\n"));
// System.out.println(System.getProperties().toString().replace(", ",
// "\n"));
MCSession mCS = null;
try {
mCS = new MCSession(new URL("http://cardforge.org/bugz/api/soap/mantisconnect.php"), "ForgeGUI", "vi2ccTbfBUu^");
mCS = new MCSession(new URL("http://cardforge.org/bugz/api/soap/mantisconnect.php"), "ForgeGUI",
"vi2ccTbfBUu^");
} catch (MalformedURLException e1) {
System.out.println("MalFormedURLException");
} catch (MCException e1) {
System.out.println("MCException - new MCSession");
}
String cats[] = {};
String[] cats = {};
try {
cats = mCS.getCategories(1);
} catch (MCException e1) {
@@ -142,44 +157,36 @@ public class BugzReporter extends JDialog {
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
getContentPane().add(contentPanel, BorderLayout.CENTER);
contentPanel.setLayout(null);
{
JLabel lblMantisUsername = new JLabel("Username");
lblMantisUsername.setHorizontalAlignment(SwingConstants.RIGHT);
lblMantisUsername.setBounds(10, 16, 75, 14);
contentPanel.add(lblMantisUsername);
}
{
txtUserName = new JTextField("ForgeGUI");
txtUserName.setBounds(90, 13, 185, 21);
txtUserName.setFont(new Font("Dialog", Font.PLAIN, 11));
contentPanel.add(txtUserName);
txtUserName.setColumns(4);
try {
prefs = new ForgePreferences("forge.preferences");
if (!prefs.BugzName.equals("")) {
txtUserName.setText(prefs.BugzName);
txtPassword.setText(prefs.BugzPwd);
chkReportAnonymously.setSelected(false);
}
else
} else {
chkReportAnonymously.setSelected(true);
}
} catch (Exception e) {
}
}
{
chkReportAnonymously.setBounds(284, 11, 139, 25);
chkReportAnonymously.setFont(new Font("Dialog", Font.PLAIN, 12));
chkReportAnonymously.setHorizontalAlignment(SwingConstants.CENTER);
chkReportAnonymously.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
public void actionPerformed(final ActionEvent e) {
if (chkReportAnonymously.isSelected()) {
txtUserName.setText("ForgeGUI");
txtPassword.setText("vi2ccTbfBUu^");
}
else {
} else {
if (!prefs.BugzName.equals("")) {
txtUserName.setText(prefs.BugzName);
txtPassword.setText(prefs.BugzPwd);
@@ -187,92 +194,63 @@ public class BugzReporter extends JDialog {
}
}
});
contentPanel.add(chkReportAnonymously);
}
{
JLabel lblMantisPassword = new JLabel("Password");
lblMantisPassword.setHorizontalAlignment(SwingConstants.RIGHT);
lblMantisPassword.setBounds(10, 45, 75, 14);
contentPanel.add(lblMantisPassword);
}
{
txtPassword.setBounds(90, 42, 185, 21);
txtPassword.setFont(new Font("Dialog", Font.PLAIN, 11));
contentPanel.add(txtPassword);
}
{
JSeparator separator = new JSeparator();
separator.setBounds(10, 69, 417, 2);
contentPanel.add(separator);
}
{
JLabel lblCategory = new JLabel("Category");
lblCategory.setBounds(10, 81, 75, 14);
lblCategory.setFont(new Font("Tahoma", Font.BOLD, 11));
lblCategory.setHorizontalAlignment(SwingConstants.RIGHT);
contentPanel.add(lblCategory);
}
{
cboCategory.setBounds(90, 77, 223, 22);
cboCategory.setFont(new Font("Dialog", Font.BOLD, 10));
if (cats.length > 0) {
for (int i=0; i<cats.length; i++)
for (int i = 0; i < cats.length; i++) {
cboCategory.addItem(cats[i]);
}
cboCategory.setSelectedItem("General Bug Report");
contentPanel.add(cboCategory);
}
{
cboCategory.setSelectedItem("General Bug Report");
contentPanel.add(cboCategory);
JLabel lblSummary = new JLabel("Summary");
lblSummary.setBounds(10, 108, 75, 14);
lblSummary.setFont(new Font("Tahoma", Font.BOLD, 11));
lblSummary.setHorizontalAlignment(SwingConstants.RIGHT);
contentPanel.add(lblSummary);
}
{
txtSummary = new JTextField();
txtSummary.setBounds(90, 105, 337, 21);
txtSummary.setFont(new Font("Dialog", Font.PLAIN, 11));
contentPanel.add(txtSummary);
txtSummary.setColumns(10);
}
{
JLabel lblDescription = new JLabel("Description");
lblDescription.setBounds(10, 182, 75, 21);
lblDescription.setFont(new Font("Tahoma", Font.BOLD, 11));
lblDescription.setHorizontalAlignment(SwingConstants.RIGHT);
contentPanel.add(lblDescription);
}
{
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(90, 132, 337, 120);
contentPanel.add(scrollPane);
{
txtDescription.setFont(new Font("Dialog", Font.PLAIN, 10));
scrollPane.setViewportView(txtDescription);
txtDescription.setBorder(null);
txtDescription.setWrapStyleWord(true);
txtDescription.setLineWrap(true);
txtDescription.setRows(8);
}
}
{
lblAddInfo.setText("<html><p align=\"right\">Additional<br>Information</p></html>");
lblAddInfo.setBounds(10, 294, 75, 40);
lblAddInfo.setFont(new Font("Dialog", Font.PLAIN, 12));
lblAddInfo.setHorizontalAlignment(SwingConstants.RIGHT);
contentPanel.add(lblAddInfo);
}
{
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(90, 254, 337, 120);
contentPanel.add(scrollPane);
{
JScrollPane scrollPane3 = new JScrollPane();
scrollPane3.setBounds(90, 254, 337, 120);
contentPanel.add(scrollPane3);
txtErrorDump.setFont(new Font("Monospaced", Font.PLAIN, 10));
scrollPane.setViewportView(txtErrorDump);
txtErrorDump.setAutoscrolls(false);
@@ -281,19 +259,13 @@ public class BugzReporter extends JDialog {
txtErrorDump.setLineWrap(true);
txtErrorDump.setWrapStyleWord(true);
txtErrorDump.setRows(8);
}
}
{
JLabel lblVersion = new JLabel("Version");
lblVersion.setHorizontalAlignment(SwingConstants.RIGHT);
lblVersion.setBounds(20, 468, 65, 16);
lblVersion.setFont(new Font("Dialog", Font.PLAIN, 12));
contentPanel.add(lblVersion);
}
{
cboVersion.setBounds(90, 465, 160, 22);
cboVersion.setFont(new Font("Dialog", Font.BOLD, 10));
cboVersion.addItem("");
if (vers.length > 0) {
for (int i = 0; i < vers.length; i++) {
@@ -302,12 +274,10 @@ public class BugzReporter extends JDialog {
}
}
cboVersion.setSelectedIndex(0);
String curVer = bi.getVersion();
String ss[] = curVer.split("-");
String[] ss = curVer.split("-");
String rx = "^" + ss[0].replaceAll("\\.", "\\\\.") + ".*";
System.out.println(ss[0] + " -> " + rx);
if (curVer.equals("SVN")) {
cboVersion.setSelectedItem("SVN");
} else {
@@ -319,53 +289,40 @@ public class BugzReporter extends JDialog {
}
}
}
contentPanel.add(cboVersion);
}
{
JLabel lblRev = new JLabel("SVN rev.");
lblRev.setBounds(247, 468, 66, 16);
lblRev.setHorizontalAlignment(SwingConstants.RIGHT);
lblRev.setFont(new Font("Dialog", Font.PLAIN, 12));
contentPanel.add(lblRev);
}
{
txtSVN = new JTextField();
String curRev = bi.getBuildID();
if (curRev != null) {
if (!curRev.equals("null"))
if (!curRev.equals("null")) {
txtSVN.setText(curRev);
}
}
txtSVN.setBounds(318, 465, 109, 21);
txtSVN.setFont(new Font("Dialog", Font.PLAIN, 11));
txtSVN.setColumns(10);
contentPanel.add(txtSVN);
}
{
JLabel lblSeverity = new JLabel("Severity");
lblSeverity.setBounds(10, 496, 75, 16);
lblSeverity.setFont(new Font("Dialog", Font.PLAIN, 12));
lblSeverity.setHorizontalAlignment(SwingConstants.RIGHT);
contentPanel.add(lblSeverity);
}
{
cboSeverity.setBounds(90, 493, 160, 22);
cboSeverity.setFont(new Font("Dialog", Font.BOLD, 10));
cboSeverity.addItem("");
if (Severities.length > 0) {
for (int i=0; i<Severities.length; i++)
for (int i = 0; i < Severities.length; i++) {
cboSeverity.addItem(Severities[i].getName());
}
contentPanel.add(cboSeverity);
}
{
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(90, 380, 337, 80);
contentPanel.add(scrollPane);
{
contentPanel.add(cboSeverity);
JScrollPane scrollPane2 = new JScrollPane();
scrollPane2.setBounds(90, 380, 337, 80);
contentPanel.add(scrollPane2);
txtSteps.setWrapStyleWord(true);
txtSteps.setRows(5);
txtSteps.setMaximumSize(new Dimension(2147483647, 300));
@@ -373,77 +330,70 @@ public class BugzReporter extends JDialog {
txtSteps.setFont(new Font("Monospaced", Font.PLAIN, 10));
txtSteps.setAutoscrolls(false);
scrollPane.setViewportView(txtSteps);
}
}
{
JLabel lblSteps = new JLabel();
lblSteps.setText("<html><p align=\"right\">Steps to<br>Reproduce</p></html>");
lblSteps.setHorizontalAlignment(SwingConstants.RIGHT);
lblSteps.setFont(new Font("Dialog", Font.PLAIN, 12));
lblSteps.setBounds(10, 400, 75, 40);
contentPanel.add(lblSteps);
}
{
JPanel buttonPane = new JPanel();
buttonPane.setOpaque(false);
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
getContentPane().add(buttonPane, BorderLayout.SOUTH);
{
JButton cmdReport = new JButton("Report");
cmdReport.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
public void actionPerformed(final ActionEvent arg0) {
doReport();
}
});
buttonPane.add(cmdReport);
}
{
JButton cmdCancel = new JButton("Cancel");
cmdCancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
public void actionPerformed(final ActionEvent arg0) {
dialog.dispose();
}
});
buttonPane.add(cmdCancel);
}
}
}
private void doReport() {
Report: {
if (txtSummary.getText().length() < 4) {
JOptionPane.showMessageDialog(null, "Summary field must be provided", "Bug Report", JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(null, "Summary field must be provided", "Bug Report",
JOptionPane.ERROR_MESSAGE);
break Report;
}
if (txtDescription.getText().length() < 10) {
JOptionPane.showMessageDialog(null, "Description field must be provided", "Bug Report", JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(null, "Description field must be provided", "Bug Report",
JOptionPane.ERROR_MESSAGE);
break Report;
}
MCSession rep = null;
if (!chkReportAnonymously.isSelected()) {
try {
rep = new MCSession(new URL("http://cardforge.org/bugz/api/soap/mantisconnect.php"), txtUserName.getText(), String.valueOf(txtPassword.getPassword()));
rep = new MCSession(new URL("http://cardforge.org/bugz/api/soap/mantisconnect.php"),
txtUserName.getText(), String.valueOf(txtPassword.getPassword()));
} catch (MalformedURLException e) {
System.out.println("MalFormedURLException");
} catch (MCException e) {
System.out.println("MCException - new MCSession - " + e.getMessage());
JOptionPane.showMessageDialog(null, "MCException - new MCSession - " + e.getMessage(), "Bug Report", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "MCException - new MCSession - " + e.getMessage(),
"Bug Report", JOptionPane.INFORMATION_MESSAGE);
break Report;
}
} else {
try {
rep = new MCSession(new URL("http://cardforge.org/bugz/api/soap/mantisconnect.php"), "ForgeGUI", "vi2ccTbfBUu^");
rep = new MCSession(new URL("http://cardforge.org/bugz/api/soap/mantisconnect.php"), "ForgeGUI",
"vi2ccTbfBUu^");
} catch (MalformedURLException e) {
System.out.println("MalformedURLException");
} catch (MCException e) {
System.out.println("MCException - new MCSession - " + e.getMessage());
JOptionPane.showMessageDialog(null, "MCException - new MCSession - " + e.getMessage(), "Bug Report", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "MCException - new MCSession - " + e.getMessage(),
"Bug Report", JOptionPane.INFORMATION_MESSAGE);
break Report;
}
}
@@ -453,7 +403,8 @@ public class BugzReporter extends JDialog {
iBug = rep.newIssue(1);
} catch (MCException e) {
System.out.println("MCException - newIssue - " + e.getMessage());
JOptionPane.showMessageDialog(null, "MCException - newIssue - " + e.getMessage(), "Bug Report", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "MCException - newIssue - " + e.getMessage(), "Bug Report",
JOptionPane.INFORMATION_MESSAGE);
break Report;
}
@@ -464,15 +415,15 @@ public class BugzReporter extends JDialog {
iBug.setVersion(cboVersion.getSelectedItem().toString());
for (int i = 0; i < Severities.length; i++) {
if (cboSeverity.getSelectedItem().toString().equals(Severities[i].getName()))
if (cboSeverity.getSelectedItem().toString().equals(Severities[i].getName())) {
iBug.setSeverity(Severities[i]);
}
}
iBug.setStepsToReproduce(txtSteps.getText());
ICustomFieldValue icfv[] = {
new CustomFieldValue(new MCAttribute(1, "Detected at SVN Rev"), txtSVN.getText())
};
ICustomFieldValue[] icfv = {new CustomFieldValue(new MCAttribute(1, "Detected at SVN Rev"),
txtSVN.getText())};
iBug.setCustomFields(icfv);
DefaultSubmitter ds = new DefaultSubmitter(false);
@@ -480,7 +431,8 @@ public class BugzReporter extends JDialog {
ds.submitIssue(rep, iBug);
} catch (MCException e1) {
System.out.println("MCException - submit Issue - " + e1.getMessage());
JOptionPane.showMessageDialog(null, "MCException - submit Issue - " + e1.getMessage(), "Bug Report", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "MCException - submit Issue - " + e1.getMessage(), "Bug Report",
JOptionPane.INFORMATION_MESSAGE);
break Report;
}
@@ -492,7 +444,8 @@ public class BugzReporter extends JDialog {
System.out.println("Exception - save preferences - " + e.getMessage());
}
JOptionPane.showMessageDialog(null, "This Issue Has Been Reported, Thank You.", "Bug Report", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "This Issue Has Been Reported, Thank You.", "Bug Report",
JOptionPane.INFORMATION_MESSAGE);
dialog.dispose();
} // Report:

View File

@@ -1,11 +1,10 @@
package forge.error;
import static forge.properties.ForgeProps.getLocalized;
import static forge.properties.ForgeProps.getProperty;
import static java.awt.event.InputEvent.CTRL_DOWN_MASK;
import static java.awt.event.KeyEvent.VK_S;
import static java.awt.event.KeyEvent.VK_B;
import static java.awt.event.KeyEvent.VK_S;
import static javax.swing.JOptionPane.DEFAULT_OPTION;
import static javax.swing.JOptionPane.ERROR_MESSAGE;
@@ -33,9 +32,9 @@ import javax.swing.KeyStroke;
import forge.Singletons;
import forge.properties.NewConstants;
/**
* The class ErrorViewer. Enables showing and saving error messages that occurred in forge.
* The class ErrorViewer. Enables showing and saving error messages that
* occurred in forge.
*
* @author Clemens Koza
* @version V1.0 02.08.2009
@@ -58,20 +57,26 @@ public class ErrorViewer implements NewConstants, NewConstants.LANG.ErrorViewer
private static JDialog dlg = null;
/**
* Shows an error dialog taking the exception's message as the error message.
* Shows an error dialog taking the exception's message as the error
* message.
*
* @param ex a {@link java.lang.Throwable} object.
* @param ex
* a {@link java.lang.Throwable} object.
*/
public static void showError(final Throwable ex) {
showError(ex, null);
}
/**
* Shows an error dialog creating the error message by a formatting operation.
* Shows an error dialog creating the error message by a formatting
* operation.
*
* @param ex a {@link java.lang.Throwable} object.
* @param format a {@link java.lang.String} object.
* @param args a {@link java.lang.Object} object.
* @param ex
* a {@link java.lang.Throwable} object.
* @param format
* a {@link java.lang.String} object.
* @param args
* a {@link java.lang.Object} object.
*/
public static void showError(final Throwable ex, final String format, final Object... args) {
if (ex == null) {
@@ -83,8 +88,10 @@ public class ErrorViewer implements NewConstants, NewConstants.LANG.ErrorViewer
/**
* Shows an error dialog with the specified error message.
*
* @param ex a {@link java.lang.Throwable} object.
* @param message a {@link java.lang.String} object.
* @param ex
* a {@link java.lang.Throwable} object.
* @param message
* a {@link java.lang.String} object.
*/
public static void showError(final Throwable ex, final String message) {
if (ex == null) {
@@ -101,8 +108,10 @@ public class ErrorViewer implements NewConstants, NewConstants.LANG.ErrorViewer
/**
* Shows an error without an exception that caused it.
*
* @param format a {@link java.lang.String} object.
* @param args a {@link java.lang.Object} object.
* @param format
* a {@link java.lang.String} object.
* @param args
* a {@link java.lang.Object} object.
*/
public static void showError(final String format, final Object... args) {
showError(String.format(format, args));
@@ -111,7 +120,8 @@ public class ErrorViewer implements NewConstants, NewConstants.LANG.ErrorViewer
/**
* Shows an error without an exception that caused it.
*
* @param message a {@link java.lang.String} object.
* @param message
* a {@link java.lang.String} object.
*/
public static void showError(final String message) {
showError(new Exception(), message);
@@ -120,8 +130,10 @@ public class ErrorViewer implements NewConstants, NewConstants.LANG.ErrorViewer
/**
* Shows an error message for all running threads.
*
* @param format a {@link java.lang.String} object.
* @param args a {@link java.lang.Object} object.
* @param format
* a {@link java.lang.String} object.
* @param args
* a {@link java.lang.Object} object.
*/
public static void showErrorAllThreads(final String format, final Object... args) {
showErrorAllThreads(String.format(format, args));
@@ -130,7 +142,8 @@ public class ErrorViewer implements NewConstants, NewConstants.LANG.ErrorViewer
/**
* Shows an error message for all running threads.
*
* @param message a {@link java.lang.String} object.
* @param message
* a {@link java.lang.String} object.
*/
public static void showErrorAllThreads(final String message) {
final StringWriter sw = new StringWriter();
@@ -141,9 +154,12 @@ public class ErrorViewer implements NewConstants, NewConstants.LANG.ErrorViewer
}
/**
* <p>showDialog.</p>
* <p>
* showDialog.
* </p>
*
* @param fullMessage a {@link java.lang.String} object.
* @param fullMessage
* a {@link java.lang.String} object.
*/
private static void showDialog(final String fullMessage) {
JTextArea area = new JTextArea(fullMessage, 40, 90);
@@ -152,10 +168,10 @@ public class ErrorViewer implements NewConstants, NewConstants.LANG.ErrorViewer
area.setLineWrap(true);
area.setWrapStyleWord(true);
//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())};
// 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())};
JOptionPane pane = new JOptionPane(new JScrollPane(area), ERROR_MESSAGE, DEFAULT_OPTION, null, options,
options[1]);
@@ -168,9 +184,12 @@ public class ErrorViewer implements NewConstants, NewConstants.LANG.ErrorViewer
/**
* Prints the error message for the specified exception to the print writer.
*
* @param pw a {@link java.io.PrintWriter} object.
* @param ex a {@link java.lang.Throwable} object.
* @param message a {@link java.lang.String} object.
* @param pw
* a {@link java.io.PrintWriter} object.
* @param ex
* a {@link java.lang.Throwable} object.
* @param message
* a {@link java.lang.String} object.
*/
private static void printError(final PrintWriter pw, final Throwable ex, final String message) {
if (message != null) {
@@ -179,26 +198,27 @@ 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(),
Singletons.getModel().getBuildInfo().toPrettyString(),
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);
}
/**
* Prints the error message to the print writer, showing all running threads' stack traces.
* Prints the error message to the print writer, showing all running
* threads' stack traces.
*
* @param pw a {@link java.io.PrintWriter} object.
* @param message a {@link java.lang.String} object.
* @param pw
* a {@link java.io.PrintWriter} object.
* @param message
* a {@link java.lang.String} object.
*/
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,
Singletons.getModel().getBuildInfo().toPrettyString(),
System.getProperty(NAME_OS), System.getProperty(VERSION_OS), System.getProperty(ARCHITECTURE_OS),
System.getProperty(VERSION_JAVA), System.getProperty(VENDOR_JAVA));
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();
for (Entry<Thread, StackTraceElement[]> e : traces.entrySet()) {
pw.println();
@@ -278,7 +298,6 @@ public class ErrorViewer implements NewConstants, NewConstants.LANG.ErrorViewer
super(getLocalized(BUTTON_EXIT));
}
public void actionPerformed(final ActionEvent e) {
System.exit(0);
}

View File

@@ -6,14 +6,13 @@
package forge.error;
import java.lang.Thread.UncaughtExceptionHandler;
import com.esotericsoftware.minlog.Log;
import java.lang.Thread.UncaughtExceptionHandler;
/**
* This class handles all exceptions that weren't caught by showing the error to the user.
* This class handles all exceptions that weren't caught by showing the error to
* the user.
*
* @author Forge
* @version $Id$
@@ -27,24 +26,26 @@ public class ExceptionHandler implements UncaughtExceptionHandler {
}
/**
* Call this at the beginning to make sure that the class is loaded and the static initializer has run
* Call this at the beginning to make sure that the class is loaded and the
* static initializer has run.
*/
public static void registerErrorHandling() {
Log.debug("Error handling registered!");
}
/** {@inheritDoc} */
public void uncaughtException(Thread t, Throwable ex) {
public final void uncaughtException(final Thread t, final Throwable ex) {
ErrorViewer.showError(ex);
}
/**
* This Method is called by AWT when an error is thrown in the event dispatching thread and not caught.
* This Method is called by AWT when an error is thrown in the event
* dispatching thread and not caught.
*
* @param ex a {@link java.lang.Throwable} object.
* @param ex
* a {@link java.lang.Throwable} object.
*/
public void handle(Throwable ex) {
public final void handle(final Throwable ex) {
ErrorViewer.showError(ex);
}
}

View File

@@ -1,2 +1,2 @@
/** Forge Card Game */
/** Forge Card Game. */
package forge.error;