1 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 ; 32 import java.awt.event.ActionEvent ; 33 import java.net.URL ; 34 import java.net.MalformedURLException ; 35 36 41 public class SourcePanel extends javax.swing.JPanel implements QueryPanelIF { 42 43 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 () { 57 public void actionPerformed(ActionEvent e) { 58 URL url = null; 59 try { 60 serviceExampleLabel.setText("probing..."); 61 url = new URL (serviceTextField.getText()); 62 String [] comps = Issuezilla.getComponents(url); 63 DefaultComboBoxModel model = new DefaultComboBoxModel(comps); 64 componentComboBox.setModel(model); 65 serviceExampleLabel.setText("Server OK"); 66 } catch (MalformedURLException e1) { 67 serviceExampleLabel.setText("Invalid server URL!"); 68 } 69 } 70 }); 71 } else { 72 componentComboBox.setEnabled(false); 73 RequestProcessor.getDefault().post(new Runnable () { 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 105 private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; 107 108 buttonGroup1 = new javax.swing.ButtonGroup (); 109 serviceLabel = new javax.swing.JLabel (); 110 serviceTextField = new javax.swing.JTextField (); 111 serviceExampleLabel = new javax.swing.JLabel (); 112 componentRadioButton = new javax.swing.JRadioButton (); 113 componentLabel = new javax.swing.JLabel (); 114 componentComboBox = new javax.swing.JComboBox (); 115 customRadioButton = new javax.swing.JRadioButton (); 116 customLabel = new javax.swing.JLabel (); 117 customTextField = new javax.swing.JTextField (); 118 customExLabel = new javax.swing.JLabel (); 119 120 setLayout(new java.awt.GridBagLayout ()); 121 122 serviceLabel.setText("Service URL"); 123 gridBagConstraints = new java.awt.GridBagConstraints (); 124 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 125 add(serviceLabel, gridBagConstraints); 126 127 serviceTextField.setColumns(60); 128 gridBagConstraints = new java.awt.GridBagConstraints (); 129 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 130 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 131 gridBagConstraints.insets = new java.awt.Insets (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 (); 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 (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 () { 148 public void actionPerformed(java.awt.event.ActionEvent evt) { 149 componentRadioButtonActionPerformed(evt); 150 } 151 }); 152 153 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (); 160 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 161 gridBagConstraints.insets = new java.awt.Insets (6, 24, 0, 0); 162 add(componentLabel, gridBagConstraints); 163 164 gridBagConstraints = new java.awt.GridBagConstraints (); 165 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 166 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 167 gridBagConstraints.insets = new java.awt.Insets (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 (); 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 (); 180 gridBagConstraints.insets = new java.awt.Insets (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 (); 186 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 187 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 188 gridBagConstraints.insets = new java.awt.Insets (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 (); 195 gridBagConstraints.gridx = 1; 196 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 197 gridBagConstraints.insets = new java.awt.Insets (6, 6, 0, 0); 198 gridBagConstraints.weightx = 1.0; 199 add(customExLabel, gridBagConstraints); 200 201 } 203 private void componentRadioButtonActionPerformed(java.awt.event.ActionEvent evt) { } 207 208 private javax.swing.ButtonGroup buttonGroup1; 210 private javax.swing.JComboBox componentComboBox; 211 private javax.swing.JLabel componentLabel; 212 private javax.swing.JRadioButton componentRadioButton; 213 private javax.swing.JLabel customExLabel; 214 private javax.swing.JLabel customLabel; 215 private javax.swing.JRadioButton customRadioButton; 216 private javax.swing.JTextField customTextField; 217 private javax.swing.JLabel serviceExampleLabel; 218 private javax.swing.JLabel serviceLabel; 219 private javax.swing.JTextField serviceTextField; 220 222 } 223 | Popular Tags |