make everything use the new bug reporter dialog

This commit is contained in:
myk
2013-02-20 03:01:37 +00:00
parent b85a07b874
commit 1ff4e9e96c
23 changed files with 50 additions and 867 deletions

2
.gitattributes vendored
View File

@@ -14036,8 +14036,6 @@ src/main/java/forge/deck/io/OldDeckFileFormatException.java -text
src/main/java/forge/deck/io/OldDeckParser.java -text
src/main/java/forge/deck/io/package-info.java svneol=native#text/plain
src/main/java/forge/deck/package-info.java svneol=native#text/plain
src/main/java/forge/error/BugzReporter.java svneol=native#text/plain
src/main/java/forge/error/ErrorViewer.java svneol=native#text/plain
src/main/java/forge/error/ExceptionHandler.java svneol=native#text/plain
src/main/java/forge/error/package-info.java svneol=native#text/plain
src/main/java/forge/game/GameAction.java svneol=native#text/plain

View File

@@ -31,7 +31,7 @@ import forge.card.spellability.AbilityActivated;
import forge.card.spellability.SpellAbility;
import forge.card.spellability.SpellPermanent;
import forge.card.spellability.Target;
import forge.error.ErrorViewer;
import forge.error.BugReporter;
import forge.game.player.Player;
import forge.gui.GuiUtils;
import forge.item.CardDb;
@@ -79,7 +79,7 @@ public class CardFactory {
CardDb.setup(listCardRules.iterator());
} catch (final Exception ex) {
ErrorViewer.showError(ex);
BugReporter.reportException(ex);
}
} // constructor

View File

@@ -46,7 +46,7 @@ import forge.card.mana.ManaCostParser;
import forge.card.mana.ManaCost;
import forge.card.replacement.ReplacementHandler;
import forge.card.trigger.TriggerHandler;
import forge.error.ErrorViewer;
import forge.error.BugReporter;
import forge.gui.toolbox.FProgressBar;
import forge.util.FileUtil;
import forge.view.FView;
@@ -474,7 +474,7 @@ public class CardReader {
fileInputStream = new FileInputStream(pathToTxtFile);
return this.loadCard(fileInputStream);
} catch (final FileNotFoundException ex) {
ErrorViewer.showError(ex, "File \"%s\" exception", pathToTxtFile.getAbsolutePath());
BugReporter.reportException(ex, "File \"%s\" exception", pathToTxtFile.getAbsolutePath());
throw new RuntimeException("CardReader : run error -- file exception -- filename is "
+ pathToTxtFile.getPath(), ex);
} finally {

View File

@@ -28,7 +28,7 @@ import forge.card.cardfactory.CardFactoryUtil;
import forge.card.cost.Cost;
import forge.card.cost.CostPayment;
import forge.card.staticability.StaticAbility;
import forge.error.ErrorViewer;
import forge.error.BugReporter;
import forge.game.GameState;
import forge.game.player.Player;
import forge.game.zone.ZoneType;
@@ -180,7 +180,7 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable
try {
return super.clone();
} catch (final Exception ex) {
ErrorViewer.showError(ex);
BugReporter.reportException(ex);
throw new RuntimeException("Spell : clone() error, " + ex);
}
}

View File

@@ -23,7 +23,7 @@ import java.util.List;
import forge.card.MagicColor;
import forge.card.ColorSet;
import forge.deck.generate.GenerateDeckUtil.FilterCMC;
import forge.error.ErrorViewer;
import forge.error.BugReporter;
import forge.game.player.PlayerType;
import forge.item.CardPrinted;
import forge.item.ItemPoolView;
@@ -102,7 +102,7 @@ public class Generate2ColorDeck extends GenerateColoredDeckBase {
adjustDeckSize(size);
tmpDeck.append("DeckSize:").append(tDeck.countAll()).append("\n");
if (ForgeProps.getProperty("showdeck/2color", "false").equals("true")) {
ErrorViewer.showError(tmpDeck.toString());
BugReporter.reportBug(tmpDeck.toString());
}
return tDeck;

View File

@@ -23,7 +23,7 @@ import java.util.List;
import forge.card.MagicColor;
import forge.card.ColorSet;
import forge.deck.generate.GenerateDeckUtil.FilterCMC;
import forge.error.ErrorViewer;
import forge.error.BugReporter;
import forge.game.player.PlayerType;
import forge.item.CardPrinted;
import forge.item.ItemPoolView;
@@ -100,7 +100,7 @@ public class Generate3ColorDeck extends GenerateColoredDeckBase {
adjustDeckSize(size);
tmpDeck.append("DeckSize:").append(tDeck.countAll()).append("\n");
if (ForgeProps.getProperty("showdeck/3color", "false").equals("true")) {
ErrorViewer.showError(tmpDeck.toString());
BugReporter.reportBug(tmpDeck.toString());
}
return tDeck;

View File

@@ -21,7 +21,7 @@ import java.util.Arrays;
import java.util.List;
import forge.card.ColorSet;
import forge.deck.generate.GenerateDeckUtil.FilterCMC;
import forge.error.ErrorViewer;
import forge.error.BugReporter;
import forge.game.player.PlayerType;
import forge.item.CardPrinted;
import forge.item.ItemPoolView;
@@ -89,7 +89,7 @@ public class Generate5ColorDeck extends GenerateColoredDeckBase {
adjustDeckSize(size);
tmpDeck.append("DeckSize:").append(tDeck.countAll()).append("\n");
if (ForgeProps.getProperty("showdeck/5color", "false").equals("true")) {
ErrorViewer.showError(tmpDeck.toString());
BugReporter.reportBug(tmpDeck.toString());
}
return tDeck;

View File

@@ -22,7 +22,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import forge.error.ErrorViewer;
import forge.error.BugReporter;
import forge.item.CardDb;
import forge.item.CardPrinted;
import forge.item.ItemPoolView;
@@ -156,7 +156,7 @@ public class GenerateThemeDeck extends GenerateColoredDeckBase {
tmpDeck += "DeckSize:" + tDeck.countAll() + "\n";
if (testing) {
ErrorViewer.showError(tmpDeck);
BugReporter.reportBug(tmpDeck);
}
return tDeck;

View File

@@ -1,476 +0,0 @@
/*
* Forge: Play Magic: the Gathering.
* Copyright (C) 2011 Forge Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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.JCheckBox;
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 javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.WindowConstants;
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;
import org.mantisbt.connect.model.ICustomFieldValue;
import org.mantisbt.connect.model.IIssue;
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 forge.Singletons;
import forge.model.BuildInfo;
import forge.properties.ForgePreferences;
import forge.properties.ForgePreferences.FPref;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
/**
* The Class BugzReporter.
*/
public class BugzReporter extends JDialog {
/**
*
*/
private static final long serialVersionUID = -4068301054750322783L;
private ForgePreferences prefs = null;
private final JPanel contentPanel = new JPanel();
private final JTextField txtUserName;
private final JPasswordField txtPassword = new JPasswordField();
private final JComboBox cboCategory = new JComboBox();
private final JTextField txtSummary;
private final JTextArea txtDescription = new JTextArea();
private final JTextArea txtErrorDump = new JTextArea();
private final JComboBox cboVersion = new JComboBox();
private final JComboBox cboSeverity = new JComboBox();
/** The chk report anonymously. */
private final JCheckBox chkReportAnonymously = new JCheckBox("Report Anonymously");
private final JTextField txtSVN;
private final JLabel lblAddInfo = new JLabel();
private final JTextArea txtSteps = new JTextArea();
private static BugzReporter dialog = null;
private IMCAttribute[] severities;
private String url = ForgeProps.getProperty(NewConstants.CARDFORGE_URL) + "/bugz/api/soap/mantisconnect.php";
/**
* Launch the application.
*
* @param args
* the arguments
*/
public static void main(final String[] args) {
// try {
BugzReporter.dialog.setVisible(true);
// } catch (Exception e) {
// System.out.println("Exception - main - " + e.getMessage());
// }
}
/**
* Sets the dump text.
*
* @param dump
* the new dump text
*/
public final void setDumpText(final String dump) {
this.txtErrorDump.setText(dump);
this.lblAddInfo.setText("Crash Report");
this.cboCategory.setSelectedItem("New Crash Report");
}
/**
* Create the dialog.
*/
public BugzReporter() {
BugzReporter.dialog = this;
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
this.setResizable(false);
// Init Logger for Axis, which is used by Mantis Library
final org.apache.log4j.ConsoleAppender appCON = new org.apache.log4j.ConsoleAppender(
new org.apache.log4j.SimpleLayout(), "System.out");
final 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"));
MCSession mCS = null;
try {
mCS = new MCSession(new URL(url), "ForgeGUI", "vi2ccTbfBUu^");
} catch (final MalformedURLException e1) {
System.out.println("MalFormedURLException");
} catch (final MCException e1) {
System.out.println("MCException - new MCSession");
}
String[] cats = {};
try {
cats = mCS.getCategories(1);
} catch (final MCException e1) {
System.out.println("MCException - getCategories - " + e1.getMessage());
}
try {
this.severities = mCS.getEnum(Enumeration.SEVERITIES);
} catch (final MCException e1) {
System.out.println("MCException - getEnum - " + e1.getMessage());
}
IProjectVersion[] vers = {};
try {
vers = mCS.getVersions(1);
} catch (final MCException e1) {
System.out.println("MCException - getVersions - " + e1.getMessage());
}
final BuildInfo bi = Singletons.getModel().getBuildInfo();
this.setTitle("Report Issue");
this.setBounds(100, 100, 442, 575);
this.getContentPane().setLayout(new BorderLayout());
this.contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
this.getContentPane().add(this.contentPanel, BorderLayout.CENTER);
this.contentPanel.setLayout(null);
final JLabel lblMantisUsername = new JLabel("Username");
lblMantisUsername.setHorizontalAlignment(SwingConstants.RIGHT);
lblMantisUsername.setBounds(10, 16, 75, 14);
this.contentPanel.add(lblMantisUsername);
this.txtUserName = new JTextField("ForgeGUI");
this.txtUserName.setBounds(90, 13, 185, 21);
this.txtUserName.setFont(new Font("Dialog", Font.PLAIN, 11));
this.contentPanel.add(this.txtUserName);
this.txtUserName.setColumns(4);
try {
this.prefs = new ForgePreferences();
if (!this.prefs.getPref(FPref.UI_BUGZ_NAME).equals("")) {
this.txtUserName.setText(this.prefs.getPref(FPref.UI_BUGZ_NAME));
this.txtPassword.setText(this.prefs.getPref(FPref.UI_BUGZ_PWD));
this.chkReportAnonymously.setSelected(false);
} else {
this.chkReportAnonymously.setSelected(true);
}
} catch (final Exception e) {
}
this.chkReportAnonymously.setBounds(284, 11, 139, 25);
this.chkReportAnonymously.setFont(new Font("Dialog", Font.PLAIN, 12));
this.chkReportAnonymously.setHorizontalAlignment(SwingConstants.CENTER);
this.chkReportAnonymously.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
if (BugzReporter.this.chkReportAnonymously.isSelected()) {
BugzReporter.this.txtUserName.setText("ForgeGUI");
BugzReporter.this.txtPassword.setText("vi2ccTbfBUu^");
} else {
if (!BugzReporter.this.prefs.getPref(FPref.UI_BUGZ_NAME).equals("")) {
BugzReporter.this.txtUserName.setText(BugzReporter.this.prefs.getPref(FPref.UI_BUGZ_NAME));
BugzReporter.this.txtPassword.setText(BugzReporter.this.prefs.getPref(FPref.UI_BUGZ_PWD));
}
}
}
});
this.contentPanel.add(this.chkReportAnonymously);
final JLabel lblMantisPassword = new JLabel("Password");
lblMantisPassword.setHorizontalAlignment(SwingConstants.RIGHT);
lblMantisPassword.setBounds(10, 45, 75, 14);
this.contentPanel.add(lblMantisPassword);
this.txtPassword.setBounds(90, 42, 185, 21);
this.txtPassword.setFont(new Font("Dialog", Font.PLAIN, 11));
this.contentPanel.add(this.txtPassword);
final JSeparator separator = new JSeparator();
separator.setBounds(10, 69, 417, 2);
this.contentPanel.add(separator);
final JLabel lblCategory = new JLabel("Category");
lblCategory.setBounds(10, 81, 75, 14);
lblCategory.setFont(new Font("Tahoma", Font.BOLD, 11));
lblCategory.setHorizontalAlignment(SwingConstants.RIGHT);
this.contentPanel.add(lblCategory);
this.cboCategory.setBounds(90, 77, 223, 22);
this.cboCategory.setFont(new Font("Dialog", Font.BOLD, 10));
if (cats.length > 0) {
for (final String cat : cats) {
this.cboCategory.addItem(cat);
}
}
this.cboCategory.setSelectedItem("General Bug Report");
this.contentPanel.add(this.cboCategory);
final JLabel lblSummary = new JLabel("Summary");
lblSummary.setBounds(10, 108, 75, 14);
lblSummary.setFont(new Font("Tahoma", Font.BOLD, 11));
lblSummary.setHorizontalAlignment(SwingConstants.RIGHT);
this.contentPanel.add(lblSummary);
this.txtSummary = new JTextField();
this.txtSummary.setBounds(90, 105, 337, 21);
this.txtSummary.setFont(new Font("Dialog", Font.PLAIN, 11));
this.contentPanel.add(this.txtSummary);
this.txtSummary.setColumns(10);
final JLabel lblDescription = new JLabel("Description");
lblDescription.setBounds(10, 182, 75, 21);
lblDescription.setFont(new Font("Tahoma", Font.BOLD, 11));
lblDescription.setHorizontalAlignment(SwingConstants.RIGHT);
this.contentPanel.add(lblDescription);
final JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(90, 132, 337, 120);
this.contentPanel.add(scrollPane);
this.txtDescription.setFont(new Font("Dialog", Font.PLAIN, 10));
scrollPane.setViewportView(this.txtDescription);
this.txtDescription.setBorder(null);
this.txtDescription.setWrapStyleWord(true);
this.txtDescription.setLineWrap(true);
this.txtDescription.setRows(8);
this.lblAddInfo.setText("<html><p align=\"right\">Additional<br>Information</p></html>");
this.lblAddInfo.setBounds(10, 294, 75, 40);
this.lblAddInfo.setFont(new Font("Dialog", Font.PLAIN, 12));
this.lblAddInfo.setHorizontalAlignment(SwingConstants.RIGHT);
this.contentPanel.add(this.lblAddInfo);
final JScrollPane scrollPane3 = new JScrollPane();
scrollPane3.setBounds(90, 254, 337, 120);
this.contentPanel.add(scrollPane3);
this.txtErrorDump.setFont(new Font("Monospaced", Font.PLAIN, 10));
scrollPane.setViewportView(this.txtErrorDump);
this.txtErrorDump.setAutoscrolls(false);
this.txtErrorDump.setMaximumSize(new Dimension(2147483647, 300));
this.txtErrorDump.setBorder(null);
this.txtErrorDump.setLineWrap(true);
this.txtErrorDump.setWrapStyleWord(true);
this.txtErrorDump.setRows(8);
final JLabel lblVersion = new JLabel("Version");
lblVersion.setHorizontalAlignment(SwingConstants.RIGHT);
lblVersion.setBounds(20, 468, 65, 16);
lblVersion.setFont(new Font("Dialog", Font.PLAIN, 12));
this.contentPanel.add(lblVersion);
this.cboVersion.setBounds(90, 465, 160, 22);
this.cboVersion.setFont(new Font("Dialog", Font.BOLD, 10));
this.cboVersion.addItem("");
if (vers.length > 0) {
for (final IProjectVersion ver : vers) {
this.cboVersion.addItem(ver.getName());
// System.out.println(vers[i].getName());
}
}
this.cboVersion.setSelectedIndex(0);
final String curVer = bi.getVersion();
final String[] ss = curVer.split("-");
final String rx = "^" + ss[0].replaceAll("\\.", "\\\\.") + ".*";
System.out.println(ss[0] + " -> " + rx);
if (curVer.equals("SVN")) {
this.cboVersion.setSelectedItem("SVN");
} else {
for (final IProjectVersion ver : vers) {
System.out.println(ver.getName());
if (ver.getName().matches(rx)) {
System.out.println("match");
this.cboVersion.setSelectedItem(ver.getName());
}
}
}
this.contentPanel.add(this.cboVersion);
final JLabel lblRev = new JLabel("SVN rev.");
lblRev.setBounds(247, 468, 66, 16);
lblRev.setHorizontalAlignment(SwingConstants.RIGHT);
lblRev.setFont(new Font("Dialog", Font.PLAIN, 12));
this.contentPanel.add(lblRev);
this.txtSVN = new JTextField();
final String curRev = bi.getBuildID();
if (curRev != null) {
if (!curRev.equals("null")) {
this.txtSVN.setText(curRev);
}
}
this.txtSVN.setBounds(318, 465, 109, 21);
this.txtSVN.setFont(new Font("Dialog", Font.PLAIN, 11));
this.txtSVN.setColumns(10);
this.contentPanel.add(this.txtSVN);
final JLabel lblSeverity = new JLabel("Severity");
lblSeverity.setBounds(10, 496, 75, 16);
lblSeverity.setFont(new Font("Dialog", Font.PLAIN, 12));
lblSeverity.setHorizontalAlignment(SwingConstants.RIGHT);
this.contentPanel.add(lblSeverity);
this.cboSeverity.setBounds(90, 493, 160, 22);
this.cboSeverity.setFont(new Font("Dialog", Font.BOLD, 10));
this.cboSeverity.addItem("");
if (this.severities != null && this.severities.length > 0) {
for (final IMCAttribute severitie : this.severities) {
this.cboSeverity.addItem(severitie.getName());
}
}
this.contentPanel.add(this.cboSeverity);
final JScrollPane scrollPane2 = new JScrollPane();
scrollPane2.setBounds(90, 380, 337, 80);
this.contentPanel.add(scrollPane2);
this.txtSteps.setWrapStyleWord(true);
this.txtSteps.setRows(5);
this.txtSteps.setMaximumSize(new Dimension(2147483647, 300));
this.txtSteps.setLineWrap(true);
this.txtSteps.setFont(new Font("Monospaced", Font.PLAIN, 10));
this.txtSteps.setAutoscrolls(false);
scrollPane.setViewportView(this.txtSteps);
final 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);
this.contentPanel.add(lblSteps);
final JPanel buttonPane = new JPanel();
buttonPane.setOpaque(false);
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
this.getContentPane().add(buttonPane, BorderLayout.SOUTH);
final JButton cmdReport = new JButton("Report");
cmdReport.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent arg0) {
BugzReporter.this.doReport();
}
});
buttonPane.add(cmdReport);
final JButton cmdCancel = new JButton("Cancel");
cmdCancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent arg0) {
BugzReporter.dialog.dispose();
}
});
buttonPane.add(cmdCancel);
}
private void doReport() {
Report: {
if (this.txtSummary.getText().length() < 4) {
JOptionPane.showMessageDialog(null, "Summary field must be provided", "Bug Report",
JOptionPane.ERROR_MESSAGE);
break Report;
}
if (this.txtDescription.getText().length() < 10) {
JOptionPane.showMessageDialog(null, "Description field must be provided", "Bug Report",
JOptionPane.ERROR_MESSAGE);
break Report;
}
MCSession rep = null;
if (!this.chkReportAnonymously.isSelected()) {
try {
rep = new MCSession(new URL(url), this.txtUserName.getText(), String.valueOf(this.txtPassword.getPassword()));
} catch (final MalformedURLException e) {
System.out.println("MalFormedURLException");
} catch (final MCException e) {
System.out.println("MCException - new MCSession - " + e.getMessage());
JOptionPane.showMessageDialog(null, "MCException - new MCSession - " + e.getMessage(),
"Bug Report", JOptionPane.INFORMATION_MESSAGE);
break Report;
}
} else {
try {
rep = new MCSession(new URL(url), "ForgeGUI", "vi2ccTbfBUu^");
} catch (final MalformedURLException e) {
System.out.println("MalformedURLException");
} catch (final MCException e) {
System.out.println("MCException - new MCSession - " + e.getMessage());
JOptionPane.showMessageDialog(null, "MCException - new MCSession - " + e.getMessage(),
"Bug Report", JOptionPane.INFORMATION_MESSAGE);
break Report;
}
}
IIssue iBug = null;
try {
iBug = rep.newIssue(1);
} catch (final MCException e) {
System.out.println("MCException - newIssue - " + e.getMessage());
JOptionPane.showMessageDialog(null, "MCException - newIssue - " + e.getMessage(), "Bug Report",
JOptionPane.INFORMATION_MESSAGE);
break Report;
}
iBug.setCategory(this.cboCategory.getSelectedItem().toString());
iBug.setSummary(this.txtSummary.getText());
iBug.setDescription(this.txtDescription.getText());
iBug.setAdditionalInformation(this.txtErrorDump.getText());
iBug.setVersion(this.cboVersion.getSelectedItem().toString());
for (final IMCAttribute severitie : this.severities) {
if (this.cboSeverity.getSelectedItem().toString().equals(severitie.getName())) {
iBug.setSeverity(severitie);
}
}
iBug.setStepsToReproduce(this.txtSteps.getText());
final ICustomFieldValue[] icfv = { new CustomFieldValue(new MCAttribute(1, "Detected at SVN Rev"),
this.txtSVN.getText()) };
iBug.setCustomFields(icfv);
final DefaultSubmitter ds = new DefaultSubmitter(false);
try {
ds.submitIssue(rep, iBug);
} catch (final MCException e1) {
System.out.println("MCException - submit Issue - " + e1.getMessage());
JOptionPane.showMessageDialog(null, "MCException - submit Issue - " + e1.getMessage(), "Bug Report",
JOptionPane.INFORMATION_MESSAGE);
break Report;
}
this.prefs.setPref(FPref.UI_BUGZ_NAME, this.txtUserName.getText());
this.prefs.setPref(FPref.UI_BUGZ_PWD, String.valueOf(this.txtPassword.getPassword()));
try {
this.prefs.save();
} catch (final Exception e) {
System.out.println("Exception - save preferences - " + e.getMessage());
}
JOptionPane.showMessageDialog(null, "This Issue Has Been Reported, Thank You.", "Bug Report",
JOptionPane.INFORMATION_MESSAGE);
BugzReporter.dialog.dispose();
} // Report:
}
}

View File

@@ -1,338 +0,0 @@
/*
* Forge: Play Magic: the Gathering.
* Copyright (C) 2011 Forge Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package forge.error;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Map;
import java.util.Map.Entry;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.KeyStroke;
import forge.Singletons;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
/**
* The class ErrorViewer. Enables showing and saving error messages that
* occurred in forge.
*
* @author Clemens Koza
* @version V1.0 02.08.2009
*/
public class ErrorViewer {
/** Constant <code>NAME_OS="os.name"</code>. */
private static final String NAME_OS = "os.name";
/** Constant <code>VERSION_OS="os.version"</code>. */
private static final String VERSION_OS = "os.version";
/** Constant <code>ARCHITECTURE_OS="os.arch"</code>. */
private static final String ARCHITECTURE_OS = "os.arch";
/** Constant <code>VERSION_JAVA="java.version"</code>. */
private static final String VERSION_JAVA = "java.version";
/** Constant <code>VENDOR_JAVA="java.vendor"</code>. */
private static final String VENDOR_JAVA = "java.vendor";
/** Constant <code>ALL_THREADS_ACTION</code>. */
public static final Action ALL_THREADS_ACTION = new ShowAllThreadsAction();
private static JDialog dlg = null;
/**
* Shows an error dialog taking the exception's message as the error
* message.
*
* @param ex
* a {@link java.lang.Throwable} object.
*/
public static void showError(final Throwable ex) {
ErrorViewer.showError(ex, null);
}
/**
* 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.
*/
public static void showError(final Throwable ex, final String format, final Object... args) {
if (ex == null) {
return;
}
ErrorViewer.showError(ex, String.format(format, args));
}
/**
* 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.
*/
public static void showError(final Throwable ex, final String message) {
if (ex == null) {
return;
}
final StringWriter sw = new StringWriter();
final PrintWriter pw = new PrintWriter(sw);
ErrorViewer.printError(pw, ex, message);
ErrorViewer.showDialog(sw.toString());
}
/**
* 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.
*/
public static void showError(final String format, final Object... args) {
ErrorViewer.showError(String.format(format, args));
}
/**
* Shows an error without an exception that caused it.
*
* @param message
* a {@link java.lang.String} object.
*/
public static void showError(final String message) {
ErrorViewer.showError(new Exception(), message);
}
/**
* Shows an error message for all running threads.
*
* @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) {
ErrorViewer.showErrorAllThreads(String.format(format, args));
}
/**
* Shows an error message for all running threads.
*
* @param message
* a {@link java.lang.String} object.
*/
public static void showErrorAllThreads(final String message) {
final StringWriter sw = new StringWriter();
final PrintWriter pw = new PrintWriter(sw);
ErrorViewer.printError(pw, message);
ErrorViewer.showDialog(sw.toString());
}
/**
* <p>
* showDialog.
* </p>
*
* @param fullMessage
* a {@link java.lang.String} object.
*/
private static void showDialog(final String fullMessage) {
final JTextArea area = new JTextArea(fullMessage, 40, 90);
area.setFont(new Font("Monospaced", Font.PLAIN, 10));
area.setEditable(false);
area.setLineWrap(true);
area.setWrapStyleWord(true);
// Button is not modified, String gets the automatic listener to hide
// the dialog
final Object[] options = { new JButton(new BugzAction(area)), new JButton(new SaveAction(area)),
ForgeProps.getLocalized(NewConstants.Lang.ErrorViewer.BUTTON_CLOSE), new JButton(new ExitAction()) };
final JOptionPane pane = new JOptionPane(new JScrollPane(area), JOptionPane.ERROR_MESSAGE,
JOptionPane.DEFAULT_OPTION, null, options, options[1]);
ErrorViewer.dlg = pane.createDialog(null, ForgeProps.getLocalized(NewConstants.Lang.ErrorViewer.TITLE));
ErrorViewer.dlg.setResizable(true);
ErrorViewer.dlg.setVisible(true);
ErrorViewer.dlg.dispose();
}
/**
* 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.
*/
private static void printError(final PrintWriter pw, final Throwable ex, final String message) {
if (message != null) {
System.err.println(message);
}
ex.printStackTrace();
pw.printf(ForgeProps.getLocalized(NewConstants.Lang.ErrorViewer.MESSAGE),
ForgeProps.getProperty(NewConstants.HOW_TO_REPORT_BUGS_URL),
message != null ? message : ex.getMessage(), Singletons.getModel().getBuildInfo().toPrettyString(),
System.getProperty(ErrorViewer.NAME_OS), System.getProperty(ErrorViewer.VERSION_OS),
System.getProperty(ErrorViewer.ARCHITECTURE_OS), System.getProperty(ErrorViewer.VERSION_JAVA),
System.getProperty(ErrorViewer.VENDOR_JAVA));
ex.printStackTrace(pw);
}
/**
* 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.
*/
private static void printError(final PrintWriter pw, final String message) {
System.err.println(message);
pw.printf(ForgeProps.getLocalized(NewConstants.Lang.ErrorViewer.MESSAGE),
ForgeProps.getProperty(NewConstants.HOW_TO_REPORT_BUGS_URL), message, Singletons.getModel()
.getBuildInfo().toPrettyString(), System.getProperty(ErrorViewer.NAME_OS),
System.getProperty(ErrorViewer.VERSION_OS), System.getProperty(ErrorViewer.ARCHITECTURE_OS),
System.getProperty(ErrorViewer.VERSION_JAVA), System.getProperty(ErrorViewer.VENDOR_JAVA));
final Map<Thread, StackTraceElement[]> traces = Thread.getAllStackTraces();
for (final Entry<Thread, StackTraceElement[]> e : traces.entrySet()) {
pw.println();
pw.printf("%s (%s):%n", e.getKey().getName(), e.getKey().getId());
for (final StackTraceElement el : e.getValue()) {
pw.println(el);
}
}
}
private static class SaveAction extends AbstractAction {
private static final long serialVersionUID = 9146834661273525959L;
private static JFileChooser c;
private final JTextArea area;
public SaveAction(final JTextArea areaParam) {
super(ForgeProps.getLocalized(NewConstants.Lang.ErrorViewer.BUTTON_SAVE));
this.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK));
this.area = areaParam;
}
@Override
public void actionPerformed(final ActionEvent e) {
if (SaveAction.c == null) {
SaveAction.c = new JFileChooser();
}
File f;
for (int i = 0;; i++) {
final String name = String.format("%TF-%02d.txt", System.currentTimeMillis(), i);
f = new File(name);
if (!f.exists()) {
break;
}
}
SaveAction.c.setSelectedFile(f);
SaveAction.c.showSaveDialog(null);
f = SaveAction.c.getSelectedFile();
try {
final BufferedWriter bw = new BufferedWriter(new FileWriter(f));
bw.write(this.area.getText());
bw.close();
} catch (final IOException ex) {
ErrorViewer.showError(ex, ForgeProps.getLocalized(NewConstants.Lang.ErrorViewer.ERRORS.SAVE_MESSAGE));
}
}
}
private static class BugzAction extends AbstractAction {
private static final long serialVersionUID = 914634661273525959L;
private final JTextArea area;
public BugzAction(final JTextArea neoArea) {
this.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_B, InputEvent.CTRL_DOWN_MASK));
this.putValue(Action.NAME, "Report Bug");
this.area = neoArea;
}
@Override
public void actionPerformed(final ActionEvent e) {
final BugzReporter br = new BugzReporter();
br.setDumpText(this.area.getText());
br.setVisible(true);
ErrorViewer.dlg.dispose();
}
}
private static class ExitAction extends AbstractAction {
private static final long serialVersionUID = 276202595758381626L;
public ExitAction() {
super(ForgeProps.getLocalized(NewConstants.Lang.ErrorViewer.BUTTON_EXIT));
}
@Override
public void actionPerformed(final ActionEvent e) {
System.exit(0);
}
}
private static class ShowAllThreadsAction extends AbstractAction {
private static final long serialVersionUID = 5638147106706803363L;
public ShowAllThreadsAction() {
super(ForgeProps.getLocalized(NewConstants.Lang.ErrorViewer.SHOW_ERROR));
}
@Override
public void actionPerformed(final ActionEvent e) {
ErrorViewer.showErrorAllThreads(ForgeProps.getLocalized(NewConstants.Lang.ErrorViewer.ERRORS.SHOW_MESSAGE));
}
}
}

View File

@@ -48,7 +48,7 @@ public class ExceptionHandler implements UncaughtExceptionHandler {
/** {@inheritDoc} */
@Override
public final void uncaughtException(final Thread t, final Throwable ex) {
ErrorViewer.showError(ex);
BugReporter.reportException(ex);
}
/**
@@ -59,6 +59,6 @@ public class ExceptionHandler implements UncaughtExceptionHandler {
* a {@link java.lang.Throwable} object.
*/
public final void handle(final Throwable ex) {
ErrorViewer.showError(ex);
BugReporter.reportException(ex);
}
}

View File

@@ -12,7 +12,7 @@ import forge.Constant.Preferences;
import forge.control.FControl;
import forge.control.input.InputControl;
import forge.deck.Deck;
import forge.error.ErrorViewer;
import forge.error.BugReporter;
import forge.game.event.DuelOutcomeEvent;
import forge.game.player.LobbyPlayer;
import forge.game.player.Player;
@@ -179,7 +179,7 @@ public class MatchController {
CMatchUI.SINGLETON_INSTANCE.setCard(Singletons.getControl().getPlayer().getCardsIn(ZoneType.Hand).get(0));
} catch (Exception e) {
ErrorViewer.showError(e);
BugReporter.reportException(e);
}
}

View File

@@ -44,7 +44,7 @@ import forge.card.mana.ManaCost;
import forge.card.spellability.AbilityStatic;
import forge.card.spellability.SpellAbility;
import forge.card.spellability.Target;
import forge.error.ErrorViewer;
import forge.error.BugReporter;
import forge.game.GameState;
import forge.game.phase.Combat;
import forge.game.phase.CombatUtil;
@@ -760,7 +760,7 @@ public class ComputerUtil {
}
} catch (final Exception ex) {
ErrorViewer.showError(ex, "There is an error in the card code for %s:%n", c.getName(),
BugReporter.reportException(ex, "There is an error in the card code for %s:%n", c.getName(),
ex.getMessage());
}
}
@@ -806,7 +806,7 @@ public class ComputerUtil {
}
}
} catch (final Exception ex) {
ErrorViewer.showError(ex, "There is an error in the card code for %s:%n", c.getName(),
BugReporter.reportException(ex, "There is an error in the card code for %s:%n", c.getName(),
ex.getMessage());
}
}

View File

@@ -21,7 +21,7 @@ import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import forge.deck.CardPool;
import forge.error.ErrorViewer;
import forge.error.BugReporter;
import forge.item.CardDb;
import forge.item.CardPrinted;
import forge.util.IgnoringXStream;
@@ -128,7 +128,7 @@ public class GauntletIO {
return data;
} catch (final Exception ex) {
ErrorViewer.showError(ex, "Error loading Gauntlet Data");
BugReporter.reportException(ex, "Error loading Gauntlet Data");
throw new RuntimeException(ex);
}
}
@@ -146,7 +146,7 @@ public class GauntletIO {
final XStream xStream = GauntletIO.getSerializer(false);
GauntletIO.savePacked(xStream, gd0);
} catch (final Exception ex) {
ErrorViewer.showError(ex, "Error saving Gauntlet Data.");
BugReporter.reportException(ex, "Error saving Gauntlet Data.");
throw new RuntimeException(ex);
}
}

View File

@@ -52,7 +52,7 @@ import com.esotericsoftware.minlog.Log;
import forge.CardUtil;
import forge.Singletons;
import forge.error.ErrorViewer;
import forge.error.BugReporter;
import forge.item.CardDb;
import forge.item.CardPrinted;
import forge.properties.ForgeProps;
@@ -360,7 +360,7 @@ public final class GuiMigrateLocalMWSSetPicturesHQ extends DefaultBoundedRangeMo
p = new Proxy(GuiMigrateLocalMWSSetPicturesHQ.TYPES[this.type], new InetSocketAddress(
this.addr.getText(), Integer.parseInt(this.port.getText())));
} catch (final Exception ex) {
ErrorViewer.showError(ex,
BugReporter.reportException(ex,
ForgeProps.getLocalized(NewConstants.Lang.GuiDownloadPictures.Errors.PROXY_CONNECT),
this.addr.getText(), this.port.getText());
// throw new

View File

@@ -13,7 +13,7 @@ import forge.Command;
import forge.deck.Deck;
import forge.deck.DeckBase;
import forge.deck.io.DeckSerializer;
import forge.error.ErrorViewer;
import forge.error.BugReporter;
import forge.gui.deckeditor.CDeckEditorUI;
import forge.gui.deckeditor.SEditorIO;
import forge.gui.deckeditor.tables.DeckController;
@@ -137,7 +137,7 @@ public enum CCurrentDeck implements ICDoc {
}
});
} catch (final Exception ex) {
ErrorViewer.showError(ex);
BugReporter.reportException(ex);
throw new RuntimeException("Error creating new deck. " + ex);
}
}
@@ -156,7 +156,7 @@ public enum CCurrentDeck implements ICDoc {
.setModel(Deck.fromFile(file));
} catch (final Exception ex) {
ErrorViewer.showError(ex);
BugReporter.reportException(ex);
throw new RuntimeException("Error importing deck." + ex);
}
}
@@ -191,7 +191,7 @@ public enum CCurrentDeck implements ICDoc {
((DeckController<Deck>) CDeckEditorUI.SINGLETON_INSTANCE
.getCurrentEditorController().getDeckController()).getModel(), filename);
} catch (final Exception ex) {
ErrorViewer.showError(ex);
BugReporter.reportException(ex);
throw new RuntimeException("Error exporting deck." + ex);
}
}
@@ -209,7 +209,7 @@ public enum CCurrentDeck implements ICDoc {
((DeckController<Deck>) CDeckEditorUI.SINGLETON_INSTANCE
.getCurrentEditorController().getDeckController()).getModel(), filename);
} catch (final Exception ex) {
ErrorViewer.showError(ex);
BugReporter.reportException(ex);
throw new RuntimeException("Error exporting deck." + ex);
}
}

View File

@@ -56,7 +56,7 @@ import org.apache.commons.lang3.StringUtils;
import com.esotericsoftware.minlog.Log;
import forge.Command;
import forge.error.ErrorViewer;
import forge.error.BugReporter;
import forge.gui.SOverlayUtils;
import forge.gui.toolbox.FButton;
import forge.gui.toolbox.FLabel;
@@ -337,7 +337,7 @@ public abstract class GuiDownloader extends DefaultBoundedRangeModel implements
p = new Proxy(GuiDownloader.TYPES[this.type], new InetSocketAddress(this.txfAddr.getText(),
Integer.parseInt(this.txfPort.getText())));
} catch (final Exception ex) {
ErrorViewer.showError(ex,
BugReporter.reportException(ex,
ForgeProps.getLocalized(NewConstants.Lang.GuiDownloadPictures.Errors.PROXY_CONNECT),
this.txfAddr.getText(), this.txfPort.getText());
return;

View File

@@ -3,7 +3,7 @@ package forge.gui.home.settings;
import javax.swing.SwingUtilities;
import forge.Command;
import forge.error.BugzReporter;
import forge.error.BugReporter;
import forge.gui.GuiImportPicture;
import forge.gui.download.GuiDownloadPicturesLQ;
import forge.gui.download.GuiDownloadPrices;
@@ -45,8 +45,7 @@ public enum CSubmenuDownloaders implements ICDoc {
private final Command cmdReportBug = new Command() { @Override
public void execute() {
final BugzReporter br = new BugzReporter();
br.setVisible(true);
BugReporter.reportBug(null);
}
};

View File

@@ -27,7 +27,7 @@ import java.io.File;
import java.io.IOException;
import java.util.Locale;
import forge.error.ErrorViewer;
import forge.error.BugReporter;
import forge.util.TreeProperties;
/**
@@ -47,7 +47,7 @@ public class ForgeProps {
p = new TreeProperties(NewConstants.PREFS_MAIN_PROPERTIES_FILE);
p.rethrow();
} catch (final IOException ex) {
ErrorViewer.showError(ex);
BugReporter.reportException(ex);
p = null;
}
PROPERTIES = p;

View File

@@ -58,7 +58,7 @@ import forge.card.CardEdition;
import forge.deck.CardPool;
import forge.deck.Deck;
import forge.deck.DeckSection;
import forge.error.ErrorViewer;
import forge.error.BugReporter;
import forge.quest.data.GameFormatQuest;
import forge.item.BoosterPack;
import forge.item.CardDb;
@@ -142,13 +142,13 @@ public class QuestDataIO {
try {
QuestDataIO.updateSaveFile(data, xml.toString(), xmlSaveFile.getName().replace(".dat", ""));
} catch (final Exception e) {
forge.error.ErrorViewer.showError(e);
forge.error.BugReporter.reportException(e);
}
}
return data;
} catch (final Exception ex) {
ErrorViewer.showError(ex, "Error loading Quest Data");
BugReporter.reportException(ex, "Error loading Quest Data");
throw new RuntimeException(ex);
}
}
@@ -361,7 +361,7 @@ public class QuestDataIO {
// QuestDataIO.saveUnpacked(f + ".xml", xStream, qd);
} catch (final Exception ex) {
ErrorViewer.showError(ex, "Error saving Quest Data.");
BugReporter.reportException(ex, "Error saving Quest Data.");
throw new RuntimeException(ex);
}
}

View File

@@ -32,7 +32,7 @@ import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import forge.error.ErrorViewer;
import forge.error.BugReporter;
import forge.properties.ForgeProps;
import forge.properties.NewConstants.Lang.GuiDownloadPictures.Errors;
@@ -103,7 +103,7 @@ public final class FileUtil {
io.flush();
io.close();
} catch (final Exception ex) {
ErrorViewer.showError(ex);
BugReporter.reportException(ex);
throw new RuntimeException("FileUtil : writeFile() error, problem writing file - " + file + " : " + ex);
}
} // writeAllDecks()
@@ -140,7 +140,7 @@ public final class FileUtil {
}
return FileUtil.readAllLines(new FileReader(file), false);
} catch (final Exception ex) {
ErrorViewer.showError(ex);
BugReporter.reportException(ex);
throw new RuntimeException("FileUtil : readFile() error, " + ex);
}
} // readFile()
@@ -175,7 +175,7 @@ public final class FileUtil {
}
in.close();
} catch (final IOException ex) {
ErrorViewer.showError(ex);
BugReporter.reportException(ex);
throw new RuntimeException("FileUtil : readAllLines() error, " + ex);
}
return list;
@@ -207,7 +207,7 @@ public final class FileUtil {
out.flush();
out.close();
} catch (final IOException ioex) {
ErrorViewer.showError(ioex, ForgeProps.getLocalized(Errors.OTHER), "deck_temp.html", url);
BugReporter.reportException(ioex, ForgeProps.getLocalized(Errors.OTHER), "deck_temp.html", url);
}
}

View File

@@ -34,7 +34,7 @@ import org.apache.commons.lang3.StringUtils;
import com.google.common.base.Function;
import forge.deck.io.OldDeckFileFormatException;
import forge.error.ErrorViewer;
import forge.error.BugReporter;
import forge.util.IItemReader;
/**
@@ -81,7 +81,7 @@ public abstract class StorageReaderFolder<T> implements IItemReader<T> {
}
}
} catch (final IOException ex) {
ErrorViewer.showError(ex);
BugReporter.reportException(ex);
throw new RuntimeException("DeckManager : writeDeck() error, " + ex.getMessage());
}
}

View File

@@ -9,7 +9,7 @@ import javax.swing.JPanel;
import org.testng.annotations.Test;
import forge.error.ErrorViewer;
import forge.error.BugReporter;
/**
* <p>
@@ -47,7 +47,7 @@ public class PanelTest extends JFrame {
try {
this.jbInit();
} catch (final Exception ex) {
ErrorViewer.showError(ex);
BugReporter.reportException(ex);
ex.printStackTrace();
}
}