PageRenderTime 22ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/src/mpv5/bugtracker/SubmitForm.java

http://mp-rechnungs-und-kundenverwaltung.googlecode.com/
Java | 244 lines | 183 code | 26 blank | 35 comment | 4 complexity | bbf24f3651a437d0e744888aca46525a MD5 | raw file
Possible License(s): LGPL-3.0, Apache-2.0, GPL-3.0, GPL-2.0, AGPL-3.0, JSON, BSD-3-Clause
  1. /*
  2. * This file is part of YaBS.
  3. *
  4. * YaBS is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * YaBS is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with YaBS. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. /*
  18. * SubmitForm.java
  19. *
  20. * Created on 05.08.2009, 11:28:47
  21. */
  22. package mpv5.bugtracker;
  23. import java.awt.Desktop;
  24. import java.net.URI;
  25. import java.net.URLEncoder;
  26. import java.util.List;
  27. import java.util.logging.Level;
  28. import java.util.logging.Logger;
  29. import mpv5.globals.Constants;
  30. import mpv5.logging.Log;
  31. import mpv5.ui.dialogs.BigPopup;
  32. import mpv5.ui.dialogs.Popup;
  33. /**
  34. *
  35. */
  36. public class SubmitForm extends javax.swing.JPanel {
  37. /** Creates new form SubmitForm
  38. * @param exceptions
  39. */
  40. public SubmitForm(List<Exception> exceptions) {
  41. initComponents();
  42. String exc = "";
  43. for (int i = exceptions.size()-1; i >=0 ; i--) {
  44. Exception exception = exceptions.get(i);
  45. exc += "Exception " + i + ":\n";
  46. exc += Log.getStackTrace(exception);
  47. try {
  48. exc += "\nCaused by:\n";
  49. exc += Log.getStackTrace(exception.getCause());
  50. } catch (Exception e) {
  51. }
  52. exc += "\n\n";
  53. }
  54. trace.setText(exc);
  55. trace.setSelectionStart(0);
  56. trace.setSelectionEnd(0);
  57. validate();
  58. }
  59. /** This method is called from within the constructor to
  60. * initialize the form.
  61. * WARNING: Do NOT modify this code. The content of this method is
  62. * always regenerated by the Form Editor.
  63. */
  64. @SuppressWarnings("unchecked")
  65. // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  66. private void initComponents() {
  67. jScrollPane1 = new javax.swing.JScrollPane();
  68. description = new javax.swing.JTextArea();
  69. jLabel1 = new javax.swing.JLabel();
  70. jScrollPane2 = new javax.swing.JScrollPane();
  71. steps = new javax.swing.JTextArea();
  72. jLabel2 = new javax.swing.JLabel();
  73. jScrollPane3 = new javax.swing.JScrollPane();
  74. trace = new javax.swing.JTextArea();
  75. jButton1 = new javax.swing.JButton();
  76. jScrollPane4 = new javax.swing.JScrollPane();
  77. optional = new javax.swing.JTextArea();
  78. google = new javax.swing.JCheckBox();
  79. java.util.ResourceBundle bundle = mpv5.i18n.LanguageManager.getBundle(); // NOI18N
  80. setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("SubmitForm.border.title"))); // NOI18N
  81. setName("Form"); // NOI18N
  82. jScrollPane1.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
  83. jScrollPane1.setName("jScrollPane1"); // NOI18N
  84. description.setBackground(new java.awt.Color(238, 238, 238));
  85. description.setColumns(20);
  86. description.setEditable(false);
  87. description.setLineWrap(true);
  88. description.setRows(5);
  89. description.setText(bundle.getString("SubmitForm.description.text")); // NOI18N
  90. description.setWrapStyleWord(true);
  91. description.setName("description"); // NOI18N
  92. jScrollPane1.setViewportView(description);
  93. jLabel1.setText(bundle.getString("SubmitForm.jLabel1.text")); // NOI18N
  94. jLabel1.setName("jLabel1"); // NOI18N
  95. jScrollPane2.setName("jScrollPane2"); // NOI18N
  96. steps.setColumns(20);
  97. steps.setLineWrap(true);
  98. steps.setRows(5);
  99. steps.setWrapStyleWord(true);
  100. steps.setName("steps"); // NOI18N
  101. jScrollPane2.setViewportView(steps);
  102. jLabel2.setText(bundle.getString("SubmitForm.jLabel2.text")); // NOI18N
  103. jLabel2.setName("jLabel2"); // NOI18N
  104. jScrollPane3.setName("jScrollPane3"); // NOI18N
  105. trace.setColumns(20);
  106. trace.setEditable(false);
  107. trace.setLineWrap(true);
  108. trace.setRows(5);
  109. trace.setWrapStyleWord(true);
  110. trace.setName("trace"); // NOI18N
  111. jScrollPane3.setViewportView(trace);
  112. jButton1.setText(bundle.getString("SubmitForm.jButton1.text")); // NOI18N
  113. jButton1.setName("jButton1"); // NOI18N
  114. jButton1.addActionListener(new java.awt.event.ActionListener() {
  115. public void actionPerformed(java.awt.event.ActionEvent evt) {
  116. jButton1ActionPerformed(evt);
  117. }
  118. });
  119. jScrollPane4.setBorder(javax.swing.BorderFactory.createEtchedBorder());
  120. jScrollPane4.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
  121. jScrollPane4.setName("jScrollPane4"); // NOI18N
  122. optional.setBackground(new java.awt.Color(238, 238, 238));
  123. optional.setColumns(20);
  124. optional.setEditable(false);
  125. optional.setLineWrap(true);
  126. optional.setRows(5);
  127. optional.setText(bundle.getString("SubmitForm.optional.text")); // NOI18N
  128. optional.setWrapStyleWord(true);
  129. optional.setName("optional"); // NOI18N
  130. jScrollPane4.setViewportView(optional);
  131. google.setSelected(true);
  132. google.setText(bundle.getString("SubmitForm.google.text")); // NOI18N
  133. google.setName("google"); // NOI18N
  134. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
  135. this.setLayout(layout);
  136. layout.setHorizontalGroup(
  137. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  138. .addGroup(layout.createSequentialGroup()
  139. .addContainerGap()
  140. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  141. .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE)
  142. .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE)
  143. .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE)
  144. .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE)
  145. .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE)
  146. .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE)
  147. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  148. .addComponent(google, javax.swing.GroupLayout.DEFAULT_SIZE, 358, Short.MAX_VALUE)
  149. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  150. .addComponent(jButton1)))
  151. .addContainerGap())
  152. );
  153. layout.setVerticalGroup(
  154. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  155. .addGroup(layout.createSequentialGroup()
  156. .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)
  157. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  158. .addComponent(jLabel1)
  159. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  160. .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  161. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  162. .addComponent(jLabel2)
  163. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  164. .addComponent(jScrollPane3)
  165. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  166. .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
  167. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  168. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  169. .addComponent(jButton1)
  170. .addComponent(google)))
  171. );
  172. }// </editor-fold>//GEN-END:initComponents
  173. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
  174. if (google.isSelected()) {
  175. try {
  176. String message = "This is a generated issue report for Yabs Version " + Constants.VERSION;
  177. message += "\n\n" + steps.getText() + "\n\n" + trace.getText();
  178. message = URLEncoder.encode(message, "UTF-8");
  179. if (message.length() > 1000) {
  180. message = message.substring(0, 999);
  181. message+="CUTOFF";
  182. }
  183. String url = "http://code.google.com/p/mp-rechnungs-und-kundenverwaltung/issues/entry?" +
  184. "labels=Type-Defect,Priority-Medium,Milestone-Release_" + Constants.VERSION +
  185. "&template=User+defect+report&summary=Unexpected+error+in+YaBS" +
  186. "+Version+" + Constants.VERSION + "&" +
  187. "comment=" + message +
  188. "";
  189. Desktop.getDesktop().browse(new URI(url));
  190. BigPopup.close(this);
  191. } catch (Exception x) {
  192. Log.Debug(x);
  193. }
  194. } else {
  195. String message = "This is a generated issue report for Yabs Version " + Constants.VERSION;
  196. message += "\n\n" + steps.getText() + "\n\n" + trace.getText();
  197. Popup.notice("Please send this message to openyabs@googlegroups.com: \n\nThank you!\n\n" +
  198. message, 500, 500);
  199. try {
  200. BigPopup.close(this);
  201. } catch (Exception ex) {}
  202. }
  203. }//GEN-LAST:event_jButton1ActionPerformed
  204. // Variables declaration - do not modify//GEN-BEGIN:variables
  205. private javax.swing.JTextArea description;
  206. private javax.swing.JCheckBox google;
  207. private javax.swing.JButton jButton1;
  208. private javax.swing.JLabel jLabel1;
  209. private javax.swing.JLabel jLabel2;
  210. private javax.swing.JScrollPane jScrollPane1;
  211. private javax.swing.JScrollPane jScrollPane2;
  212. private javax.swing.JScrollPane jScrollPane3;
  213. private javax.swing.JScrollPane jScrollPane4;
  214. private javax.swing.JTextArea optional;
  215. private javax.swing.JTextArea steps;
  216. private javax.swing.JTextArea trace;
  217. // End of variables declaration//GEN-END:variables
  218. }