KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > versioning > system > cvss > ui > history > SearchCriteriaPanel


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.versioning.system.cvss.ui.history;
21
22 import org.netbeans.lib.cvsclient.CVSRoot;
23 import org.netbeans.lib.cvsclient.admin.AdminHandler;
24 import org.netbeans.modules.versioning.system.cvss.util.Utils;
25 import org.netbeans.modules.versioning.system.cvss.CvsVersioningSystem;
26 import org.netbeans.modules.versioning.system.cvss.ui.selectors.BranchSelector;
27
28 import javax.swing.*;
29 import java.io.IOException JavaDoc;
30 import java.io.File JavaDoc;
31
32 /**
33  * Packages search criteria in Search History panel.
34  *
35  * @author Maros Sandor
36  */

37 class SearchCriteriaPanel extends javax.swing.JPanel JavaDoc {
38     
39     private final File JavaDoc[] roots;
40
41     /** Creates new form SearchCriteriaPanel */
42     public SearchCriteriaPanel(File JavaDoc [] roots) {
43         this.roots = roots;
44         initComponents();
45     }
46
47     public String JavaDoc getFrom() {
48         String JavaDoc s = tfFrom.getText().trim();
49         return s.length() > 0 ? s : null;
50     }
51
52     public String JavaDoc getTo() {
53         String JavaDoc s = tfTo.getText().trim();
54         return s.length() > 0 ? s : null;
55     }
56     
57     public String JavaDoc getCommitMessage() {
58         String JavaDoc s = tfCommitMessage.getText().trim();
59         return s.length() > 0 ? s : null;
60     }
61
62     public String JavaDoc getUsername() {
63         String JavaDoc s = tfUsername.getText().trim();
64         return s.length() > 0 ? s : null;
65     }
66
67     public void setFrom(String JavaDoc from) {
68         if (from == null) from = ""; // NOI18N
69
tfFrom.setText(from);
70     }
71
72     public void setTo(String JavaDoc to) {
73         if (to == null) to = ""; // NOI18N
74
tfTo.setText(to);
75     }
76     
77     public void setCommitMessage(String JavaDoc message) {
78         if (message == null) message = ""; // NOI18N
79
tfCommitMessage.setText(message);
80     }
81
82     public void setUsername(String JavaDoc username) {
83         if (username == null) username = ""; // NOI18N
84
tfUsername.setText(username);
85     }
86     
87     public void addNotify() {
88         super.addNotify();
89         SwingUtilities.invokeLater(new Runnable JavaDoc() {
90             public void run() {
91                 tfCommitMessage.requestFocusInWindow();
92             }
93         });
94     }
95
96     /** This method is called from within the constructor to
97      * initialize the form.
98      * WARNING: Do NOT modify this code. The content of this method is
99      * always regenerated by the Form Editor.
100      */

101     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
102
private void initComponents() {
103         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
104
105         jLabel1 = new javax.swing.JLabel JavaDoc();
106         tfCommitMessage = new javax.swing.JTextField JavaDoc();
107         jLabel2 = new javax.swing.JLabel JavaDoc();
108         tfUsername = new javax.swing.JTextField JavaDoc();
109         jLabel3 = new javax.swing.JLabel JavaDoc();
110         tfFrom = new javax.swing.JTextField JavaDoc();
111         jLabel5 = new javax.swing.JLabel JavaDoc();
112         bBrowseFrom = new javax.swing.JButton JavaDoc();
113         jLabel4 = new javax.swing.JLabel JavaDoc();
114         tfTo = new javax.swing.JTextField JavaDoc();
115         jLabel6 = new javax.swing.JLabel JavaDoc();
116         bBrowseTo = new javax.swing.JButton JavaDoc();
117
118         setLayout(new java.awt.GridBagLayout JavaDoc());
119
120         setBorder(javax.swing.BorderFactory.createEmptyBorder(8, 12, 0, 11));
121         jLabel1.setLabelFor(tfCommitMessage);
122         org.openide.awt.Mnemonics.setLocalizedText(jLabel1, java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/history/Bundle").getString("CTL_UseCommitMessage"));
123         jLabel1.setToolTipText(java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/history/Bundle").getString("TT_CommitMessage"));
124         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
125         gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
126         add(jLabel1, gridBagConstraints);
127
128         tfCommitMessage.setColumns(20);
129         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
130         gridBagConstraints.gridx = 1;
131         gridBagConstraints.gridy = 0;
132         gridBagConstraints.gridwidth = 2;
133         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
134         gridBagConstraints.weightx = 1.0;
135         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 4, 0, 0);
136         add(tfCommitMessage, gridBagConstraints);
137
138         jLabel2.setLabelFor(tfUsername);
139         org.openide.awt.Mnemonics.setLocalizedText(jLabel2, java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/history/Bundle").getString("CTL_UseUsername"));
140         jLabel2.setToolTipText(java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/history/Bundle").getString("TT_Username"));
141         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
142         gridBagConstraints.gridy = 1;
143         gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
144         add(jLabel2, gridBagConstraints);
145
146         tfUsername.setColumns(20);
147         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
148         gridBagConstraints.gridx = 1;
149         gridBagConstraints.gridy = 1;
150         gridBagConstraints.gridwidth = 2;
151         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
152         gridBagConstraints.weightx = 1.0;
153         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 4, 0, 0);
154         add(tfUsername, gridBagConstraints);
155
156         jLabel3.setLabelFor(tfFrom);
157         org.openide.awt.Mnemonics.setLocalizedText(jLabel3, java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/history/Bundle").getString("CTL_UseFrom"));
158         jLabel3.setToolTipText(java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/history/Bundle").getString("TT_From"));
159         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
160         gridBagConstraints.gridy = 2;
161         gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
162         add(jLabel3, gridBagConstraints);
163
164         tfFrom.setColumns(20);
165         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
166         gridBagConstraints.gridx = 1;
167         gridBagConstraints.gridy = 2;
168         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
169         gridBagConstraints.weightx = 1.0;
170         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 4, 0, 4);
171         add(tfFrom, gridBagConstraints);
172
173         org.openide.awt.Mnemonics.setLocalizedText(jLabel5, java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/history/Bundle").getString("CTL_FromToHint"));
174         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
175         gridBagConstraints.gridx = 2;
176         gridBagConstraints.gridy = 2;
177         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 2, 0, 4);
178         add(jLabel5, gridBagConstraints);
179
180         org.openide.awt.Mnemonics.setLocalizedText(bBrowseFrom, java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/history/Bundle").getString("CTL_BrowseFrom"));
181         bBrowseFrom.setToolTipText(java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/history/Bundle").getString("TT_BrowseFrom"));
182         bBrowseFrom.addActionListener(new java.awt.event.ActionListener JavaDoc() {
183             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
184                 onFromBrowse(evt);
185             }
186         });
187
188         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
189         gridBagConstraints.gridx = 3;
190         gridBagConstraints.gridy = 2;
191         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 4, 0, 0);
192         add(bBrowseFrom, gridBagConstraints);
193
194         jLabel4.setLabelFor(tfTo);
195         org.openide.awt.Mnemonics.setLocalizedText(jLabel4, java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/history/Bundle").getString("CTL_UseTo"));
196         jLabel4.setToolTipText(java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/history/Bundle").getString("TT_To"));
197         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
198         gridBagConstraints.gridy = 3;
199         gridBagConstraints.anchor = java.awt.GridBagConstraints.FIRST_LINE_START;
200         gridBagConstraints.weighty = 1.0;
201         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 0, 0, 0);
202         add(jLabel4, gridBagConstraints);
203
204         tfTo.setColumns(20);
205         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
206         gridBagConstraints.gridx = 1;
207         gridBagConstraints.gridy = 3;
208         gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
209         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
210         gridBagConstraints.anchor = java.awt.GridBagConstraints.FIRST_LINE_START;
211         gridBagConstraints.weightx = 1.0;
212         gridBagConstraints.weighty = 1.0;
213         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 4, 0, 4);
214         add(tfTo, gridBagConstraints);
215
216         org.openide.awt.Mnemonics.setLocalizedText(jLabel6, java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/history/Bundle").getString("CTL_FromToHint"));
217         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
218         gridBagConstraints.gridx = 2;
219         gridBagConstraints.gridy = 3;
220         gridBagConstraints.anchor = java.awt.GridBagConstraints.PAGE_START;
221         gridBagConstraints.weighty = 1.0;
222         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 2, 0, 4);
223         add(jLabel6, gridBagConstraints);
224
225         org.openide.awt.Mnemonics.setLocalizedText(bBrowseTo, java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/history/Bundle").getString("CTL_BrowseTo"));
226         bBrowseTo.setToolTipText(java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/history/Bundle").getString("TT_BrowseTo"));
227         bBrowseTo.addActionListener(new java.awt.event.ActionListener JavaDoc() {
228             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
229                 onToBrowse(evt);
230             }
231         });
232
233         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
234         gridBagConstraints.gridx = 3;
235         gridBagConstraints.gridy = 3;
236         gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
237         gridBagConstraints.anchor = java.awt.GridBagConstraints.FIRST_LINE_START;
238         gridBagConstraints.weighty = 1.0;
239         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 4, 0, 0);
240         add(bBrowseTo, gridBagConstraints);
241
242     }
243     // </editor-fold>//GEN-END:initComponents
244

245     private void onToBrowse(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_onToBrowse
246
onBrowse(tfTo);
247     }//GEN-LAST:event_onToBrowse
248

249     private void onFromBrowse(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_onFromBrowse
250
onBrowse(tfFrom);
251     }//GEN-LAST:event_onFromBrowse
252

253     private void onBrowse(JTextField destination) {
254         for (int i = 0; i < roots.length; i++) {
255             try {
256                 CVSRoot.parse(Utils.getCVSRootFor(roots[i])); // raises exception
257
BranchSelector selector = new BranchSelector();
258                 String JavaDoc tag = selector.selectTag(roots[i]);
259                 if (tag != null) {
260                     destination.setText(tag);
261                 }
262                 return;
263             } catch (IOException JavaDoc e) {
264                 // no root for this file, try next
265
}
266         }
267     }
268     
269     // Variables declaration - do not modify//GEN-BEGIN:variables
270
private javax.swing.JButton JavaDoc bBrowseFrom;
271     private javax.swing.JButton JavaDoc bBrowseTo;
272     private javax.swing.JLabel JavaDoc jLabel1;
273     private javax.swing.JLabel JavaDoc jLabel2;
274     private javax.swing.JLabel JavaDoc jLabel3;
275     private javax.swing.JLabel JavaDoc jLabel4;
276     private javax.swing.JLabel JavaDoc jLabel5;
277     private javax.swing.JLabel JavaDoc jLabel6;
278     private javax.swing.JTextField JavaDoc tfCommitMessage;
279     private javax.swing.JTextField JavaDoc tfFrom;
280     private javax.swing.JTextField JavaDoc tfTo;
281     private javax.swing.JTextField JavaDoc tfUsername;
282     // End of variables declaration//GEN-END:variables
283

284 }
285
Popular Tags