1 /*
   2  * To change this template, choose Tools | Templates
   3  * and open the template in the editor.
   4  */
   5 
   6 /*
   7  * SearchDialog.java
   8  *
   9  * Created on Nov 16, 2010, 7:30:59 PM
  10  */
  11 
  12 package org.jemmy.browser;
  13 
  14 import javax.swing.JTextField;
  15 
  16 /**
  17  *
  18  * @author shura
  19  */
  20 public class SearchDialog extends javax.swing.JDialog {
  21     private boolean doSearch;
  22 
  23     /** Creates new form SearchDialog */
  24     public SearchDialog(java.awt.Frame parent) {
  25         super(parent, true);
  26         initComponents();
  27         getRootPane().setDefaultButton(searchBtn);
  28     }
  29 
  30     public boolean isConfirmed() {
  31         return doSearch;
  32     }
  33 
  34     /** This method is called from within the constructor to
  35      * initialize the form.
  36      * WARNING: Do NOT modify this code. The content of this method is
  37      * always regenerated by the Form Editor.
  38      */
  39     @SuppressWarnings("unchecked")
  40     // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  41     private void initComponents() {
  42 
  43         jLabel1 = new javax.swing.JLabel();
  44         searchTF = new javax.swing.JTextField();
  45         cancelBtn = new javax.swing.JButton();
  46         searchBtn = new javax.swing.JButton();
  47         useProp = new javax.swing.JCheckBox();
  48         propSearch = new javax.swing.JTextField();
  49 
  50         setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
  51         setModal(true);
  52 
  53         jLabel1.setText("Class name");
  54 
  55         cancelBtn.setText("Cancel");
  56         cancelBtn.addActionListener(new java.awt.event.ActionListener() {
  57             public void actionPerformed(java.awt.event.ActionEvent evt) {
  58                 cancelBtnActionPerformed(evt);
  59             }
  60         });
  61 
  62         searchBtn.setText("Search");
  63         searchBtn.addActionListener(new java.awt.event.ActionListener() {
  64             public void actionPerformed(java.awt.event.ActionEvent evt) {
  65                 searchBtnActionPerformed(evt);
  66             }
  67         });
  68 
  69         useProp.setText("Property value");
  70         useProp.addActionListener(new java.awt.event.ActionListener() {
  71             public void actionPerformed(java.awt.event.ActionEvent evt) {
  72                 usePropActionPerformed(evt);
  73             }
  74         });
  75 
  76         propSearch.setEnabled(false);
  77 
  78         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  79         getContentPane().setLayout(layout);
  80         layout.setHorizontalGroup(
  81             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  82             .addGroup(layout.createSequentialGroup()
  83                 .addContainerGap()
  84                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  85                     .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  86                         .addComponent(searchBtn)
  87                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  88                         .addComponent(cancelBtn))
  89                     .addGroup(layout.createSequentialGroup()
  90                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  91                             .addComponent(useProp)
  92                             .addComponent(jLabel1))
  93                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  94                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  95                             .addComponent(searchTF, javax.swing.GroupLayout.DEFAULT_SIZE, 263, Short.MAX_VALUE)
  96                             .addComponent(propSearch, javax.swing.GroupLayout.DEFAULT_SIZE, 263, Short.MAX_VALUE))))
  97                 .addContainerGap())
  98         );
  99         layout.setVerticalGroup(
 100             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 101             .addGroup(layout.createSequentialGroup()
 102                 .addContainerGap()
 103                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 104                     .addComponent(jLabel1)
 105                     .addComponent(searchTF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
 106                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 107                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 108                     .addComponent(useProp)
 109                     .addComponent(propSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
 110                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
 111                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 112                     .addComponent(cancelBtn)
 113                     .addComponent(searchBtn))
 114                 .addContainerGap())
 115         );
 116 
 117         pack();
 118     }// </editor-fold>//GEN-END:initComponents
 119 
 120     private void cancelBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelBtnActionPerformed
 121         doSearch = false;
 122         setVisible(false);
 123     }//GEN-LAST:event_cancelBtnActionPerformed
 124 
 125     private void searchBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchBtnActionPerformed
 126         doSearch = true;
 127         setVisible(false);
 128     }//GEN-LAST:event_searchBtnActionPerformed
 129 
 130     private void usePropActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_usePropActionPerformed
 131         propSearch.setEnabled(useProp.isSelected());
 132         if(useProp.isSelected()) {
 133             propSearch.requestFocus();
 134         }
 135     }//GEN-LAST:event_usePropActionPerformed
 136 
 137     public String getClassNameFilter() {
 138         return searchTF.getText();
 139     }
 140 
 141     public String getPropertyFilter() {
 142         return useProp.isSelected() ? propSearch.getText() : null;
 143     }
 144 
 145 
 146     // Variables declaration - do not modify//GEN-BEGIN:variables
 147     private javax.swing.JButton cancelBtn;
 148     private javax.swing.JLabel jLabel1;
 149     private javax.swing.JTextField propSearch;
 150     private javax.swing.JButton searchBtn;
 151     private javax.swing.JTextField searchTF;
 152     private javax.swing.JCheckBox useProp;
 153     // End of variables declaration//GEN-END:variables
 154 
 155 }