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

View File

@@ -1,11 +1,10 @@
package forge.error; package forge.error;
import static forge.properties.ForgeProps.getLocalized; import static forge.properties.ForgeProps.getLocalized;
import static forge.properties.ForgeProps.getProperty; import static forge.properties.ForgeProps.getProperty;
import static java.awt.event.InputEvent.CTRL_DOWN_MASK; 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_B;
import static java.awt.event.KeyEvent.VK_S;
import static javax.swing.JOptionPane.DEFAULT_OPTION; import static javax.swing.JOptionPane.DEFAULT_OPTION;
import static javax.swing.JOptionPane.ERROR_MESSAGE; import static javax.swing.JOptionPane.ERROR_MESSAGE;
@@ -33,9 +32,9 @@ import javax.swing.KeyStroke;
import forge.Singletons; import forge.Singletons;
import forge.properties.NewConstants; 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 * @author Clemens Koza
* @version V1.0 02.08.2009 * @version V1.0 02.08.2009
@@ -58,20 +57,26 @@ public class ErrorViewer implements NewConstants, NewConstants.LANG.ErrorViewer
private static JDialog dlg = null; 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) { public static void showError(final Throwable ex) {
showError(ex, null); 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 ex
* @param format a {@link java.lang.String} object. * a {@link java.lang.Throwable} 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 Throwable ex, final String format, final Object... args) { public static void showError(final Throwable ex, final String format, final Object... args) {
if (ex == null) { if (ex == null) {
@@ -83,8 +88,10 @@ public class ErrorViewer implements NewConstants, NewConstants.LANG.ErrorViewer
/** /**
* Shows an error dialog with the specified error message. * Shows an error dialog with the specified error message.
* *
* @param ex a {@link java.lang.Throwable} object. * @param ex
* @param message a {@link java.lang.String} object. * a {@link java.lang.Throwable} object.
* @param message
* a {@link java.lang.String} object.
*/ */
public static void showError(final Throwable ex, final String message) { public static void showError(final Throwable ex, final String message) {
if (ex == null) { if (ex == null) {
@@ -101,8 +108,10 @@ public class ErrorViewer implements NewConstants, NewConstants.LANG.ErrorViewer
/** /**
* Shows an error without an exception that caused it. * Shows an error without an exception that caused it.
* *
* @param format a {@link java.lang.String} object. * @param format
* @param args a {@link java.lang.Object} object. * a {@link java.lang.String} object.
* @param args
* a {@link java.lang.Object} object.
*/ */
public static void showError(final String format, final Object... args) { public static void showError(final String format, final Object... args) {
showError(String.format(format, 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. * 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) { public static void showError(final String message) {
showError(new Exception(), 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. * Shows an error message for all running threads.
* *
* @param format a {@link java.lang.String} object. * @param format
* @param args a {@link java.lang.Object} object. * a {@link java.lang.String} object.
* @param args
* a {@link java.lang.Object} object.
*/ */
public static void showErrorAllThreads(final String format, final Object... args) { public static void showErrorAllThreads(final String format, final Object... args) {
showErrorAllThreads(String.format(format, 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. * 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) { public static void showErrorAllThreads(final String message) {
final StringWriter sw = new StringWriter(); 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) { private static void showDialog(final String fullMessage) {
JTextArea area = new JTextArea(fullMessage, 40, 90); JTextArea area = new JTextArea(fullMessage, 40, 90);
@@ -152,10 +168,10 @@ public class ErrorViewer implements NewConstants, NewConstants.LANG.ErrorViewer
area.setLineWrap(true); area.setLineWrap(true);
area.setWrapStyleWord(true); area.setWrapStyleWord(true);
//Button is not modified, String gets the automatic listener to hide the dialog // Button is not modified, String gets the automatic listener to hide
Object[] options = { // the dialog
new JButton(new BugzAction(area)), new JButton(new SaveAction(area)), getLocalized(BUTTON_CLOSE), Object[] options = {new JButton(new BugzAction(area)), new JButton(new SaveAction(area)),
new JButton(new ExitAction())}; getLocalized(BUTTON_CLOSE), new JButton(new ExitAction())};
JOptionPane pane = new JOptionPane(new JScrollPane(area), ERROR_MESSAGE, DEFAULT_OPTION, null, options, JOptionPane pane = new JOptionPane(new JScrollPane(area), ERROR_MESSAGE, DEFAULT_OPTION, null, options,
options[1]); 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. * Prints the error message for the specified exception to the print writer.
* *
* @param pw a {@link java.io.PrintWriter} object. * @param pw
* @param ex a {@link java.lang.Throwable} object. * a {@link java.io.PrintWriter} 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.
*/ */
private static void printError(final PrintWriter pw, final Throwable ex, final String message) { private static void printError(final PrintWriter pw, final Throwable ex, final String message) {
if (message != null) { if (message != null) {
@@ -179,26 +198,27 @@ public class ErrorViewer implements NewConstants, NewConstants.LANG.ErrorViewer
ex.printStackTrace(); ex.printStackTrace();
pw.printf(getLocalized(MESSAGE), getProperty(HOW_TO_REPORT_BUGS_URL), pw.printf(getLocalized(MESSAGE), getProperty(HOW_TO_REPORT_BUGS_URL),
message != null ? message : ex.getMessage(), message != null ? message : ex.getMessage(), Singletons.getModel().getBuildInfo().toPrettyString(),
Singletons.getModel().getBuildInfo().toPrettyString(),
System.getProperty(NAME_OS), System.getProperty(VERSION_OS), System.getProperty(ARCHITECTURE_OS), System.getProperty(NAME_OS), System.getProperty(VERSION_OS), System.getProperty(ARCHITECTURE_OS),
System.getProperty(VERSION_JAVA), System.getProperty(VENDOR_JAVA)); System.getProperty(VERSION_JAVA), System.getProperty(VENDOR_JAVA));
ex.printStackTrace(pw); 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 pw
* @param message a {@link java.lang.String} object. * a {@link java.io.PrintWriter} object.
* @param message
* a {@link java.lang.String} object.
*/ */
private static void printError(final PrintWriter pw, final String message) { private static void printError(final PrintWriter pw, final String message) {
System.err.println(message); System.err.println(message);
pw.printf(getLocalized(MESSAGE), getProperty(HOW_TO_REPORT_BUGS_URL), message, pw.printf(getLocalized(MESSAGE), getProperty(HOW_TO_REPORT_BUGS_URL), message, Singletons.getModel()
Singletons.getModel().getBuildInfo().toPrettyString(), .getBuildInfo().toPrettyString(), System.getProperty(NAME_OS), System.getProperty(VERSION_OS),
System.getProperty(NAME_OS), System.getProperty(VERSION_OS), System.getProperty(ARCHITECTURE_OS), System.getProperty(ARCHITECTURE_OS), System.getProperty(VERSION_JAVA), System.getProperty(VENDOR_JAVA));
System.getProperty(VERSION_JAVA), System.getProperty(VENDOR_JAVA));
Map<Thread, StackTraceElement[]> traces = Thread.getAllStackTraces(); Map<Thread, StackTraceElement[]> traces = Thread.getAllStackTraces();
for (Entry<Thread, StackTraceElement[]> e : traces.entrySet()) { for (Entry<Thread, StackTraceElement[]> e : traces.entrySet()) {
pw.println(); pw.println();
@@ -278,7 +298,6 @@ public class ErrorViewer implements NewConstants, NewConstants.LANG.ErrorViewer
super(getLocalized(BUTTON_EXIT)); super(getLocalized(BUTTON_EXIT));
} }
public void actionPerformed(final ActionEvent e) { public void actionPerformed(final ActionEvent e) {
System.exit(0); System.exit(0);
} }

View File

@@ -6,14 +6,13 @@
package forge.error; package forge.error;
import java.lang.Thread.UncaughtExceptionHandler;
import com.esotericsoftware.minlog.Log; 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 * @author Forge
* @version $Id$ * @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() { public static void registerErrorHandling() {
Log.debug("Error handling registered!"); Log.debug("Error handling registered!");
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
public void uncaughtException(Thread t, Throwable ex) { public final void uncaughtException(final Thread t, final Throwable ex) {
ErrorViewer.showError(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); ErrorViewer.showError(ex);
} }
} }

View File

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