PageRenderTime 26ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 1ms

/projects/netbeans-7.3/mercurial/src/org/netbeans/modules/mercurial/ui/log/SearchCriteriaPanel.java

https://gitlab.com/essere.lab.public/qualitas.class-corpus
Java | 283 lines | 187 code | 35 blank | 61 comment | 11 complexity | 1bd9f3788fe8b58d94cb4ce50bcd87db MD5 | raw file
  1. /*
  2. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  3. *
  4. * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
  5. *
  6. * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
  7. * Other names may be trademarks of their respective owners.
  8. *
  9. * The contents of this file are subject to the terms of either the GNU
  10. * General Public License Version 2 only ("GPL") or the Common
  11. * Development and Distribution License("CDDL") (collectively, the
  12. * "License"). You may not use this file except in compliance with the
  13. * License. You can obtain a copy of the License at
  14. * http://www.netbeans.org/cddl-gplv2.html
  15. * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
  16. * specific language governing permissions and limitations under the
  17. * License. When distributing the software, include this License Header
  18. * Notice in each file and include the License file at
  19. * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
  20. * particular file as subject to the "Classpath" exception as provided
  21. * by Oracle in the GPL Version 2 section of the License file that
  22. * accompanied this code. If applicable, add the following below the
  23. * License Header, with the fields enclosed by brackets [] replaced by
  24. * your own identifying information:
  25. * "Portions Copyrighted [year] [name of copyright owner]"
  26. *
  27. * Contributor(s):
  28. *
  29. * The Original Software is NetBeans. The Initial Developer of the Original
  30. * Software is Sun Microsystems, Inc. Portions Copyright 1997-2009 Sun
  31. * Microsystems, Inc. All Rights Reserved.
  32. *
  33. * If you wish your version of this file to be governed by only the CDDL
  34. * or only the GPL Version 2, indicate your decision by adding
  35. * "[Contributor] elects to include this software in this distribution
  36. * under the [CDDL or GPL Version 2] license." If you do not indicate a
  37. * single choice of license, a recipient has the option to distribute
  38. * your version of this file under either the CDDL, the GPL Version 2 or
  39. * to extend the choice of license to its licensees as provided above.
  40. * However, if you add GPL Version 2 code and therefore, elected the GPL
  41. * Version 2 license, then the option applies only if the new code is
  42. * made subject to such option by the copyright holder.
  43. */
  44. package org.netbeans.modules.mercurial.ui.log;
  45. import org.netbeans.modules.mercurial.HgModuleConfig;
  46. import org.openide.util.NbBundle;
  47. /**
  48. * Packages search criteria in Search History panel.
  49. *
  50. * @author Maros Sandor
  51. */
  52. class SearchCriteriaPanel extends javax.swing.JPanel {
  53. /** Creates new form SearchCriteriaPanel */
  54. public SearchCriteriaPanel() {
  55. initComponents();
  56. showMergesChkBox.setSelected(HgModuleConfig.getDefault().getShowHistoryMerges());
  57. tfLimit.setText(Integer.toString(SearchExecutor.DEFAULT_LIMIT));
  58. }
  59. public String getFrom() {
  60. String s = tfFrom.getText().trim();
  61. if(s.length() == 0) {
  62. return null;
  63. }
  64. return s;
  65. }
  66. public String getTo() {
  67. String s = tfTo.getText().trim();
  68. if(s.length() == 0) {
  69. return null;
  70. }
  71. return s;
  72. }
  73. /**
  74. *
  75. * @return limit for shown changesets, -1 for no limit
  76. */
  77. public int getLimit() {
  78. String s = tfLimit.getText().trim();
  79. Integer retval = -1;
  80. try {
  81. retval = Integer.parseInt(s);
  82. } catch (NumberFormatException ex) {
  83. retval = -1;
  84. }
  85. if (retval <= 0) {
  86. retval = -1;
  87. }
  88. return retval;
  89. }
  90. void setForIncoming() {
  91. fromInfoLabel.setText(NbBundle.getMessage(SearchCriteriaPanel.class, "CTL_FromToOutOrIncomingHint"));
  92. toInfoLabel.setText(NbBundle.getMessage(SearchCriteriaPanel.class, "CTL_FromToOutOrIncomingHint"));
  93. fromLabel.setToolTipText(NbBundle.getMessage(SearchHistoryPanel.class, "TT_IncomingFrom"));
  94. toLabel.setToolTipText(NbBundle.getMessage(SearchHistoryPanel.class, "TT_IncomingTo"));
  95. showMergesChkBox.setToolTipText(NbBundle.getMessage(SearchHistoryPanel.class, "TT_IncomingShowMerges"));
  96. tfFrom.setText(NbBundle.getMessage(SearchHistoryPanel.class, "TTF_IncomingFrom"));
  97. tfFrom.setEnabled(false);
  98. }
  99. void setForOut() {
  100. fromInfoLabel.setText(NbBundle.getMessage(SearchCriteriaPanel.class, "CTL_FromToOutOrIncomingHint"));
  101. toInfoLabel.setText(NbBundle.getMessage(SearchCriteriaPanel.class, "CTL_FromToOutOrIncomingHint"));
  102. fromLabel.setToolTipText(NbBundle.getMessage(SearchHistoryPanel.class, "TT_OutFrom"));
  103. toLabel.setToolTipText(NbBundle.getMessage(SearchHistoryPanel.class, "TT_OutTo"));
  104. showMergesChkBox.setToolTipText(NbBundle.getMessage(SearchHistoryPanel.class, "TT_OutShowMerges"));
  105. tfFrom.setText(NbBundle.getMessage(SearchHistoryPanel.class, "TTF_OutFrom"));
  106. tfFrom.setEnabled(false);
  107. }
  108. public void setFrom(String from) {
  109. if (from == null) from = ""; // NOI18N
  110. tfFrom.setText(from);
  111. }
  112. public void setTo(String to) {
  113. if (to == null) to = ""; // NOI18N
  114. tfTo.setText(to);
  115. }
  116. void setLimit (int limit) {
  117. if (limit > 0) {
  118. tfLimit.setText(Integer.toString(limit));
  119. } else {
  120. tfLimit.setText("");
  121. }
  122. }
  123. public String getBranch () {
  124. return tfBranch.getText().trim();
  125. }
  126. public void setBranch (String branchName) {
  127. tfBranch.setText(branchName);
  128. }
  129. boolean isIncludeMerges() {
  130. return showMergesChkBox.isSelected();
  131. }
  132. /** This method is called from within the constructor to
  133. * initialize the form.
  134. * WARNING: Do NOT modify this code. The content of this method is
  135. * always regenerated by the Form Editor.
  136. */
  137. // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  138. private void initComponents() {
  139. fromLabel = new javax.swing.JLabel();
  140. fromInfoLabel = new javax.swing.JLabel();
  141. toLabel = new javax.swing.JLabel();
  142. toInfoLabel = new javax.swing.JLabel();
  143. toLabel1 = new javax.swing.JLabel();
  144. toLabel2 = new javax.swing.JLabel();
  145. showMergesChkBox = new javax.swing.JCheckBox();
  146. setBorder(javax.swing.BorderFactory.createEmptyBorder(8, 12, 0, 11));
  147. fromLabel.setLabelFor(tfFrom);
  148. java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/netbeans/modules/mercurial/ui/log/Bundle"); // NOI18N
  149. org.openide.awt.Mnemonics.setLocalizedText(fromLabel, bundle.getString("CTL_UseFrom")); // NOI18N
  150. fromLabel.setToolTipText(bundle.getString("TT_From")); // NOI18N
  151. tfFrom.setColumns(20);
  152. org.openide.awt.Mnemonics.setLocalizedText(fromInfoLabel, bundle.getString("CTL_FromToHint")); // NOI18N
  153. toLabel.setLabelFor(tfTo);
  154. org.openide.awt.Mnemonics.setLocalizedText(toLabel, bundle.getString("CTL_UseTo")); // NOI18N
  155. toLabel.setToolTipText(bundle.getString("TT_To")); // NOI18N
  156. tfTo.setColumns(20);
  157. org.openide.awt.Mnemonics.setLocalizedText(toInfoLabel, bundle.getString("CTL_FromToHint")); // NOI18N
  158. toLabel1.setLabelFor(tfLimit);
  159. org.openide.awt.Mnemonics.setLocalizedText(toLabel1, bundle.getString("CTL_UseLimit")); // NOI18N
  160. toLabel1.setToolTipText(bundle.getString("TT_Limit")); // NOI18N
  161. tfLimit.setColumns(10);
  162. toLabel2.setLabelFor(tfBranch);
  163. org.openide.awt.Mnemonics.setLocalizedText(toLabel2, bundle.getString("CTL_UseBranch")); // NOI18N
  164. toLabel2.setToolTipText(bundle.getString("TT_Branch")); // NOI18N
  165. tfBranch.setColumns(10);
  166. org.openide.awt.Mnemonics.setLocalizedText(btnSelectBranch, org.openide.util.NbBundle.getMessage(SearchCriteriaPanel.class, "CTL_SelectBranch")); // NOI18N
  167. btnSelectBranch.setToolTipText(org.openide.util.NbBundle.getMessage(SearchCriteriaPanel.class, "TT_SelectBranch")); // NOI18N
  168. showMergesChkBox.setSelected(true);
  169. org.openide.awt.Mnemonics.setLocalizedText(showMergesChkBox, org.openide.util.NbBundle.getMessage(SearchCriteriaPanel.class, "CTL_ShowMerge")); // NOI18N
  170. showMergesChkBox.setToolTipText(org.openide.util.NbBundle.getMessage(SearchCriteriaPanel.class, "TT_ShowMerges")); // NOI18N
  171. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
  172. this.setLayout(layout);
  173. layout.setHorizontalGroup(
  174. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  175. .addGroup(layout.createSequentialGroup()
  176. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  177. .addGroup(layout.createSequentialGroup()
  178. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  179. .addComponent(toLabel2, javax.swing.GroupLayout.Alignment.TRAILING)
  180. .addComponent(toLabel1, javax.swing.GroupLayout.Alignment.TRAILING))
  181. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  182. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  183. .addGroup(layout.createSequentialGroup()
  184. .addComponent(tfLimit, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
  185. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  186. .addComponent(showMergesChkBox))
  187. .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
  188. .addComponent(tfBranch)
  189. .addGap(18, 18, 18)
  190. .addComponent(btnSelectBranch)))
  191. .addGap(30, 30, 30)
  192. .addComponent(fromLabel))
  193. .addGroup(layout.createSequentialGroup()
  194. .addGap(0, 0, Short.MAX_VALUE)
  195. .addComponent(toLabel)))
  196. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  197. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  198. .addComponent(toInfoLabel)
  199. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  200. .addComponent(tfFrom)
  201. .addComponent(fromInfoLabel)
  202. .addComponent(tfTo)))
  203. .addGap(14, 14, 14))
  204. );
  205. layout.setVerticalGroup(
  206. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  207. .addGroup(layout.createSequentialGroup()
  208. .addGap(2, 2, 2)
  209. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  210. .addComponent(fromLabel)
  211. .addComponent(tfFrom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  212. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  213. .addComponent(fromInfoLabel)
  214. .addGap(16, 16, 16)
  215. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  216. .addComponent(tfTo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  217. .addComponent(toLabel))
  218. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  219. .addComponent(toInfoLabel)
  220. .addContainerGap(28, Short.MAX_VALUE))
  221. .addGroup(layout.createSequentialGroup()
  222. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
  223. .addComponent(toLabel2)
  224. .addComponent(btnSelectBranch)
  225. .addComponent(tfBranch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  226. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  227. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
  228. .addComponent(showMergesChkBox, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
  229. .addComponent(toLabel1)
  230. .addComponent(tfLimit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  231. .addGap(0, 0, Short.MAX_VALUE))
  232. );
  233. }// </editor-fold>//GEN-END:initComponents
  234. // Variables declaration - do not modify//GEN-BEGIN:variables
  235. final javax.swing.JButton btnSelectBranch = new javax.swing.JButton();
  236. private javax.swing.JLabel fromInfoLabel;
  237. private javax.swing.JLabel fromLabel;
  238. private javax.swing.JCheckBox showMergesChkBox;
  239. final javax.swing.JTextField tfBranch = new javax.swing.JTextField();
  240. final javax.swing.JTextField tfFrom = new javax.swing.JTextField();
  241. final javax.swing.JTextField tfLimit = new javax.swing.JTextField();
  242. final javax.swing.JTextField tfTo = new javax.swing.JTextField();
  243. private javax.swing.JLabel toInfoLabel;
  244. private javax.swing.JLabel toLabel;
  245. private javax.swing.JLabel toLabel1;
  246. private javax.swing.JLabel toLabel2;
  247. // End of variables declaration//GEN-END:variables
  248. }