1 19 20 package org.netbeans.modules.tasklist.bugs.bugzilla; 21 22 import java.awt.BorderLayout ; 23 import java.awt.Color ; 24 import java.awt.Dialog ; 25 import java.awt.Dimension ; 26 import java.awt.FlowLayout ; 27 import java.awt.GridLayout ; 28 import java.awt.event.ActionEvent ; 29 import java.awt.event.ActionListener ; 30 import java.beans.PropertyVetoException ; 31 import java.text.ParseException ; 32 import java.text.SimpleDateFormat ; 33 import java.util.Date ; 34 import java.util.Iterator ; 35 import java.util.Set ; 36 import java.net.URL ; 37 import java.net.MalformedURLException ; 38 39 import javax.swing.DefaultComboBoxModel ; 40 import javax.swing.JPanel ; 41 import javax.swing.JComboBox ; 42 import javax.swing.JButton ; 43 import javax.swing.JLabel ; 44 import javax.swing.JTextField ; 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 67 public class BugzillaQueryPanel extends JPanel implements QueryPanelIF { 68 69 private static final long serialVersionUID = 1; 70 71 72 private JPanel mTopPanel; 73 74 private JPanel mQueryPanel; 75 76 private JLabel mEngineLabel; 77 78 private JComboBox mBugEngines; 79 80 private JTextField mBaseUrlField; 81 82 private JLabel mBaseUrlLabel; 83 84 private JLabel mBaseUrlExampleLabel; 85 86 private JPanel mBaseUrlExamplePanel; 87 88 private JTextField mQueryField; 89 90 private JLabel mQueryLabel; 91 92 private JLabel mQueryExampleLabel; 93 94 private JPanel mQueryExamplePanel; 95 96 private JPanel mButtonPanel; 97 98 private JButton mDoneButton; 99 private JPanel mBaseUrlPanel; 100 private JPanel mQueryStringPanel; 101 102 103 private BugQuery mQuery; 104 105 private boolean mEditing; 106 107 private JComboBox components; 108 private JLabel status; 109 110 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 (); 119 mQueryPanel = new JPanel (); 120 mBaseUrlPanel = new JPanel (); 121 mBaseUrlField = new JTextField (); 122 mBaseUrlLabel = new JLabel (); 123 mBaseUrlExampleLabel = new JLabel (); 124 mBaseUrlExamplePanel = new JPanel (); 125 mQueryStringPanel = new JPanel (); 126 mQueryField = new JTextField (); 127 mQueryLabel = new JLabel (); 128 mQueryExampleLabel = new JLabel (); 129 mQueryExamplePanel = new JPanel (); 130 components = new JComboBox (); 131 status = new JLabel ("Choose server and Enter"); 132 setLayout(new BorderLayout ()); 133 134 135 mBaseUrlLabel.setText(NbBundle.getMessage(BugzillaQueryPanel.class, "BaseUrl_Label")); mBaseUrlField.setPreferredSize(new Dimension (300, 20)); 137 mBaseUrlField.addActionListener(new ActionListener () { 138 public void actionPerformed(ActionEvent e) { 139 URL url = null; 140 try { 141 status.setText("probing..."); 142 url = new URL (mBaseUrlField.getText()); 143 String [] comps = Issuezilla.getComponents(url); 144 DefaultComboBoxModel model = new DefaultComboBoxModel (comps); 145 components.setModel(model); 146 status.setText("Server OK"); 147 mQuery.setBaseUrl(mBaseUrlField.getText()); 148 } catch (MalformedURLException e1) { 149 status.setText("Invalid server URL "); 150 } 151 } 152 }); 153 mBaseUrlExampleLabel.setText(NbBundle.getMessage(BugzillaQueryPanel.class, "BaseUrlExample_Label")); mBaseUrlExampleLabel.setForeground(new Color (153, 153, 153)); 155 156 mTopPanel.setLayout(new BorderLayout ()); 157 mBaseUrlPanel.setLayout(new FlowLayout (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 (FlowLayout.LEFT)); 163 mBaseUrlExamplePanel.add(mBaseUrlExampleLabel); 164 mTopPanel.add(mBaseUrlExamplePanel, BorderLayout.SOUTH); 165 166 167 mQueryLabel.setText(NbBundle.getMessage(BugzillaQueryPanel.class, "Query_Label")); mQueryField.setPreferredSize(new Dimension (400, 20)); 169 mQueryExampleLabel.setText(NbBundle.getMessage(BugzillaQueryPanel.class, "QueryExample_Label")); mQueryExampleLabel.setForeground(new Color (153, 153, 153)); 171 172 mQueryPanel.setLayout(new BorderLayout ()); 173 mQueryStringPanel.setLayout(new FlowLayout (FlowLayout.LEFT)); 174 mQueryStringPanel.add(mQueryLabel); 175 mQueryStringPanel.add(mQueryField); 176 177 mQueryExamplePanel.setLayout(new FlowLayout (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 |