KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > exceptions > ReportDialog


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20
21 package org.netbeans.modules.exceptions;
22
23 import java.awt.event.ActionEvent JavaDoc;
24 import java.awt.event.ActionListener JavaDoc;
25 import javax.swing.DefaultComboBoxModel JavaDoc;
26 import org.netbeans.modules.exceptions.settings.ExceptionsRepos;
27 import org.netbeans.modules.exceptions.settings.ExceptionsSettings;
28 import org.openide.DialogDisplayer;
29 import org.openide.NotifyDescriptor;
30
31 /**
32  *
33  * @author jindra
34  */

35 public class ReportDialog extends javax.swing.JFrame JavaDoc {
36     String JavaDoc[] components = ExceptionsRepos.getInstance().getComponents();
37     ExceptionsSettings exSettings = new ExceptionsSettings();
38     
39     /** Creates new form Report */
40     public ReportDialog() {
41         initComponents();
42         updateSubComponents();
43     }
44     
45     /** This method is called from within the constructor to
46      * initialize the form.
47      * WARNING: Do NOT modify this code. The content of this method is
48      * always regenerated by the Form Editor.
49      */

50     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
51
private void initComponents() {
52
53         cancelButton = new javax.swing.JButton JavaDoc();
54         submitButton = new javax.swing.JButton JavaDoc();
55         jScrollPane1 = new javax.swing.JScrollPane JavaDoc();
56         commentArea = new javax.swing.JTextArea JavaDoc();
57         jLabel1 = new javax.swing.JLabel JavaDoc();
58         loginField = new javax.swing.JTextField JavaDoc();
59         jLabel4 = new javax.swing.JLabel JavaDoc();
60         jLabel3 = new javax.swing.JLabel JavaDoc();
61         jLabel5 = new javax.swing.JLabel JavaDoc();
62         jLabel6 = new javax.swing.JLabel JavaDoc();
63         jLabel7 = new javax.swing.JLabel JavaDoc();
64         componentBox = new javax.swing.JComboBox JavaDoc();
65         jLabel8 = new javax.swing.JLabel JavaDoc();
66         subComponentBox = new javax.swing.JComboBox JavaDoc();
67         jSeparator1 = new javax.swing.JSeparator JavaDoc();
68         jSeparator2 = new javax.swing.JSeparator JavaDoc();
69         jLabel9 = new javax.swing.JLabel JavaDoc();
70         jTextField1 = new javax.swing.JTextField JavaDoc();
71
72         setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
73         setTitle(org.openide.util.NbBundle.getMessage(ReportDialog.class, "ReportDialog_title")); // NOI18N
74

75         org.openide.awt.Mnemonics.setLocalizedText(cancelButton, org.openide.util.NbBundle.getMessage(ReportDialog.class, "Report.cancelButton.text")); // NOI18N
76
cancelButton.addActionListener(new java.awt.event.ActionListener JavaDoc() {
77             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
78                 cancelButtonPressed(evt);
79             }
80         });
81
82         org.openide.awt.Mnemonics.setLocalizedText(submitButton, org.openide.util.NbBundle.getMessage(ReportDialog.class, "Report.submitButton.text")); // NOI18N
83
submitButton.addActionListener(new java.awt.event.ActionListener JavaDoc() {
84             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
85                 reportListener(evt);
86             }
87         });
88
89         commentArea.setColumns(20);
90         commentArea.setRows(5);
91         jScrollPane1.setViewportView(commentArea);
92         commentArea.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ReportDialog.class, "AN_Comment")); // NOI18N
93
commentArea.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ReportDialog.class, "AD_CommentBox")); // NOI18N
94
commentArea.getAccessibleContext().setAccessibleParent(this);
95
96         jLabel1.setText(org.openide.util.NbBundle.getMessage(ReportDialog.class, "Report.jLabel1.text")); // NOI18N
97

98         loginField.setText(exSettings.getUserName());
99
100         jLabel4.setText(org.openide.util.NbBundle.getMessage(ReportDialog.class, "Report.jLabel4.text")); // NOI18N
101

102         jLabel3.setText(org.openide.util.NbBundle.getMessage(ReportDialog.class, "Report.jLabel3.text")); // NOI18N
103

104         jLabel5.setText(org.openide.util.NbBundle.getMessage(ReportDialog.class, "Report.jLabel5.text")); // NOI18N
105

106         jLabel6.setForeground(new java.awt.Color JavaDoc(0, 0, 255));
107         jLabel6.setText(org.openide.util.NbBundle.getMessage(ReportDialog.class, "Report.jLabel6.text")); // NOI18N
108

109         jLabel7.setText(org.openide.util.NbBundle.getMessage(ReportDialog.class, "Report.jLabel7.text")); // NOI18N
110

111         componentBox.setModel(new DefaultComboBoxModel JavaDoc(components));
112         componentBox.addItemListener(new java.awt.event.ItemListener JavaDoc() {
113             public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
114                 itemListener(evt);
115             }
116         });
117
118         jLabel8.setText(org.openide.util.NbBundle.getMessage(ReportDialog.class, "Report.jLabel8.text")); // NOI18N
119

120         jLabel9.setText(org.openide.util.NbBundle.getMessage(ReportDialog.class, "ReportDialog.jLabel9.text")); // NOI18N
121

122         jTextField1.setText(Sender.getActivIssueMessage());
123
124         javax.swing.GroupLayout JavaDoc layout = new javax.swing.GroupLayout JavaDoc(getContentPane());
125         getContentPane().setLayout(layout);
126         layout.setHorizontalGroup(
127             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
128             .addGroup(layout.createSequentialGroup()
129                 .addContainerGap()
130                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
131                     .addComponent(jLabel3)
132                     .addGroup(layout.createSequentialGroup()
133                         .addComponent(jLabel5)
134                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
135                         .addComponent(jLabel6))
136                     .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
137                         .addComponent(jLabel1)
138                         .addGap(43, 43, 43)
139                         .addComponent(loginField, javax.swing.GroupLayout.DEFAULT_SIZE, 290, Short.MAX_VALUE))
140                     .addComponent(jSeparator2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 371, Short.MAX_VALUE)
141                     .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
142                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
143                             .addComponent(jLabel8)
144                             .addComponent(jLabel7))
145                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
146                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
147                             .addComponent(subComponentBox, 0, 263, Short.MAX_VALUE)
148                             .addComponent(componentBox, 0, 263, Short.MAX_VALUE)))
149                     .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 371, Short.MAX_VALUE)
150                     .addGroup(layout.createSequentialGroup()
151                         .addComponent(jLabel9)
152                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
153                         .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 298, Short.MAX_VALUE))
154                     .addComponent(jLabel4)
155                     .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
156                         .addComponent(submitButton)
157                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
158                         .addComponent(cancelButton))
159                     .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 371, Short.MAX_VALUE))
160                 .addContainerGap())
161         );
162         layout.setVerticalGroup(
163             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
164             .addGroup(layout.createSequentialGroup()
165                 .addContainerGap()
166                 .addComponent(jLabel3)
167                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
168                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
169                     .addComponent(jLabel5)
170                     .addComponent(jLabel6))
171                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
172                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
173                     .addComponent(jLabel1)
174                     .addComponent(loginField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
175                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
176                 .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
177                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
178                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
179                     .addComponent(jLabel7)
180                     .addComponent(componentBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
181                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
182                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
183                     .addComponent(jLabel8)
184                     .addComponent(subComponentBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
185                 .addGap(11, 11, 11)
186                 .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
187                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
188                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
189                     .addComponent(jLabel9)
190                     .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
191                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
192                 .addComponent(jLabel4)
193                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
194                 .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 236, javax.swing.GroupLayout.PREFERRED_SIZE)
195                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
196                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
197                     .addComponent(cancelButton)
198                     .addComponent(submitButton))
199                 .addContainerGap())
200         );
201
202         loginField.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ReportDialog.class, "Report.labelField.AccessibleContext.accessibleName")); // NOI18N
203
loginField.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ReportDialog.class, "Report.labelField.AccessibleContext.accessibleDescription")); // NOI18N
204
jLabel4.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ReportDialog.class, "Report.jLabel4.AccessibleContext.accessibleName")); // NOI18N
205

206         getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ReportDialog.class, "AD_Report_Dialog")); // NOI18N
207

208         pack();
209     }// </editor-fold>//GEN-END:initComponents
210

211 private void cancelButtonPressed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_cancelButtonPressed
212
setVisible(false);
213 }//GEN-LAST:event_cancelButtonPressed
214

215 private void reportListener(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_reportListener
216
String JavaDoc login = loginField.getText();
217 // String passwd = new String(passwdField.getPassword());
218
if (login.length()!=0){
219 // if ((login.length()!=0)&&(passwd.length()!=0)){
220
exSettings.setUserName(login);
221 // if (rememberBox.isSelected())exSettings.setPassword(passwd);
222
// else exSettings.setPassword(null);
223
submit(login, null);
224     }else{
225         DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(org.openide.util.NbBundle.getMessage(ReportDialog.class, "set_passwd"), // NOI18N
226
NotifyDescriptor.INFORMATION_MESSAGE));
227     }
228 }//GEN-LAST:event_reportListener
229

230 private void itemListener(java.awt.event.ItemEvent JavaDoc evt) {//GEN-FIRST:event_itemListener
231
if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED){
232         updateSubComponents();
233     }
234 }//GEN-LAST:event_itemListener
235

236 private void updateSubComponents(){
237     Object JavaDoc object = componentBox.getSelectedItem();
238     if (object instanceof String JavaDoc){
239         String JavaDoc[] subComponents = ExceptionsRepos.getInstance().getSubcomponents((String JavaDoc)object);
240         subComponentBox.setModel(new DefaultComboBoxModel JavaDoc(subComponents));
241     }
242 }
243
244
245
246 private void submit(String JavaDoc userName, String JavaDoc passwd){
247     Object JavaDoc com = componentBox.getSelectedItem();
248     String JavaDoc component=null, subComponent=null;
249     if (com instanceof String JavaDoc) component = (String JavaDoc) com;
250     Object JavaDoc subCom = subComponentBox.getSelectedItem();
251     if (subCom instanceof String JavaDoc) subComponent = (String JavaDoc) subCom;
252     if (component==null) component = new String JavaDoc();
253     if (subComponent==null) subComponent = new String JavaDoc();
254     Sender.setND(component, subComponent, ""/*assignToBox.getText()*/, /*summaryBox.getText()*/"", commentArea.getText());
255     Sender.send(userName, passwd);
256     setVisible(false);
257 }
258
259
260
261
262 /**
263  * @param args the command line arguments
264  */

265 public static void main(String JavaDoc args[]) {
266     java.awt.EventQueue.invokeLater(new Runnable JavaDoc() {
267         public void run() {
268             new ReportDialog().setVisible(true);
269         }
270     });
271 }
272
273     // Variables declaration - do not modify//GEN-BEGIN:variables
274
private javax.swing.JButton JavaDoc cancelButton;
275     private javax.swing.JTextArea JavaDoc commentArea;
276     private javax.swing.JComboBox JavaDoc componentBox;
277     private javax.swing.JLabel JavaDoc jLabel1;
278     private javax.swing.JLabel JavaDoc jLabel3;
279     private javax.swing.JLabel JavaDoc jLabel4;
280     private javax.swing.JLabel JavaDoc jLabel5;
281     private javax.swing.JLabel JavaDoc jLabel6;
282     private javax.swing.JLabel JavaDoc jLabel7;
283     private javax.swing.JLabel JavaDoc jLabel8;
284     private javax.swing.JLabel JavaDoc jLabel9;
285     private javax.swing.JScrollPane JavaDoc jScrollPane1;
286     private javax.swing.JSeparator JavaDoc jSeparator1;
287     private javax.swing.JSeparator JavaDoc jSeparator2;
288     private javax.swing.JTextField JavaDoc jTextField1;
289     private javax.swing.JTextField JavaDoc loginField;
290     private javax.swing.JComboBox JavaDoc subComponentBox;
291     private javax.swing.JButton JavaDoc submitButton;
292     // End of variables declaration//GEN-END:variables
293

294 }
295
Popular Tags