1 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 ; 30 import java.io.File ; 31 32 37 class SearchCriteriaPanel extends javax.swing.JPanel { 38 39 private final File [] roots; 40 41 42 public SearchCriteriaPanel(File [] roots) { 43 this.roots = roots; 44 initComponents(); 45 } 46 47 public String getFrom() { 48 String s = tfFrom.getText().trim(); 49 return s.length() > 0 ? s : null; 50 } 51 52 public String getTo() { 53 String s = tfTo.getText().trim(); 54 return s.length() > 0 ? s : null; 55 } 56 57 public String getCommitMessage() { 58 String s = tfCommitMessage.getText().trim(); 59 return s.length() > 0 ? s : null; 60 } 61 62 public String getUsername() { 63 String s = tfUsername.getText().trim(); 64 return s.length() > 0 ? s : null; 65 } 66 67 public void setFrom(String from) { 68 if (from == null) from = ""; tfFrom.setText(from); 70 } 71 72 public void setTo(String to) { 73 if (to == null) to = ""; tfTo.setText(to); 75 } 76 77 public void setCommitMessage(String message) { 78 if (message == null) message = ""; tfCommitMessage.setText(message); 80 } 81 82 public void setUsername(String username) { 83 if (username == null) username = ""; tfUsername.setText(username); 85 } 86 87 public void addNotify() { 88 super.addNotify(); 89 SwingUtilities.invokeLater(new Runnable () { 90 public void run() { 91 tfCommitMessage.requestFocusInWindow(); 92 } 93 }); 94 } 95 96 101 private void initComponents() { 103 java.awt.GridBagConstraints gridBagConstraints; 104 105 jLabel1 = new javax.swing.JLabel (); 106 tfCommitMessage = new javax.swing.JTextField (); 107 jLabel2 = new javax.swing.JLabel (); 108 tfUsername = new javax.swing.JTextField (); 109 jLabel3 = new javax.swing.JLabel (); 110 tfFrom = new javax.swing.JTextField (); 111 jLabel5 = new javax.swing.JLabel (); 112 bBrowseFrom = new javax.swing.JButton (); 113 jLabel4 = new javax.swing.JLabel (); 114 tfTo = new javax.swing.JTextField (); 115 jLabel6 = new javax.swing.JLabel (); 116 bBrowseTo = new javax.swing.JButton (); 117 118 setLayout(new java.awt.GridBagLayout ()); 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 (); 125 gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; 126 add(jLabel1, gridBagConstraints); 127 128 tfCommitMessage.setColumns(20); 129 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (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 (); 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 (); 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 (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 (); 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 (); 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 (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 (); 175 gridBagConstraints.gridx = 2; 176 gridBagConstraints.gridy = 2; 177 gridBagConstraints.insets = new java.awt.Insets (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 () { 183 public void actionPerformed(java.awt.event.ActionEvent evt) { 184 onFromBrowse(evt); 185 } 186 }); 187 188 gridBagConstraints = new java.awt.GridBagConstraints (); 189 gridBagConstraints.gridx = 3; 190 gridBagConstraints.gridy = 2; 191 gridBagConstraints.insets = new java.awt.Insets (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 (); 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 (3, 0, 0, 0); 202 add(jLabel4, gridBagConstraints); 203 204 tfTo.setColumns(20); 205 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (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 (); 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 (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 () { 228 public void actionPerformed(java.awt.event.ActionEvent evt) { 229 onToBrowse(evt); 230 } 231 }); 232 233 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (0, 4, 0, 0); 240 add(bBrowseTo, gridBagConstraints); 241 242 } 243 245 private void onToBrowse(java.awt.event.ActionEvent evt) { onBrowse(tfTo); 247 } 249 private void onFromBrowse(java.awt.event.ActionEvent evt) { onBrowse(tfFrom); 251 } 253 private void onBrowse(JTextField destination) { 254 for (int i = 0; i < roots.length; i++) { 255 try { 256 CVSRoot.parse(Utils.getCVSRootFor(roots[i])); BranchSelector selector = new BranchSelector(); 258 String tag = selector.selectTag(roots[i]); 259 if (tag != null) { 260 destination.setText(tag); 261 } 262 return; 263 } catch (IOException e) { 264 } 266 } 267 } 268 269 private javax.swing.JButton bBrowseFrom; 271 private javax.swing.JButton bBrowseTo; 272 private javax.swing.JLabel jLabel1; 273 private javax.swing.JLabel jLabel2; 274 private javax.swing.JLabel jLabel3; 275 private javax.swing.JLabel jLabel4; 276 private javax.swing.JLabel jLabel5; 277 private javax.swing.JLabel jLabel6; 278 private javax.swing.JTextField tfCommitMessage; 279 private javax.swing.JTextField tfFrom; 280 private javax.swing.JTextField tfTo; 281 private javax.swing.JTextField tfUsername; 282 284 } 285 | Popular Tags |