KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > changelog > wizard > FilterPanel


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 Ralph Krueger.
17  */

18 package org.netbeans.modules.changelog.wizard;
19
20 /**
21  *
22  * @author ralph
23  */

24
25 import org.openide.util.*;
26 import javax.swing.event.*;
27 import javax.swing.*;
28 import org.netbeans.modules.changelog.*;
29
30
31 public class FilterPanel extends javax.swing.JPanel JavaDoc {
32
33     /** Creates new form FilterPanel */
34     public FilterPanel() {
35         initComponents();
36         putClientProperty ("WizardPanel_contentSelectedIndex", new Integer JavaDoc (0)); // NOI18N
37
String JavaDoc[] comboValues = new String JavaDoc[4];
38         comboValues[0] = NbBundle.getBundle(FilterPanel.class).getString("FilterPanel.Substring");
39         comboValues[2] = NbBundle.getBundle(FilterPanel.class).getString("FilterPanel.AllWords");
40         comboValues[3] = NbBundle.getBundle(FilterPanel.class).getString("FilterPanel.SomeWords");
41         comboValues[1] = NbBundle.getBundle(FilterPanel.class).getString("FilterPanel.RegExp");
42         DefaultComboBoxModel model = new DefaultComboBoxModel(comboValues);
43         comMessage.setModel(model);
44         String JavaDoc[] comboValues2 = new String JavaDoc[2];
45         comboValues2[0] = NbBundle.getBundle(FilterPanel.class).getString("FilterPanel.Substring");
46         comboValues2[1] = NbBundle.getBundle(FilterPanel.class).getString("FilterPanel.RegExp");
47         comFilePattern.setModel(new DefaultComboBoxModel(comboValues2));
48         
49     }
50     
51     /** This method is called from within the constructor to
52      * initialize the form.
53      * WARNING: Do NOT modify this code. The content of this method is
54      * always regenerated by the Form Editor.
55      */

56     private void initComponents() {//GEN-BEGIN:initComponents
57
java.awt.GridBagConstraints JavaDoc gridBagConstraints;
58
59         lblDate = new javax.swing.JLabel JavaDoc();
60         txDate = new javax.swing.JTextField JavaDoc();
61         lblUser = new javax.swing.JLabel JavaDoc();
62         txUser = new javax.swing.JTextField JavaDoc();
63         lblRevision = new javax.swing.JLabel JavaDoc();
64         txRevision = new javax.swing.JTextField JavaDoc();
65         lblMessage = new javax.swing.JLabel JavaDoc();
66         txMessage = new javax.swing.JTextField JavaDoc();
67         comMessage = new javax.swing.JComboBox JavaDoc();
68         lblDateFormat = new javax.swing.JLabel JavaDoc();
69         lRevisionRange = new javax.swing.JLabel JavaDoc();
70         lblFilePattern = new javax.swing.JLabel JavaDoc();
71         txFilePattern = new javax.swing.JTextField JavaDoc();
72         comFilePattern = new javax.swing.JComboBox JavaDoc();
73
74         setLayout(new java.awt.GridBagLayout JavaDoc());
75
76         setMinimumSize(new java.awt.Dimension JavaDoc(400, 200));
77         setPreferredSize(new java.awt.Dimension JavaDoc(600, 300));
78         getAccessibleContext().setAccessibleName(java.util.ResourceBundle.getBundle("org/netbeans/modules/changelog/wizard/Bundle").getString("ACSN_FilterPanel"));
79         getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/changelog/wizard/Bundle").getString("ACSD_FilterPanel"));
80         lblDate.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/changelog/wizard/Bundle").getString("ACS_lblDate_mnc").charAt(0));
81         lblDate.setLabelFor(txDate);
82         lblDate.setText(org.openide.util.NbBundle.getBundle(FilterPanel.class).getString("FilterPanel.lblStatDate.text"));
83         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
84         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
85         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 0);
86         add(lblDate, gridBagConstraints);
87
88         txDate.setColumns(40);
89         txDate.setMinimumSize(new java.awt.Dimension JavaDoc(100, 17));
90         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
91         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
92         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
93         gridBagConstraints.weightx = 0.5;
94         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 6, 0, 0);
95         add(txDate, gridBagConstraints);
96         txDate.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/changelog/wizard/Bundle").getString("ACSD_txDate"));
97
98         lblUser.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/changelog/wizard/Bundle").getString("ACS_lblUser_mnc").charAt(0));
99         lblUser.setLabelFor(txUser);
100         lblUser.setText(org.openide.util.NbBundle.getBundle(FilterPanel.class).getString("FilterPanel.lblUser.text"));
101         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
102         gridBagConstraints.gridx = 0;
103         gridBagConstraints.gridy = 2;
104         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
105         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 12, 0, 0);
106         add(lblUser, gridBagConstraints);
107
108         txUser.setColumns(10);
109         txUser.setMinimumSize(new java.awt.Dimension JavaDoc(100, 17));
110         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
111         gridBagConstraints.gridx = 1;
112         gridBagConstraints.gridy = 2;
113         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
114         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
115         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 6, 0, 0);
116         add(txUser, gridBagConstraints);
117         txUser.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/changelog/wizard/Bundle").getString("ACSD_txUser"));
118
119         lblRevision.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/changelog/wizard/Bundle").getString("ACS_lblRevision_mnc").charAt(0));
120         lblRevision.setLabelFor(txRevision);
121         lblRevision.setText(org.openide.util.NbBundle.getBundle(FilterPanel.class).getString("FilterPanel.lblBranch.text"));
122         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
123         gridBagConstraints.gridx = 0;
124         gridBagConstraints.gridy = 3;
125         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
126         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 12, 0, 0);
127         add(lblRevision, gridBagConstraints);
128
129         txRevision.setColumns(10);
130         txRevision.setMinimumSize(new java.awt.Dimension JavaDoc(100, 17));
131         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
132         gridBagConstraints.gridx = 1;
133         gridBagConstraints.gridy = 3;
134         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
135         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
136         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 6, 0, 0);
137         add(txRevision, gridBagConstraints);
138         txRevision.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/changelog/wizard/Bundle").getString("ACSD_txRevision"));
139
140         lblMessage.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/changelog/wizard/Bundle").getString("ACS_lblMessage_mnc").charAt(0));
141         lblMessage.setLabelFor(txMessage);
142         lblMessage.setText(org.openide.util.NbBundle.getBundle(FilterPanel.class).getString("FilterPanel.lblMessage.text"));
143         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
144         gridBagConstraints.gridx = 0;
145         gridBagConstraints.gridy = 5;
146         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
147         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 12, 6, 0);
148         add(lblMessage, gridBagConstraints);
149
150         txMessage.setColumns(10);
151         txMessage.setMinimumSize(new java.awt.Dimension JavaDoc(100, 17));
152         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
153         gridBagConstraints.gridx = 1;
154         gridBagConstraints.gridy = 5;
155         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
156         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
157         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 6, 6, 0);
158         add(txMessage, gridBagConstraints);
159         txMessage.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/changelog/wizard/Bundle").getString("ACSD_txMessage"));
160
161         comMessage.setPreferredSize(new java.awt.Dimension JavaDoc(250, 27));
162         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
163         gridBagConstraints.gridx = 2;
164         gridBagConstraints.gridy = 5;
165         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
166         gridBagConstraints.weightx = 0.5;
167         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 6, 5, 11);
168         add(comMessage, gridBagConstraints);
169         comMessage.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/changelog/wizard/Bundle").getString("ACSD_comMessage"));
170
171         lblDateFormat.setText(org.openide.util.NbBundle.getBundle(FilterPanel.class).getString("FilterPanel.lblDateFormat.text"));
172         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
173         gridBagConstraints.gridx = 0;
174         gridBagConstraints.gridy = 1;
175         gridBagConstraints.gridwidth = 2;
176         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
177         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 12, 6, 0);
178         add(lblDateFormat, gridBagConstraints);
179
180         lRevisionRange.setText(org.openide.util.NbBundle.getBundle(FilterPanel.class).getString("FilterPanel.lblRevisionRange.text"));
181         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
182         gridBagConstraints.gridx = 0;
183         gridBagConstraints.gridy = 4;
184         gridBagConstraints.gridwidth = 2;
185         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
186         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 12, 6, 0);
187         add(lRevisionRange, gridBagConstraints);
188
189         lblFilePattern.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/changelog/wizard/Bundle").getString("ACS_lblFilePattern_mnc").charAt(0));
190         lblFilePattern.setLabelFor(txFilePattern);
191         lblFilePattern.setText(org.openide.util.NbBundle.getBundle(FilterPanel.class).getString("FilterPanel.lblFilePattern.text"));
192         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
193         gridBagConstraints.gridx = 0;
194         gridBagConstraints.gridy = 6;
195         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
196         gridBagConstraints.weighty = 0.5;
197         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 12, 12, 0);
198         add(lblFilePattern, gridBagConstraints);
199
200         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
201         gridBagConstraints.gridx = 1;
202         gridBagConstraints.gridy = 6;
203         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
204         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
205         gridBagConstraints.weightx = 0.5;
206         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 6, 12, 0);
207         add(txFilePattern, gridBagConstraints);
208         txFilePattern.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/changelog/wizard/Bundle").getString("ACSD_txFilePattern"));
209
210         comFilePattern.setPreferredSize(new java.awt.Dimension JavaDoc(250, 27));
211         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
212         gridBagConstraints.gridx = 2;
213         gridBagConstraints.gridy = 6;
214         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
215         gridBagConstraints.weightx = 0.5;
216         gridBagConstraints.weighty = 0.5;
217         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 6, 11, 11);
218         add(comFilePattern, gridBagConstraints);
219         comFilePattern.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/changelog/wizard/Bundle").getString("ACSD_comFilePattern"));
220
221     }//GEN-END:initComponents
222

223     
224     // Variables declaration - do not modify//GEN-BEGIN:variables
225
private javax.swing.JLabel JavaDoc lblMessage;
226     private javax.swing.JLabel JavaDoc lblDateFormat;
227     private javax.swing.JTextField JavaDoc txUser;
228     private javax.swing.JTextField JavaDoc txDate;
229     private javax.swing.JTextField JavaDoc txMessage;
230     private javax.swing.JTextField JavaDoc txFilePattern;
231     private javax.swing.JLabel JavaDoc lblFilePattern;
232     private javax.swing.JComboBox JavaDoc comMessage;
233     private javax.swing.JLabel JavaDoc lblRevision;
234     private javax.swing.JLabel JavaDoc lblDate;
235     private javax.swing.JLabel JavaDoc lblUser;
236     private javax.swing.JTextField JavaDoc txRevision;
237     private javax.swing.JComboBox JavaDoc comFilePattern;
238     private javax.swing.JLabel JavaDoc lRevisionRange;
239     // End of variables declaration//GEN-END:variables
240

241
242     public static class Panel implements org.openide.WizardDescriptor.Panel {
243
244
245         private FilterPanel panel;
246         private String JavaDoc name;
247
248
249         public Panel (String JavaDoc name) {
250             this.name = name;
251         }
252
253         /** Get the component displayed in this panel.
254          * @return the component
255          */

256         public synchronized java.awt.Component JavaDoc getComponent() {
257             if (this.panel == null) {
258                 this.panel = new FilterPanel();
259                 this.panel.setName (name);
260             }
261             return this.panel;
262         }
263
264         /** Help for this panel.
265          * When the panel is active, this is used as the help for the wizard dialog.
266          * @return the help or <code>null</code> if no help is supplied
267          */

268         public HelpCtx getHelp() {
269             return new HelpCtx(this.getClass());
270         }
271
272         /** Add a listener to changes of the panel's validity.
273          * @param l the listener to add
274          * @see #isValid
275          */

276         public void addChangeListener(ChangeListener l) {
277         }
278
279         /** Remove a listener to changes of the panel's validity.
280          * @param l the listener to remove
281          */

282         public void removeChangeListener(ChangeListener l) {
283         }
284
285
286         public boolean isValid() {
287             return true;
288         }
289
290         /** Provides the wizard panel with the opportunity to update the
291          * settings with its current customized state.
292          * Rather than updating its settings with every change in the GUI, it should collect them,
293          * and then only save them when requested to by this method.
294          * Also, the original settings passed to {@link #readSettings} should not be modified (mutated);
295          * rather, the (copy) passed in here should be mutated according to the collected changes.
296          * This method can be called multiple times on one instance of <code>WizardDescriptor.Panel</code>.
297          * @param settings the object representing a settings of the wizard
298          */

299         public void storeSettings(Object JavaDoc settings) {
300             if (settings instanceof ChangeLogProcessor) {
301                 ChangeLogProcessor proces = (ChangeLogProcessor)settings;
302                 FilterPanel p = (FilterPanel) this.getComponent();
303                 if (p.txMessage.getText() != null && p.txMessage.getText().length() > 0) {
304                     proces.setMessageFilter(p.comMessage.getSelectedIndex(), p.txMessage.getText());
305                 }
306                 else {
307                     proces.setMessageFilter(ChangeLogProcessor.MESSAGE_FILTER_SUBSTRING, null);
308                 }
309                 if (p.txFilePattern.getText() != null && p.txFilePattern.getText().length() > 0) {
310                     proces.setFileFilter(p.comFilePattern.getSelectedIndex(), p.txFilePattern.getText());
311                 }
312                 else {
313                     proces.setFileFilter(ChangeLogProcessor.FILE_FILTER_SUBSTRING, null);
314                 }
315
316                 if (p.txUser.getText() != null & p.txUser.getText().length() > 0)
317                     proces.setUser(p.txUser.getText());
318                 else proces.setUser(null);
319
320                 if (p.txRevision.getText() != null & p.txRevision.getText().length() > 0)
321                     proces.setRevisionRange(p.txRevision.getText());
322                 else proces.setRevisionRange(null);
323                 if (p.txDate.getText() != null & p.txDate.getText().length() > 0)
324                     proces.setDateRange(p.txDate.getText());
325                 else proces.setDateRange(null);
326             }
327         }
328
329         /** Provides the wizard panel with the current data--either
330          * the default data or already-modified settings, if the user used the previous and/or next buttons.
331          * This method can be called multiple times on one instance of <code>WizardDescriptor.Panel</code>.
332          * @param settings the object representing wizard panel state, as originally supplied to {@link org.openide.WizardDescriptor#WizardDescriptor(org.openide.WizardDescriptor.Iterator,Object)}
333          * @exception IllegalStateException if the the data provided
334          * by the wizard are not valid.
335          */

336         public void readSettings(Object JavaDoc settings) {
337             if (settings instanceof ChangeLogProcessor) {
338                 ChangeLogProcessor proces = (ChangeLogProcessor)settings;
339                 FilterPanel p = (FilterPanel) this.getComponent();
340                 if (proces.getRevisionRange() != null)
341                     p.txRevision.setText(proces.getRevisionRange());
342                 if (proces.getDateRange() != null)
343                     p.txDate.setText(proces.getDateRange());
344                 if (proces.getUser() != null) {
345                     p.txUser.setText(proces.getUser());
346                 }
347                 if (proces.getMessageFilter() != null) {
348                     p.txMessage.setText(proces.getMessageFilter());
349                     p.comMessage.setSelectedIndex(proces.getMessageFilterType());
350                 }
351                 if (proces.getFileFilter() != null) {
352                     p.txFilePattern.setText(proces.getFileFilter());
353                     p.comFilePattern.setSelectedIndex(proces.getFileFilterType());
354                 }
355             }
356         }
357     }
358
359 }
360
Popular Tags