2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
6 * The contents of this file are subject to the terms of either the GNU
7 * General Public License Version 2 only ("GPL") or the Common
8 * Development and Distribution License("CDDL") (collectively, the
9 * "License"). You may not use this file except in compliance with the
10 * License. You can obtain a copy of the License at
11 * http://www.netbeans.org/cddl-gplv2.html
12 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13 * specific language governing permissions and limitations under the
14 * License. When distributing the software, include this License Header
15 * Notice in each file and include the License file at
16 * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17 * particular file as subject to the "Classpath" exception as provided
18 * by Sun in the GPL Version 2 section of the License file that
19 * accompanied this code. If applicable, add the following below the
20 * License Header, with the fields enclosed by brackets [] replaced by
21 * your own identifying information:
22 * "Portions Copyrighted [year] [name of copyright owner]"
26 * The Original Software is NetBeans. The Initial Developer of the Original
27 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28 * Microsystems, Inc. All Rights Reserved.
29 * Portions Copyright 2008 Alexander Coles (Ikonoklastik Productions).
31 * If you wish your version of this file to be governed by only the CDDL
32 * or only the GPL Version 2, indicate your decision by adding
33 * "[Contributor] elects to include this software in this distribution
34 * under the [CDDL or GPL Version 2] license." If you do not indicate a
35 * single choice of license, a recipient has the option to distribute
36 * your version of this file under either the CDDL, the GPL Version 2 or
37 * to extend the choice of license to its licensees as provided above.
38 * However, if you add GPL Version 2 code and therefore, elected the GPL
39 * Version 2 license, then the option applies only if the new code is
40 * made subject to such option by the copyright holder.
42 package org
.nbgit
.ui
.log
;
45 import java
.text
.DateFormat
;
46 import java
.text
.ParseException
;
47 import java
.util
.Date
;
48 import javax
.swing
.SwingUtilities
;
49 import org
.openide
.util
.NbBundle
;
52 * Packages search criteria in Search History panel.
54 * @author Maros Sandor
56 class SearchCriteriaPanel
extends javax
.swing
.JPanel
{
58 private final File
[] roots
;
59 private final String url
;
61 /** Creates new form SearchCriteriaPanel */
62 public SearchCriteriaPanel(File
[] roots
) {
68 public SearchCriteriaPanel(String url
) {
74 public String
getFrom() {
75 String s
= tfFrom
.getText().trim();
76 if (s
.length() == 0) {
82 public String
getTo() {
83 String s
= tfTo
.getText().trim();
84 if (s
.length() == 0) {
90 void setForIncoming() {
91 fromInfoLabel
.setText(NbBundle
.getMessage(SearchCriteriaPanel
.class, "CTL_FromToOutOrIncomingHint"));
92 toInfoLabel
.setText(NbBundle
.getMessage(SearchCriteriaPanel
.class, "CTL_FromToOutOrIncomingHint"));
93 commitMessageLabel
.setToolTipText(NbBundle
.getMessage(SearchHistoryPanel
.class, "TT_IncomingCommitMessage"));
94 usernameLabel
.setToolTipText(NbBundle
.getMessage(SearchHistoryPanel
.class, "TT_IncomingUsername"));
95 fromLabel
.setToolTipText(NbBundle
.getMessage(SearchHistoryPanel
.class, "TT_IncomingFrom"));
96 toLabel
.setToolTipText(NbBundle
.getMessage(SearchHistoryPanel
.class, "TT_IncomingTo"));
98 tfFrom
.setEnabled(false);
99 fromLabel
.setEnabled(false);
103 fromInfoLabel
.setText(NbBundle
.getMessage(SearchCriteriaPanel
.class, "CTL_FromToOutOrIncomingHint"));
104 toInfoLabel
.setText(NbBundle
.getMessage(SearchCriteriaPanel
.class, "CTL_FromToOutOrIncomingHint"));
105 commitMessageLabel
.setToolTipText(NbBundle
.getMessage(SearchHistoryPanel
.class, "TT_OutCommitMessage"));
106 usernameLabel
.setToolTipText(NbBundle
.getMessage(SearchHistoryPanel
.class, "TT_OutUsername"));
107 fromLabel
.setToolTipText(NbBundle
.getMessage(SearchHistoryPanel
.class, "TT_OutFrom"));
108 toLabel
.setToolTipText(NbBundle
.getMessage(SearchHistoryPanel
.class, "TT_OutTo"));
110 tfFrom
.setEnabled(false);
111 fromLabel
.setEnabled(false);
114 private Date
parseDate(String s
) {
118 for (int i
= 0; i
< SearchExecutor
.dateFormats
.length
; i
++) {
119 DateFormat dateformat
= SearchExecutor
.dateFormats
[i
];
121 return dateformat
.parse(s
);
122 } catch (ParseException e
) {
129 public String
getCommitMessage() {
130 String s
= tfCommitMessage
.getText().trim();
131 return s
.length() > 0 ? s
: null;
134 public String
getUsername() {
135 String s
= tfUsername
.getText().trim();
136 return s
.length() > 0 ? s
: null;
139 public void setFrom(String from
) {
143 tfFrom
.setText(from
);
146 public void setTo(String to
) {
153 public void setCommitMessage(String message
) {
154 if (message
== null) {
155 message
= ""; // NOI18N
157 tfCommitMessage
.setText(message
);
160 public void setUsername(String username
) {
161 if (username
== null) {
162 username
= ""; // NOI18N
164 tfUsername
.setText(username
);
168 public void addNotify() {
170 SwingUtilities
.invokeLater(new Runnable() {
173 tfCommitMessage
.requestFocusInWindow();
178 /** This method is called from within the constructor to
179 * initialize the form.
180 * WARNING: Do NOT modify this code. The content of this method is
181 * always regenerated by the Form Editor.
183 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
184 private void initComponents() {
185 java
.awt
.GridBagConstraints gridBagConstraints
;
187 commitMessageLabel
= new javax
.swing
.JLabel();
188 tfCommitMessage
= new javax
.swing
.JTextField();
189 usernameLabel
= new javax
.swing
.JLabel();
190 tfUsername
= new javax
.swing
.JTextField();
191 fromLabel
= new javax
.swing
.JLabel();
192 fromInfoLabel
= new javax
.swing
.JLabel();
193 toLabel
= new javax
.swing
.JLabel();
194 toInfoLabel
= new javax
.swing
.JLabel();
196 setBorder(javax
.swing
.BorderFactory
.createEmptyBorder(8, 12, 0, 11));
197 setLayout(new java
.awt
.GridBagLayout());
199 commitMessageLabel
.setLabelFor(tfCommitMessage
);
200 java
.util
.ResourceBundle bundle
= java
.util
.ResourceBundle
.getBundle("org/nbgit/ui/log/Bundle"); // NOI18N
201 org
.openide
.awt
.Mnemonics
.setLocalizedText(commitMessageLabel
, bundle
.getString("CTL_UseCommitMessage")); // NOI18N
202 commitMessageLabel
.setToolTipText(bundle
.getString("TT_CommitMessage")); // NOI18N
203 gridBagConstraints
= new java
.awt
.GridBagConstraints();
204 gridBagConstraints
.anchor
= java
.awt
.GridBagConstraints
.LINE_START
;
205 add(commitMessageLabel
, gridBagConstraints
);
206 commitMessageLabel
.getAccessibleContext().setAccessibleName(org
.openide
.util
.NbBundle
.getMessage(SearchCriteriaPanel
.class, "CTL_UseCommitMessage")); // NOI18N
208 tfCommitMessage
.setColumns(20);
209 gridBagConstraints
= new java
.awt
.GridBagConstraints();
210 gridBagConstraints
.gridx
= 1;
211 gridBagConstraints
.gridy
= 0;
212 gridBagConstraints
.gridwidth
= 2;
213 gridBagConstraints
.fill
= java
.awt
.GridBagConstraints
.HORIZONTAL
;
214 gridBagConstraints
.weightx
= 1.0;
215 gridBagConstraints
.insets
= new java
.awt
.Insets(0, 4, 0, 0);
216 add(tfCommitMessage
, gridBagConstraints
);
218 usernameLabel
.setLabelFor(tfUsername
);
219 org
.openide
.awt
.Mnemonics
.setLocalizedText(usernameLabel
, bundle
.getString("CTL_UseUsername")); // NOI18N
220 usernameLabel
.setToolTipText(bundle
.getString("TT_Username")); // NOI18N
221 gridBagConstraints
= new java
.awt
.GridBagConstraints();
222 gridBagConstraints
.gridy
= 1;
223 gridBagConstraints
.anchor
= java
.awt
.GridBagConstraints
.LINE_START
;
224 add(usernameLabel
, gridBagConstraints
);
226 tfUsername
.setColumns(20);
227 gridBagConstraints
= new java
.awt
.GridBagConstraints();
228 gridBagConstraints
.gridx
= 1;
229 gridBagConstraints
.gridy
= 1;
230 gridBagConstraints
.gridwidth
= 2;
231 gridBagConstraints
.fill
= java
.awt
.GridBagConstraints
.HORIZONTAL
;
232 gridBagConstraints
.weightx
= 1.0;
233 gridBagConstraints
.insets
= new java
.awt
.Insets(3, 4, 0, 0);
234 add(tfUsername
, gridBagConstraints
);
236 fromLabel
.setLabelFor(tfFrom
);
237 org
.openide
.awt
.Mnemonics
.setLocalizedText(fromLabel
, bundle
.getString("CTL_UseFrom")); // NOI18N
238 fromLabel
.setToolTipText(bundle
.getString("TT_From")); // NOI18N
239 gridBagConstraints
= new java
.awt
.GridBagConstraints();
240 gridBagConstraints
.gridy
= 2;
241 gridBagConstraints
.anchor
= java
.awt
.GridBagConstraints
.LINE_START
;
242 add(fromLabel
, gridBagConstraints
);
244 tfFrom
.setColumns(20);
245 gridBagConstraints
= new java
.awt
.GridBagConstraints();
246 gridBagConstraints
.gridx
= 1;
247 gridBagConstraints
.gridy
= 2;
248 gridBagConstraints
.fill
= java
.awt
.GridBagConstraints
.HORIZONTAL
;
249 gridBagConstraints
.weightx
= 1.0;
250 gridBagConstraints
.insets
= new java
.awt
.Insets(0, 4, 0, 4);
251 add(tfFrom
, gridBagConstraints
);
253 org
.openide
.awt
.Mnemonics
.setLocalizedText(fromInfoLabel
, bundle
.getString("CTL_FromToHint")); // NOI18N
254 gridBagConstraints
= new java
.awt
.GridBagConstraints();
255 gridBagConstraints
.gridx
= 2;
256 gridBagConstraints
.gridy
= 2;
257 gridBagConstraints
.insets
= new java
.awt
.Insets(0, 2, 0, 4);
258 add(fromInfoLabel
, gridBagConstraints
);
260 toLabel
.setLabelFor(tfTo
);
261 org
.openide
.awt
.Mnemonics
.setLocalizedText(toLabel
, bundle
.getString("CTL_UseTo")); // NOI18N
262 toLabel
.setToolTipText(bundle
.getString("TT_To")); // NOI18N
263 gridBagConstraints
= new java
.awt
.GridBagConstraints();
264 gridBagConstraints
.gridy
= 3;
265 gridBagConstraints
.anchor
= java
.awt
.GridBagConstraints
.FIRST_LINE_START
;
266 gridBagConstraints
.weighty
= 1.0;
267 gridBagConstraints
.insets
= new java
.awt
.Insets(3, 0, 0, 0);
268 add(toLabel
, gridBagConstraints
);
271 gridBagConstraints
= new java
.awt
.GridBagConstraints();
272 gridBagConstraints
.gridx
= 1;
273 gridBagConstraints
.gridy
= 3;
274 gridBagConstraints
.gridheight
= java
.awt
.GridBagConstraints
.REMAINDER
;
275 gridBagConstraints
.fill
= java
.awt
.GridBagConstraints
.HORIZONTAL
;
276 gridBagConstraints
.anchor
= java
.awt
.GridBagConstraints
.FIRST_LINE_START
;
277 gridBagConstraints
.weightx
= 1.0;
278 gridBagConstraints
.weighty
= 1.0;
279 gridBagConstraints
.insets
= new java
.awt
.Insets(0, 4, 0, 4);
280 add(tfTo
, gridBagConstraints
);
282 org
.openide
.awt
.Mnemonics
.setLocalizedText(toInfoLabel
, bundle
.getString("CTL_FromToHint")); // NOI18N
283 gridBagConstraints
= new java
.awt
.GridBagConstraints();
284 gridBagConstraints
.gridx
= 2;
285 gridBagConstraints
.gridy
= 3;
286 gridBagConstraints
.anchor
= java
.awt
.GridBagConstraints
.PAGE_START
;
287 gridBagConstraints
.weighty
= 1.0;
288 gridBagConstraints
.insets
= new java
.awt
.Insets(3, 2, 0, 4);
289 add(toInfoLabel
, gridBagConstraints
);
290 }// </editor-fold>//GEN-END:initComponents
291 // Variables declaration - do not modify//GEN-BEGIN:variables
292 private javax
.swing
.JLabel commitMessageLabel
;
293 private javax
.swing
.JLabel fromInfoLabel
;
294 private javax
.swing
.JLabel fromLabel
;
295 private javax
.swing
.JTextField tfCommitMessage
;
296 final javax
.swing
.JTextField tfFrom
= new javax
.swing
.JTextField();
297 final javax
.swing
.JTextField tfTo
= new javax
.swing
.JTextField();
298 private javax
.swing
.JTextField tfUsername
;
299 private javax
.swing
.JLabel toInfoLabel
;
300 private javax
.swing
.JLabel toLabel
;
301 private javax
.swing
.JLabel usernameLabel
;
302 // End of variables declaration//GEN-END:variables