1 19 20 21 package org.netbeans.modules.exceptions; 22 23 import java.awt.event.ActionEvent ; 24 import java.awt.event.ActionListener ; 25 import javax.swing.DefaultComboBoxModel ; 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 35 public class ReportDialog extends javax.swing.JFrame { 36 String [] components = ExceptionsRepos.getInstance().getComponents(); 37 ExceptionsSettings exSettings = new ExceptionsSettings(); 38 39 40 public ReportDialog() { 41 initComponents(); 42 updateSubComponents(); 43 } 44 45 50 private void initComponents() { 52 53 cancelButton = new javax.swing.JButton (); 54 submitButton = new javax.swing.JButton (); 55 jScrollPane1 = new javax.swing.JScrollPane (); 56 commentArea = new javax.swing.JTextArea (); 57 jLabel1 = new javax.swing.JLabel (); 58 loginField = new javax.swing.JTextField (); 59 jLabel4 = new javax.swing.JLabel (); 60 jLabel3 = new javax.swing.JLabel (); 61 jLabel5 = new javax.swing.JLabel (); 62 jLabel6 = new javax.swing.JLabel (); 63 jLabel7 = new javax.swing.JLabel (); 64 componentBox = new javax.swing.JComboBox (); 65 jLabel8 = new javax.swing.JLabel (); 66 subComponentBox = new javax.swing.JComboBox (); 67 jSeparator1 = new javax.swing.JSeparator (); 68 jSeparator2 = new javax.swing.JSeparator (); 69 jLabel9 = new javax.swing.JLabel (); 70 jTextField1 = new javax.swing.JTextField (); 71 72 setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); 73 setTitle(org.openide.util.NbBundle.getMessage(ReportDialog.class, "ReportDialog_title")); 75 org.openide.awt.Mnemonics.setLocalizedText(cancelButton, org.openide.util.NbBundle.getMessage(ReportDialog.class, "Report.cancelButton.text")); cancelButton.addActionListener(new java.awt.event.ActionListener () { 77 public void actionPerformed(java.awt.event.ActionEvent evt) { 78 cancelButtonPressed(evt); 79 } 80 }); 81 82 org.openide.awt.Mnemonics.setLocalizedText(submitButton, org.openide.util.NbBundle.getMessage(ReportDialog.class, "Report.submitButton.text")); submitButton.addActionListener(new java.awt.event.ActionListener () { 84 public void actionPerformed(java.awt.event.ActionEvent 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")); commentArea.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ReportDialog.class, "AD_CommentBox")); commentArea.getAccessibleContext().setAccessibleParent(this); 95 96 jLabel1.setText(org.openide.util.NbBundle.getMessage(ReportDialog.class, "Report.jLabel1.text")); 98 loginField.setText(exSettings.getUserName()); 99 100 jLabel4.setText(org.openide.util.NbBundle.getMessage(ReportDialog.class, "Report.jLabel4.text")); 102 jLabel3.setText(org.openide.util.NbBundle.getMessage(ReportDialog.class, "Report.jLabel3.text")); 104 jLabel5.setText(org.openide.util.NbBundle.getMessage(ReportDialog.class, "Report.jLabel5.text")); 106 jLabel6.setForeground(new java.awt.Color (0, 0, 255)); 107 jLabel6.setText(org.openide.util.NbBundle.getMessage(ReportDialog.class, "Report.jLabel6.text")); 109 jLabel7.setText(org.openide.util.NbBundle.getMessage(ReportDialog.class, "Report.jLabel7.text")); 111 componentBox.setModel(new DefaultComboBoxModel (components)); 112 componentBox.addItemListener(new java.awt.event.ItemListener () { 113 public void itemStateChanged(java.awt.event.ItemEvent evt) { 114 itemListener(evt); 115 } 116 }); 117 118 jLabel8.setText(org.openide.util.NbBundle.getMessage(ReportDialog.class, "Report.jLabel8.text")); 120 jLabel9.setText(org.openide.util.NbBundle.getMessage(ReportDialog.class, "ReportDialog.jLabel9.text")); 122 jTextField1.setText(Sender.getActivIssueMessage()); 123 124 javax.swing.GroupLayout layout = new javax.swing.GroupLayout (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")); loginField.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ReportDialog.class, "Report.labelField.AccessibleContext.accessibleDescription")); jLabel4.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ReportDialog.class, "Report.jLabel4.AccessibleContext.accessibleName")); 206 getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ReportDialog.class, "AD_Report_Dialog")); 208 pack(); 209 } 211 private void cancelButtonPressed(java.awt.event.ActionEvent evt) { setVisible(false); 213 } 215 private void reportListener(java.awt.event.ActionEvent evt) { String login = loginField.getText(); 217 if (login.length()!=0){ 219 exSettings.setUserName(login); 221 submit(login, null); 224 }else{ 225 DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(org.openide.util.NbBundle.getMessage(ReportDialog.class, "set_passwd"), NotifyDescriptor.INFORMATION_MESSAGE)); 227 } 228 } 230 private void itemListener(java.awt.event.ItemEvent evt) { if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED){ 232 updateSubComponents(); 233 } 234 } 236 private void updateSubComponents(){ 237 Object object = componentBox.getSelectedItem(); 238 if (object instanceof String ){ 239 String [] subComponents = ExceptionsRepos.getInstance().getSubcomponents((String )object); 240 subComponentBox.setModel(new DefaultComboBoxModel (subComponents)); 241 } 242 } 243 244 245 246 private void submit(String userName, String passwd){ 247 Object com = componentBox.getSelectedItem(); 248 String component=null, subComponent=null; 249 if (com instanceof String ) component = (String ) com; 250 Object subCom = subComponentBox.getSelectedItem(); 251 if (subCom instanceof String ) subComponent = (String ) subCom; 252 if (component==null) component = new String (); 253 if (subComponent==null) subComponent = new String (); 254 Sender.setND(component, subComponent, "", "", commentArea.getText()); 255 Sender.send(userName, passwd); 256 setVisible(false); 257 } 258 259 260 261 262 265 public static void main(String args[]) { 266 java.awt.EventQueue.invokeLater(new Runnable () { 267 public void run() { 268 new ReportDialog().setVisible(true); 269 } 270 }); 271 } 272 273 private javax.swing.JButton cancelButton; 275 private javax.swing.JTextArea commentArea; 276 private javax.swing.JComboBox componentBox; 277 private javax.swing.JLabel jLabel1; 278 private javax.swing.JLabel jLabel3; 279 private javax.swing.JLabel jLabel4; 280 private javax.swing.JLabel jLabel5; 281 private javax.swing.JLabel jLabel6; 282 private javax.swing.JLabel jLabel7; 283 private javax.swing.JLabel jLabel8; 284 private javax.swing.JLabel jLabel9; 285 private javax.swing.JScrollPane jScrollPane1; 286 private javax.swing.JSeparator jSeparator1; 287 private javax.swing.JSeparator jSeparator2; 288 private javax.swing.JTextField jTextField1; 289 private javax.swing.JTextField loginField; 290 private javax.swing.JComboBox subComponentBox; 291 private javax.swing.JButton submitButton; 292 294 } 295 | Popular Tags |