KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > tasklist > bugs > bugzilla > SourcePanel


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 package org.netbeans.modules.tasklist.bugs.bugzilla;
21
22 import org.netbeans.modules.tasklist.bugs.BugQuery;
23 import org.netbeans.modules.tasklist.bugs.QueryPanelIF;
24 import org.netbeans.modules.tasklist.bugs.BugEngine;
25 import org.netbeans.modules.tasklist.bugs.ProjectDesc;
26 import org.netbeans.modules.tasklist.bugs.javanet.ProjectList;
27 import org.netbeans.modules.tasklist.bugs.issuezilla.Issuezilla;
28 import org.openide.util.RequestProcessor;
29
30 import javax.swing.*;
31 import java.awt.event.ActionListener JavaDoc;
32 import java.awt.event.ActionEvent JavaDoc;
33 import java.net.URL JavaDoc;
34 import java.net.MalformedURLException JavaDoc;
35
36 /**
37  * Allows to customize IZ and java.net bug database connection.
38  *
39  * @author Petr Kuzel
40  */

41 public class SourcePanel extends javax.swing.JPanel JavaDoc implements QueryPanelIF {
42
43     /**
44      * Creates new form SourcePanel
45      *
46      * @param showServiceField XXX on true allows to enter IZ server on false access java.net
47      */

48     public SourcePanel(boolean showServiceField) {
49         initComponents();
50
51         serviceExampleLabel.setVisible(showServiceField);
52         serviceLabel.setVisible(showServiceField);
53         serviceTextField.setVisible(showServiceField);
54
55         if (showServiceField) {
56             serviceTextField.addActionListener(new ActionListener JavaDoc() {
57                 public void actionPerformed(ActionEvent JavaDoc e) {
58                     URL JavaDoc url = null;
59                     try {
60                         serviceExampleLabel.setText("probing...");
61                         url = new URL JavaDoc(serviceTextField.getText());
62                         String JavaDoc [] comps = Issuezilla.getComponents(url);
63                         DefaultComboBoxModel model = new DefaultComboBoxModel(comps);
64                         componentComboBox.setModel(model);
65                         serviceExampleLabel.setText("Server OK");
66                     } catch (MalformedURLException JavaDoc e1) {
67                         serviceExampleLabel.setText("Invalid server URL!");
68                     }
69                 }
70             });
71         } else {
72             componentComboBox.setEnabled(false);
73             RequestProcessor.getDefault().post(new Runnable JavaDoc() {
74                 public void run() {
75                     ProjectDesc[] projects = ProjectList.listProjects();
76                     DefaultComboBoxModel model = new DefaultComboBoxModel(projects);
77                     componentComboBox.setModel(model);
78                     componentComboBox.setEnabled(true);
79                 }
80             });
81         }
82     }
83
84
85     public BugQuery getQueryOptions(BugQuery inQuery) {
86         if (serviceTextField.isVisible()) {
87             inQuery.setBaseUrl(serviceTextField.getText());
88         } else {
89             inQuery.setBaseUrl("https://" + componentComboBox.getSelectedItem() + ".dev.java.net/issues/");
90         }
91
92         if (componentRadioButton.isSelected()) {
93             inQuery.setQueryString("component=" + componentComboBox.getSelectedItem() + "&issue_status=NEW&issue_status=STARTED&issue_status=REOPENED");
94         } else {
95             inQuery.setQueryString(customTextField.getText());
96         }
97         return inQuery;
98     }
99
100     /** This method is called from within the constructor to
101      * initialize the form.
102      * WARNING: Do NOT modify this code. The content of this method is
103      * always regenerated by the Form Editor.
104      */

105     private void initComponents() {//GEN-BEGIN:initComponents
106
java.awt.GridBagConstraints JavaDoc gridBagConstraints;
107
108         buttonGroup1 = new javax.swing.ButtonGroup JavaDoc();
109         serviceLabel = new javax.swing.JLabel JavaDoc();
110         serviceTextField = new javax.swing.JTextField JavaDoc();
111         serviceExampleLabel = new javax.swing.JLabel JavaDoc();
112         componentRadioButton = new javax.swing.JRadioButton JavaDoc();
113         componentLabel = new javax.swing.JLabel JavaDoc();
114         componentComboBox = new javax.swing.JComboBox JavaDoc();
115         customRadioButton = new javax.swing.JRadioButton JavaDoc();
116         customLabel = new javax.swing.JLabel JavaDoc();
117         customTextField = new javax.swing.JTextField JavaDoc();
118         customExLabel = new javax.swing.JLabel JavaDoc();
119
120         setLayout(new java.awt.GridBagLayout JavaDoc());
121
122         serviceLabel.setText("Service URL");
123         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
124         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
125         add(serviceLabel, gridBagConstraints);
126
127         serviceTextField.setColumns(60);
128         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
129         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
130         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
131         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 6, 0, 0);
132         gridBagConstraints.weightx = 1.0;
133         add(serviceTextField, gridBagConstraints);
134
135         serviceExampleLabel.setText("e.g. http://www.netbeans.org/issues/");
136         serviceExampleLabel.setEnabled(false);
137         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
138         gridBagConstraints.gridx = 1;
139         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
140         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
141         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 6, 0, 0);
142         gridBagConstraints.weightx = 1.0;
143         add(serviceExampleLabel, gridBagConstraints);
144
145         componentRadioButton.setText("Show all opened issues");
146         buttonGroup1.add(componentRadioButton);
147         componentRadioButton.addActionListener(new java.awt.event.ActionListener JavaDoc() {
148             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
149                 componentRadioButtonActionPerformed(evt);
150             }
151         });
152
153         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
154         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
155         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
156         add(componentRadioButton, gridBagConstraints);
157
158         componentLabel.setText("for component");
159         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
160         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
161         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 24, 0, 0);
162         add(componentLabel, gridBagConstraints);
163
164         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
165         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
166         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
167         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 6, 0, 0);
168         gridBagConstraints.weightx = 1.0;
169         add(componentComboBox, gridBagConstraints);
170
171         customRadioButton.setText("Custom query given by URL");
172         buttonGroup1.add(customRadioButton);
173         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
174         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
175         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
176         add(customRadioButton, gridBagConstraints);
177
178         customLabel.setText("parameters");
179         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
180         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 24, 0, 0);
181         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
182         add(customLabel, gridBagConstraints);
183
184         customTextField.setColumns(60);
185         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
186         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
187         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
188         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 6, 0, 0);
189         gridBagConstraints.weightx = 1.0;
190         add(customTextField, gridBagConstraints);
191
192         customExLabel.setText("e.g. component=www&state=NEW");
193         customExLabel.setEnabled(false);
194         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
195         gridBagConstraints.gridx = 1;
196         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
197         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 6, 0, 0);
198         gridBagConstraints.weightx = 1.0;
199         add(customExLabel, gridBagConstraints);
200
201     }//GEN-END:initComponents
202

203     private void componentRadioButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_componentRadioButtonActionPerformed
204
// TODO add your handling code here:
205
}//GEN-LAST:event_componentRadioButtonActionPerformed
206

207     
208     // Variables declaration - do not modify//GEN-BEGIN:variables
209
private javax.swing.ButtonGroup JavaDoc buttonGroup1;
210     private javax.swing.JComboBox JavaDoc componentComboBox;
211     private javax.swing.JLabel JavaDoc componentLabel;
212     private javax.swing.JRadioButton JavaDoc componentRadioButton;
213     private javax.swing.JLabel JavaDoc customExLabel;
214     private javax.swing.JLabel JavaDoc customLabel;
215     private javax.swing.JRadioButton JavaDoc customRadioButton;
216     private javax.swing.JTextField JavaDoc customTextField;
217     private javax.swing.JLabel JavaDoc serviceExampleLabel;
218     private javax.swing.JLabel JavaDoc serviceLabel;
219     private javax.swing.JTextField JavaDoc serviceTextField;
220     // End of variables declaration//GEN-END:variables
221

222 }
223
Popular Tags