1 19 20 package org.netbeans.modules.tasklist.bugs; 21 22 import java.awt.BorderLayout ; 23 import java.awt.FlowLayout ; 24 import java.awt.Dialog ; 25 import java.awt.event.ActionEvent ; 26 import java.awt.event.ActionListener ; 27 import java.beans.PropertyVetoException ; 28 import java.text.ParseException ; 29 import java.text.SimpleDateFormat ; 30 import java.util.Date ; 31 import java.util.Iterator ; 32 import java.util.Set ; 33 34 import javax.swing.*; 35 36 import org.netbeans.modules.tasklist.bugs.BugQuery; 37 import org.netbeans.modules.tasklist.bugs.bugzilla.BugzillaQueryPanel; 38 import org.netbeans.modules.tasklist.bugs.bugzilla.SourcePanel; 39 40 import org.openide.DialogDescriptor; 41 import org.openide.ErrorManager; 42 import org.openide.NotifyDescriptor; 43 import org.openide.explorer.ExplorerManager; 44 import org.openide.explorer.view.BeanTreeView; 45 import org.openide.nodes.Node; 46 import org.openide.util.HelpCtx; 47 import org.openide.util.NbBundle; 48 49 63 public final class EditQueryPanel extends JPanel { 64 65 private static final long serialVersionUID = 1; 66 67 68 private JPanel mTopPanel; 69 70 private JPanel mQueryPanel; 71 72 private JLabel mEngineLabel; 73 74 private JComboBox mBugEngines; 75 76 private JPanel mButtonPanel; 77 78 private JButton mDefaultButton; 79 80 81 private BugQuery mQuery; 82 83 private boolean mEditing; 84 85 86 public EditQueryPanel(BugQuery query, boolean editing) { 87 mEditing = editing; 88 mQuery = query; 89 initComponents(); 90 } 91 92 private void initComponents() { 93 mTopPanel = new JPanel(); 94 mEngineLabel = new JLabel(); 95 mBugEngines = new JComboBox(); 96 mButtonPanel = new JPanel(); 97 mDefaultButton = new JButton(); 98 99 setLayout(new BorderLayout ()); 100 101 mEngineLabel.setText(NbBundle.getMessage(EditQueryPanel.class, "BugEngine_Label")); 103 String [] engines = BugEngines.list(); 105 for (int i= 0; i<engines.length; i++) { 106 mBugEngines.addItem(engines[i]); 107 } 108 109 mTopPanel.setLayout(new FlowLayout (FlowLayout.LEFT, 6, 6)); 110 mTopPanel.add(mEngineLabel); 111 mTopPanel.add(mBugEngines); 112 113 final JPanel hotSwap = new JPanel(); 115 mQueryPanel = getQueryPanel((String )mBugEngines.getSelectedItem()); 116 hotSwap.add(mQueryPanel); 117 mBugEngines.addActionListener(new ActionListener () { 118 public void actionPerformed(ActionEvent e) { 119 hotSwap.removeAll(); 120 mQueryPanel = getQueryPanel((String )mBugEngines.getSelectedItem()); 121 hotSwap.add(mQueryPanel); 122 hotSwap.revalidate(); 123 EditQueryPanel.this.repaint(); 124 } 125 }); 126 127 mDefaultButton.setText(NbBundle.getMessage(EditQueryPanel.class, "DefaultButton_Text")); 129 mDefaultButton.addActionListener(new java.awt.event.ActionListener () { 130 public void actionPerformed(java.awt.event.ActionEvent evt) { 131 defaultButtonActionPerformed(evt); 132 } 133 }); 134 mDefaultButton.setEnabled(false); 135 mDefaultButton.setToolTipText("Not yet implemented"); 136 mButtonPanel.setLayout(new FlowLayout (FlowLayout.RIGHT, 6, 6)); 137 139 add(mTopPanel, BorderLayout.NORTH); 140 hotSwap.setBorder(BorderFactory.createEmptyBorder(0,6,0,6)); 141 add(hotSwap, BorderLayout.CENTER); 142 add(mButtonPanel, BorderLayout.SOUTH); 143 } 144 145 149 public JPanel getQueryPanel(String engineName) { 150 JPanel ret = null; 152 BugEngine engine = BugEngines.get(getBugEngine()); 153 ret = (JPanel) engine.getQueryCustomizer(getQuery(), false); 154 assert ret instanceof QueryPanelIF : "Engine " + engine + " returned " + ret; 155 return ret; 156 } 157 158 private void defaultButtonActionPerformed(java.awt.event.ActionEvent evt) { 159 mQuery.setBugEngine(((String )mBugEngines.getSelectedItem())); 161 mQuery = ((QueryPanelIF)mQueryPanel).getQueryOptions(mQuery); 162 163 165 } 166 167 public BugQuery getQuery() { 168 mQuery.setBugEngine(((String )mBugEngines.getSelectedItem())); 169 if (mQueryPanel != null) { 170 mQuery = ((QueryPanelIF)mQueryPanel).getQueryOptions(mQuery); 171 } 172 return mQuery; 173 } 174 175 public String getBugEngine() { 176 return (String )mBugEngines.getSelectedItem(); 177 } 178 179 public String getQueryString() { 180 return ((QueryPanelIF)mQueryPanel).getQueryOptions(mQuery).getQueryString(); 181 } 182 183 public String getBaseUrl() { 184 return ((QueryPanelIF)mQueryPanel).getQueryOptions(mQuery).getBaseUrl(); 185 } 186 } 187 | Popular Tags |