KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.awt.BorderLayout JavaDoc;
23 import java.awt.Color JavaDoc;
24 import java.awt.Dialog JavaDoc;
25 import java.awt.Dimension JavaDoc;
26 import java.awt.FlowLayout JavaDoc;
27 import java.awt.GridLayout JavaDoc;
28 import java.awt.event.ActionEvent JavaDoc;
29 import java.awt.event.ActionListener JavaDoc;
30 import java.beans.PropertyVetoException JavaDoc;
31 import java.text.ParseException JavaDoc;
32 import java.text.SimpleDateFormat JavaDoc;
33 import java.util.Date JavaDoc;
34 import java.util.Iterator JavaDoc;
35 import java.util.Set JavaDoc;
36 import java.net.URL JavaDoc;
37 import java.net.MalformedURLException JavaDoc;
38
39 import javax.swing.DefaultComboBoxModel JavaDoc;
40 import javax.swing.JPanel JavaDoc;
41 import javax.swing.JComboBox JavaDoc;
42 import javax.swing.JButton JavaDoc;
43 import javax.swing.JLabel JavaDoc;
44 import javax.swing.JTextField JavaDoc;
45
46 import org.netbeans.modules.tasklist.bugs.BugQuery;
47 import org.netbeans.modules.tasklist.bugs.QueryPanelIF;
48 import org.netbeans.modules.tasklist.bugs.issuezilla.IZBugEngine;
49 import org.netbeans.modules.tasklist.bugs.issuezilla.Issuezilla;
50
51 import org.openide.DialogDescriptor;
52 import org.openide.ErrorManager;
53 import org.openide.NotifyDescriptor;
54 import org.openide.explorer.ExplorerManager;
55 import org.openide.explorer.view.BeanTreeView;
56 import org.openide.nodes.Node;
57 import org.openide.util.HelpCtx;
58 import org.openide.util.NbBundle;
59
60 /**
61  * This panel has the specific query parameters for a bugzilla query.
62  *
63  * @todo add all the swing components to be just like the query.cgi page
64  *
65  * @author serff
66  */

67 public class BugzillaQueryPanel extends JPanel JavaDoc implements QueryPanelIF {
68
69     private static final long serialVersionUID = 1;
70
71     /** A panel at the top to hold the combobox and label */
72     private JPanel JavaDoc mTopPanel;
73     /** a panel that holds the query part */
74     private JPanel JavaDoc mQueryPanel;
75     /** A label for the ComboBox */
76     private JLabel JavaDoc mEngineLabel;
77     /** a combox box for the bug engine choices */
78     private JComboBox JavaDoc mBugEngines;
79     /** a text field for the base url */
80     private JTextField JavaDoc mBaseUrlField;
81     /** a label for the base url field */
82     private JLabel JavaDoc mBaseUrlLabel;
83     /** a label for an example of a base url */
84     private JLabel JavaDoc mBaseUrlExampleLabel;
85     /** a panel to hold the label */
86     private JPanel JavaDoc mBaseUrlExamplePanel;
87     /** a text field for the query sting for now */
88     private JTextField JavaDoc mQueryField;
89     /** A label for the query field */
90     private JLabel JavaDoc mQueryLabel;
91     /** a label for an example of a query string */
92     private JLabel JavaDoc mQueryExampleLabel;
93     /** a panel to hold the label */
94     private JPanel JavaDoc mQueryExamplePanel;
95     /** A button panel */
96     private JPanel JavaDoc mButtonPanel;
97     /** A done button */
98     private JButton JavaDoc mDoneButton;
99     private JPanel JavaDoc mBaseUrlPanel;
100     private JPanel JavaDoc mQueryStringPanel;
101     
102     /** an instance of the query */
103     private BugQuery mQuery;
104     /** a flag to tell if we are editing this query or not */
105     private boolean mEditing;
106
107     private JComboBox JavaDoc components;
108     private JLabel JavaDoc status;
109
110     /** Creates a new instance of BugzillaQueryPanel */
111     public BugzillaQueryPanel(BugQuery query, boolean editing) {
112         mEditing = editing;
113         mQuery = query;
114         initComponents();
115     }
116     
117     private void initComponents() {
118         mTopPanel = new JPanel JavaDoc();
119         mQueryPanel = new JPanel JavaDoc();
120         mBaseUrlPanel = new JPanel JavaDoc();
121         mBaseUrlField = new JTextField JavaDoc();
122         mBaseUrlLabel = new JLabel JavaDoc();
123         mBaseUrlExampleLabel = new JLabel JavaDoc();
124         mBaseUrlExamplePanel = new JPanel JavaDoc();
125         mQueryStringPanel = new JPanel JavaDoc();
126         mQueryField = new JTextField JavaDoc();
127         mQueryLabel = new JLabel JavaDoc();
128         mQueryExampleLabel = new JLabel JavaDoc();
129         mQueryExamplePanel = new JPanel JavaDoc();
130         components = new JComboBox JavaDoc();
131         status = new JLabel JavaDoc("Choose server and Enter");
132         setLayout(new BorderLayout JavaDoc());
133
134
135         mBaseUrlLabel.setText(NbBundle.getMessage(BugzillaQueryPanel.class, "BaseUrl_Label")); // NOI18N
136
mBaseUrlField.setPreferredSize(new Dimension JavaDoc(300, 20));
137         mBaseUrlField.addActionListener(new ActionListener JavaDoc() {
138             public void actionPerformed(ActionEvent JavaDoc e) {
139                 URL JavaDoc url = null;
140                 try {
141                     status.setText("probing...");
142                     url = new URL JavaDoc(mBaseUrlField.getText());
143                     String JavaDoc [] comps = Issuezilla.getComponents(url);
144                     DefaultComboBoxModel JavaDoc model = new DefaultComboBoxModel JavaDoc(comps);
145                     components.setModel(model);
146                     status.setText("Server OK");
147                     mQuery.setBaseUrl(mBaseUrlField.getText());
148                 } catch (MalformedURLException JavaDoc e1) {
149                     status.setText("Invalid server URL ");
150                 }
151             }
152         });
153         mBaseUrlExampleLabel.setText(NbBundle.getMessage(BugzillaQueryPanel.class, "BaseUrlExample_Label")); // NOI18N
154
mBaseUrlExampleLabel.setForeground(new Color JavaDoc(153, 153, 153));
155         
156         mTopPanel.setLayout(new BorderLayout JavaDoc());
157         mBaseUrlPanel.setLayout(new FlowLayout JavaDoc(FlowLayout.LEFT));
158         mBaseUrlPanel.add(mBaseUrlLabel);
159         mBaseUrlPanel.add(mBaseUrlField);
160         mBaseUrlPanel.add(status);
161         mTopPanel.add(mBaseUrlPanel, BorderLayout.CENTER);
162         mBaseUrlExamplePanel.setLayout(new FlowLayout JavaDoc(FlowLayout.LEFT));
163         mBaseUrlExamplePanel.add(mBaseUrlExampleLabel);
164         mTopPanel.add(mBaseUrlExamplePanel, BorderLayout.SOUTH);
165         
166         
167         mQueryLabel.setText(NbBundle.getMessage(BugzillaQueryPanel.class, "Query_Label")); // NOI18N
168
mQueryField.setPreferredSize(new Dimension JavaDoc(400, 20));
169         mQueryExampleLabel.setText(NbBundle.getMessage(BugzillaQueryPanel.class, "QueryExample_Label")); // NOI18N
170
mQueryExampleLabel.setForeground(new Color JavaDoc(153, 153, 153));
171         
172         mQueryPanel.setLayout(new BorderLayout JavaDoc());
173         mQueryStringPanel.setLayout(new FlowLayout JavaDoc(FlowLayout.LEFT));
174         mQueryStringPanel.add(mQueryLabel);
175         mQueryStringPanel.add(mQueryField);
176
177         mQueryExamplePanel.setLayout(new FlowLayout JavaDoc(FlowLayout.LEFT));
178         mQueryExamplePanel.add(mQueryExampleLabel);
179
180         mQueryPanel.add(mQueryStringPanel, BorderLayout.CENTER);
181         mQueryPanel.add(mQueryExamplePanel, BorderLayout.SOUTH);
182         
183         add(mTopPanel, BorderLayout.NORTH);
184         add(mQueryPanel, BorderLayout.SOUTH);
185     }
186     
187     public BugQuery getQueryOptions(BugQuery inQuery) {
188         inQuery.setBaseUrl(mBaseUrlField.getText());
189         inQuery.setQueryString(mQueryField.getText());
190         return inQuery;
191     }
192     
193 }
194
Popular Tags