PageRenderTime 144ms CodeModel.GetById 60ms app.highlight 43ms RepoModel.GetById 37ms app.codeStats 1ms

/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
  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 */
 22package mpv5.bugtracker;
 23
 24import java.awt.Desktop;
 25import java.net.URI;
 26import java.net.URLEncoder;
 27import java.util.List;
 28
 29import java.util.logging.Level;
 30import java.util.logging.Logger;
 31import mpv5.globals.Constants;
 32import mpv5.logging.Log;
 33import mpv5.ui.dialogs.BigPopup;
 34import mpv5.ui.dialogs.Popup;
 35
 36/**
 37 *
 38 */
 39public class SubmitForm extends javax.swing.JPanel {
 40
 41    /** Creates new form SubmitForm
 42     * @param exceptions
 43     */
 44    public SubmitForm(List<Exception> exceptions) {
 45        initComponents();
 46
 47        String exc = "";
 48        for (int i = exceptions.size()-1; i >=0 ; i--) {
 49            Exception exception = exceptions.get(i);
 50            exc += "Exception " + i + ":\n";
 51            exc += Log.getStackTrace(exception);
 52            try {
 53                exc += "\nCaused by:\n";
 54                exc += Log.getStackTrace(exception.getCause());
 55            } catch (Exception e) {
 56            }
 57            exc += "\n\n";
 58        }
 59
 60        trace.setText(exc);
 61        trace.setSelectionStart(0);
 62        trace.setSelectionEnd(0);
 63        validate();
 64    }
 65
 66    /** This method is called from within the constructor to
 67     * initialize the form.
 68     * WARNING: Do NOT modify this code. The content of this method is
 69     * always regenerated by the Form Editor.
 70     */
 71    @SuppressWarnings("unchecked")
 72    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
 73    private void initComponents() {
 74
 75        jScrollPane1 = new javax.swing.JScrollPane();
 76        description = new javax.swing.JTextArea();
 77        jLabel1 = new javax.swing.JLabel();
 78        jScrollPane2 = new javax.swing.JScrollPane();
 79        steps = new javax.swing.JTextArea();
 80        jLabel2 = new javax.swing.JLabel();
 81        jScrollPane3 = new javax.swing.JScrollPane();
 82        trace = new javax.swing.JTextArea();
 83        jButton1 = new javax.swing.JButton();
 84        jScrollPane4 = new javax.swing.JScrollPane();
 85        optional = new javax.swing.JTextArea();
 86        google = new javax.swing.JCheckBox();
 87
 88        java.util.ResourceBundle bundle = mpv5.i18n.LanguageManager.getBundle(); // NOI18N
 89        setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("SubmitForm.border.title"))); // NOI18N
 90        setName("Form"); // NOI18N
 91
 92        jScrollPane1.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
 93        jScrollPane1.setName("jScrollPane1"); // NOI18N
 94
 95        description.setBackground(new java.awt.Color(238, 238, 238));
 96        description.setColumns(20);
 97        description.setEditable(false);
 98        description.setLineWrap(true);
 99        description.setRows(5);
100        description.setText(bundle.getString("SubmitForm.description.text")); // NOI18N
101        description.setWrapStyleWord(true);
102        description.setName("description"); // NOI18N
103        jScrollPane1.setViewportView(description);
104
105        jLabel1.setText(bundle.getString("SubmitForm.jLabel1.text")); // NOI18N
106        jLabel1.setName("jLabel1"); // NOI18N
107
108        jScrollPane2.setName("jScrollPane2"); // NOI18N
109
110        steps.setColumns(20);
111        steps.setLineWrap(true);
112        steps.setRows(5);
113        steps.setWrapStyleWord(true);
114        steps.setName("steps"); // NOI18N
115        jScrollPane2.setViewportView(steps);
116
117        jLabel2.setText(bundle.getString("SubmitForm.jLabel2.text")); // NOI18N
118        jLabel2.setName("jLabel2"); // NOI18N
119
120        jScrollPane3.setName("jScrollPane3"); // NOI18N
121
122        trace.setColumns(20);
123        trace.setEditable(false);
124        trace.setLineWrap(true);
125        trace.setRows(5);
126        trace.setWrapStyleWord(true);
127        trace.setName("trace"); // NOI18N
128        jScrollPane3.setViewportView(trace);
129
130        jButton1.setText(bundle.getString("SubmitForm.jButton1.text")); // NOI18N
131        jButton1.setName("jButton1"); // NOI18N
132        jButton1.addActionListener(new java.awt.event.ActionListener() {
133            public void actionPerformed(java.awt.event.ActionEvent evt) {
134                jButton1ActionPerformed(evt);
135            }
136        });
137
138        jScrollPane4.setBorder(javax.swing.BorderFactory.createEtchedBorder());
139        jScrollPane4.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
140        jScrollPane4.setName("jScrollPane4"); // NOI18N
141
142        optional.setBackground(new java.awt.Color(238, 238, 238));
143        optional.setColumns(20);
144        optional.setEditable(false);
145        optional.setLineWrap(true);
146        optional.setRows(5);
147        optional.setText(bundle.getString("SubmitForm.optional.text")); // NOI18N
148        optional.setWrapStyleWord(true);
149        optional.setName("optional"); // NOI18N
150        jScrollPane4.setViewportView(optional);
151
152        google.setSelected(true);
153        google.setText(bundle.getString("SubmitForm.google.text")); // NOI18N
154        google.setName("google"); // NOI18N
155
156        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
157        this.setLayout(layout);
158        layout.setHorizontalGroup(
159            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
160            .addGroup(layout.createSequentialGroup()
161                .addContainerGap()
162                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
163                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE)
164                    .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE)
165                    .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE)
166                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE)
167                    .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE)
168                    .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE)
169                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
170                        .addComponent(google, javax.swing.GroupLayout.DEFAULT_SIZE, 358, Short.MAX_VALUE)
171                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
172                        .addComponent(jButton1)))
173                .addContainerGap())
174        );
175        layout.setVerticalGroup(
176            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
177            .addGroup(layout.createSequentialGroup()
178                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)
179                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
180                .addComponent(jLabel1)
181                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
182                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
183                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
184                .addComponent(jLabel2)
185                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
186                .addComponent(jScrollPane3)
187                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
188                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
189                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
190                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
191                    .addComponent(jButton1)
192                    .addComponent(google)))
193        );
194    }// </editor-fold>//GEN-END:initComponents
195
196    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
197
198        if (google.isSelected()) {
199            try {
200                String message = "This is a generated issue report for Yabs Version " + Constants.VERSION;
201                message += "\n\n" + steps.getText() + "\n\n" + trace.getText();
202                message = URLEncoder.encode(message, "UTF-8");
203                if (message.length() > 1000) {
204                    message = message.substring(0, 999);
205                    message+="CUTOFF";
206                }
207
208                String url = "http://code.google.com/p/mp-rechnungs-und-kundenverwaltung/issues/entry?" +
209                        "labels=Type-Defect,Priority-Medium,Milestone-Release_" + Constants.VERSION +
210                        "&template=User+defect+report&summary=Unexpected+error+in+YaBS" +
211                        "+Version+" + Constants.VERSION + "&" +
212                        "comment=" + message +
213                        "";
214
215                Desktop.getDesktop().browse(new URI(url));
216                BigPopup.close(this);
217            } catch (Exception x) {
218                Log.Debug(x);
219            }
220        } else {
221            String message = "This is a generated issue report for Yabs Version " + Constants.VERSION;
222            message += "\n\n" + steps.getText() + "\n\n" + trace.getText();
223            Popup.notice("Please send this message to openyabs@googlegroups.com: \n\nThank you!\n\n" +
224                    message, 500, 500);
225            try {
226                BigPopup.close(this);
227            } catch (Exception ex) {}
228        }
229    }//GEN-LAST:event_jButton1ActionPerformed
230    // Variables declaration - do not modify//GEN-BEGIN:variables
231    private javax.swing.JTextArea description;
232    private javax.swing.JCheckBox google;
233    private javax.swing.JButton jButton1;
234    private javax.swing.JLabel jLabel1;
235    private javax.swing.JLabel jLabel2;
236    private javax.swing.JScrollPane jScrollPane1;
237    private javax.swing.JScrollPane jScrollPane2;
238    private javax.swing.JScrollPane jScrollPane3;
239    private javax.swing.JScrollPane jScrollPane4;
240    private javax.swing.JTextArea optional;
241    private javax.swing.JTextArea steps;
242    private javax.swing.JTextArea trace;
243    // End of variables declaration//GEN-END:variables
244}