AdvancedSearchDialog.java
上传用户:njlgjx
上传日期:2022-08-07
资源大小:9105k
文件大小:26k
源码类别:

图形图象

开发平台:

Java

  1. /*
  2.  * AdvancedSearchDialog.java
  3.  *
  4.  * Created on 2008年7月8日, 上午11:20
  5.  */
  6. package com.mwq.map.frame;
  7. import com.mwq.map.dao.Dao;
  8. import com.mwq.map.tool.ScreenSize;
  9. import java.text.DateFormat;
  10. import java.text.ParseException;
  11. import java.util.Date;
  12. import java.util.Enumeration;
  13. import java.util.Vector;
  14. import java.util.logging.Level;
  15. import java.util.logging.Logger;
  16. import javax.swing.AbstractButton;
  17. import javax.swing.JList;
  18. import javax.swing.JOptionPane;
  19. import javax.swing.JRadioButton;
  20. import javax.swing.JTextField;
  21. /**
  22.  *
  23.  * @author  Administrator
  24.  */
  25. public class AdvancedSearchDialog extends javax.swing.JDialog {
  26.     private static final Dao dao = Dao.getInstance();
  27.     private JList searchResultList;
  28.     private Vector searchResult;
  29.     /** Creates new form AdvancedSearchDialog */
  30.     public AdvancedSearchDialog(java.awt.Frame parent, boolean modal, JList searchResultList, Vector searchResult) {
  31.         super(parent, modal);
  32.         this.searchResultList = searchResultList;
  33.         this.searchResult = searchResult;
  34.         initComponents();
  35.         ScreenSize.centered(this);
  36.     }
  37.     /** This method is called from within the constructor to
  38.      * initialize the form.
  39.      * WARNING: Do NOT modify this code. The content of this method is
  40.      * always regenerated by the Form Editor.
  41.      */
  42.     @SuppressWarnings("unchecked")
  43.     // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
  44.     private void initComponents() {
  45.         textButtonGroup = new javax.swing.ButtonGroup();
  46.         timeButtonGroup = new javax.swing.ButtonGroup();
  47.         sortButtonGroup = new javax.swing.ButtonGroup();
  48.         textPanel = new javax.swing.JPanel();
  49.         keywordTextField = new javax.swing.JTextField();
  50.         keywordLabel = new javax.swing.JLabel();
  51.         nameRadioButton = new javax.swing.JRadioButton();
  52.         allRadioButton = new javax.swing.JRadioButton();
  53.         explainRadioButton = new javax.swing.JRadioButton();
  54.         jLabel1 = new javax.swing.JLabel();
  55.         timePanel = new javax.swing.JPanel();
  56.         appointRadioButton = new javax.swing.JRadioButton();
  57.         spaceRadioButton = new javax.swing.JRadioButton();
  58.         appointPanel = new com.mwq.map.calendar.CalendarPanel();
  59.         spaceStartPanel = new com.mwq.map.calendar.CalendarPanel();
  60.         spaceLabel = new javax.swing.JLabel();
  61.         spaceEndPanel = new com.mwq.map.calendar.CalendarPanel();
  62.         compareComboBox = new javax.swing.JComboBox();
  63.         sortPanel = new javax.swing.JPanel();
  64.         sortLabel = new javax.swing.JLabel();
  65.         sortTreePanel = new com.mwq.map.mwing.MTreePanel();
  66.         childTreeRadioButton = new javax.swing.JRadioButton();
  67.         currentNodeRadioButton = new javax.swing.JRadioButton();
  68.         jLabel2 = new javax.swing.JLabel();
  69.         searchButton = new javax.swing.JButton();
  70.         clearButton = new javax.swing.JButton();
  71.         exitButton = new javax.swing.JButton();
  72.         setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
  73.         setTitle("高级搜索");
  74.         textPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("标记文本"));
  75.         keywordTextField.setColumns(30);
  76.         keywordLabel.setText("关  键  字:");
  77.         textButtonGroup.add(nameRadioButton);
  78.         nameRadioButton.setText("名称");
  79.         nameRadioButton.setFocusPainted(false);
  80.         textButtonGroup.add(allRadioButton);
  81.         allRadioButton.setSelected(true);
  82.         allRadioButton.setText("全部");
  83.         allRadioButton.setFocusPainted(false);
  84.         textButtonGroup.add(explainRadioButton);
  85.         explainRadioButton.setText("说明");
  86.         explainRadioButton.setFocusPainted(false);
  87.         jLabel1.setText("搜索范围:");
  88.         javax.swing.GroupLayout textPanelLayout = new javax.swing.GroupLayout(textPanel);
  89.         textPanel.setLayout(textPanelLayout);
  90.         textPanelLayout.setHorizontalGroup(
  91.             textPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  92.             .addGroup(textPanelLayout.createSequentialGroup()
  93.                 .addContainerGap()
  94.                 .addGroup(textPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  95.                     .addComponent(keywordLabel)
  96.                     .addComponent(jLabel1))
  97.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  98.                 .addGroup(textPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  99.                     .addGroup(textPanelLayout.createSequentialGroup()
  100.                         .addComponent(allRadioButton)
  101.                         .addGap(18, 18, 18)
  102.                         .addComponent(nameRadioButton)
  103.                         .addGap(18, 18, 18)
  104.                         .addComponent(explainRadioButton))
  105.                     .addComponent(keywordTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  106.                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  107.         );
  108.         textPanelLayout.setVerticalGroup(
  109.             textPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  110.             .addGroup(textPanelLayout.createSequentialGroup()
  111.                 .addContainerGap()
  112.                 .addGroup(textPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  113.                     .addComponent(keywordLabel)
  114.                     .addComponent(keywordTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  115.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  116.                 .addGroup(textPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  117.                     .addComponent(allRadioButton)
  118.                     .addComponent(nameRadioButton)
  119.                     .addComponent(explainRadioButton)
  120.                     .addComponent(jLabel1))
  121.                 .addContainerGap(11, Short.MAX_VALUE))
  122.         );
  123.         timePanel.setBorder(javax.swing.BorderFactory.createTitledBorder("创建日期"));
  124.         timeButtonGroup.add(appointRadioButton);
  125.         appointRadioButton.setSelected(true);
  126.         appointRadioButton.setText("指定日期");
  127.         appointRadioButton.setFocusPainted(false);
  128.         appointRadioButton.addActionListener(new java.awt.event.ActionListener() {
  129.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  130.                 appointRadioButtonActionPerformed(evt);
  131.             }
  132.         });
  133.         timeButtonGroup.add(spaceRadioButton);
  134.         spaceRadioButton.setText("一段时间");
  135.         spaceRadioButton.setFocusPainted(false);
  136.         spaceRadioButton.addActionListener(new java.awt.event.ActionListener() {
  137.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  138.                 spaceRadioButtonActionPerformed(evt);
  139.             }
  140.         });
  141.         spaceStartPanel.setEnabled(false);
  142.         spaceLabel.setText("——");
  143.         spaceLabel.setEnabled(false);
  144.         spaceEndPanel.setEnabled(false);
  145.         compareComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "等于", "大于", "小于" }));
  146.         javax.swing.GroupLayout timePanelLayout = new javax.swing.GroupLayout(timePanel);
  147.         timePanel.setLayout(timePanelLayout);
  148.         timePanelLayout.setHorizontalGroup(
  149.             timePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  150.             .addGroup(timePanelLayout.createSequentialGroup()
  151.                 .addContainerGap()
  152.                 .addGroup(timePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  153.                     .addGroup(timePanelLayout.createSequentialGroup()
  154.                         .addComponent(spaceRadioButton)
  155.                         .addGap(18, 18, 18)
  156.                         .addComponent(spaceStartPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  157.                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  158.                         .addComponent(spaceLabel))
  159.                     .addGroup(timePanelLayout.createSequentialGroup()
  160.                         .addComponent(appointRadioButton)
  161.                         .addGap(18, 18, 18)
  162.                         .addComponent(appointPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
  163.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  164.                 .addGroup(timePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  165.                     .addComponent(spaceEndPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  166.                     .addComponent(compareComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  167.                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  168.         );
  169.         timePanelLayout.setVerticalGroup(
  170.             timePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  171.             .addGroup(timePanelLayout.createSequentialGroup()
  172.                 .addContainerGap()
  173.                 .addGroup(timePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  174.                     .addComponent(spaceLabel)
  175.                     .addGroup(timePanelLayout.createSequentialGroup()
  176.                         .addGroup(timePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  177.                             .addGroup(timePanelLayout.createSequentialGroup()
  178.                                 .addGroup(timePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  179.                                     .addComponent(appointPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  180.                                     .addComponent(appointRadioButton))
  181.                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
  182.                             .addGroup(timePanelLayout.createSequentialGroup()
  183.                                 .addComponent(compareComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  184.                                 .addGap(2, 2, 2)))
  185.                         .addGroup(timePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  186.                             .addComponent(spaceRadioButton, javax.swing.GroupLayout.Alignment.TRAILING)
  187.                             .addComponent(spaceStartPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  188.                             .addComponent(spaceEndPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
  189.                 .addContainerGap(13, Short.MAX_VALUE))
  190.         );
  191.         sortPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("所属类别"));
  192.         sortLabel.setText("所属类别:");
  193.         sortButtonGroup.add(childTreeRadioButton);
  194.         childTreeRadioButton.setSelected(true);
  195.         childTreeRadioButton.setText("包含子类");
  196.         childTreeRadioButton.setFocusPainted(false);
  197.         sortButtonGroup.add(currentNodeRadioButton);
  198.         currentNodeRadioButton.setText("仅当前类");
  199.         currentNodeRadioButton.setFocusPainted(false);
  200.         jLabel2.setText("搜索范围:");
  201.         javax.swing.GroupLayout sortPanelLayout = new javax.swing.GroupLayout(sortPanel);
  202.         sortPanel.setLayout(sortPanelLayout);
  203.         sortPanelLayout.setHorizontalGroup(
  204.             sortPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  205.             .addGroup(sortPanelLayout.createSequentialGroup()
  206.                 .addContainerGap()
  207.                 .addGroup(sortPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  208.                     .addComponent(sortLabel)
  209.                     .addComponent(jLabel2))
  210.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  211.                 .addGroup(sortPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  212.                     .addGroup(sortPanelLayout.createSequentialGroup()
  213.                         .addComponent(childTreeRadioButton)
  214.                         .addGap(18, 18, 18)
  215.                         .addComponent(currentNodeRadioButton))
  216.                     .addComponent(sortTreePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  217.                 .addContainerGap(79, Short.MAX_VALUE))
  218.         );
  219.         sortPanelLayout.setVerticalGroup(
  220.             sortPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  221.             .addGroup(sortPanelLayout.createSequentialGroup()
  222.                 .addContainerGap()
  223.                 .addGroup(sortPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  224.                     .addComponent(sortTreePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  225.                     .addComponent(sortLabel))
  226.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  227.                 .addGroup(sortPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  228.                     .addComponent(childTreeRadioButton)
  229.                     .addComponent(currentNodeRadioButton)
  230.                     .addComponent(jLabel2))
  231.                 .addContainerGap(11, Short.MAX_VALUE))
  232.         );
  233.         searchButton.setText("搜索");
  234.         searchButton.addActionListener(new java.awt.event.ActionListener() {
  235.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  236.                 searchButtonActionPerformed(evt);
  237.             }
  238.         });
  239.         clearButton.setText("清空");
  240.         clearButton.addActionListener(new java.awt.event.ActionListener() {
  241.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  242.                 clearButtonActionPerformed(evt);
  243.             }
  244.         });
  245.         exitButton.setText("退出");
  246.         exitButton.addActionListener(new java.awt.event.ActionListener() {
  247.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  248.                 exitButtonActionPerformed(evt);
  249.             }
  250.         });
  251.         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  252.         getContentPane().setLayout(layout);
  253.         layout.setHorizontalGroup(
  254.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  255.             .addGroup(layout.createSequentialGroup()
  256.                 .addContainerGap()
  257.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  258.                     .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  259.                         .addComponent(searchButton)
  260.                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  261.                         .addComponent(clearButton)
  262.                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  263.                         .addComponent(exitButton))
  264.                     .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
  265.                         .addComponent(textPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  266.                         .addComponent(timePanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  267.                         .addComponent(sortPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
  268.                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  269.         );
  270.         layout.setVerticalGroup(
  271.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  272.             .addGroup(layout.createSequentialGroup()
  273.                 .addContainerGap()
  274.                 .addComponent(textPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  275.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  276.                 .addComponent(timePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  277.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  278.                 .addComponent(sortPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  279.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  280.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  281.                     .addComponent(exitButton)
  282.                     .addComponent(clearButton)
  283.                     .addComponent(searchButton))
  284.                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  285.         );
  286.         pack();
  287.     }// </editor-fold>                        
  288. private void appointRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {                                                   
  289. // TODO add your handling code here:
  290.     appointPanel.setEnabled(true);
  291.     compareComboBox.setEnabled(true);
  292.     spaceStartPanel.setEnabled(false);
  293.     spaceLabel.setEnabled(false);
  294.     spaceEndPanel.setEnabled(false);
  295. }                                                  
  296. private void spaceRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {                                                 
  297. // TODO add your handling code here:
  298.     appointPanel.setEnabled(false);
  299.     compareComboBox.setEnabled(false);
  300.     spaceStartPanel.setEnabled(true);
  301.     spaceLabel.setEnabled(true);
  302.     spaceEndPanel.setEnabled(true);
  303. }                                                
  304. private void searchButtonActionPerformed(java.awt.event.ActionEvent evt) {                                             
  305. // TODO add your handling code here:
  306.     String keyword = keywordTextField.getText().trim();// 获得搜索关键字
  307.     String keywordArea = "";// 关键字的搜索范围
  308.     Enumeration<AbstractButton> elements = textButtonGroup.getElements();
  309.     while (elements.hasMoreElements()) {
  310.         JRadioButton radioButton = (JRadioButton) elements.nextElement();
  311.         if (radioButton.isSelected()) {
  312.             keywordArea = radioButton.getText();
  313.             break;
  314.         }
  315.     }
  316.     JTextField sortTextField = sortTreePanel.getTextField();// 获得类别文本框对象
  317.     String sort = (sortTextField.getText().length() > 0 ? sortTextField.getName() : null);// 获得搜索类别
  318.     String sortArea = "";// 类别的搜索范围
  319.     if (childTreeRadioButton.isSelected()) {
  320.         sortArea = "包含子类";
  321.     } else {
  322.         sortArea = "仅当前类";
  323.     }
  324.     if (appointRadioButton.isSelected()) {// 指定日期
  325.         String date = appointPanel.getTextField().getText();// 获得日期
  326.         String compare = compareComboBox.getSelectedItem().toString();// 获得比较条件
  327.         if (keyword.length() > 0 || sort != null || date.length() > 0) {// 输入了查询条件
  328.             dealWithSearchResult(
  329.                     dao.selectAppointSign(keyword, keywordArea, date, compare, sort, sortArea));
  330.         } else {// 未输入任何查询条件
  331.             JOptionPane.showMessageDialog(null, new String[]{"至少填写:", "        标记文本", 
  332.             "        创建日期", "        所属类别", "中的一个搜索条件!"}, "友情提示", 
  333.                     JOptionPane.INFORMATION_MESSAGE);
  334.         }
  335.     } else {// 一段时间
  336.         String startDate = spaceStartPanel.getTextField().getText();// 开始日期
  337.         String endDate = spaceEndPanel.getTextField().getText();// 结束日期
  338.         int sl = startDate.length();
  339.         int el = endDate.length();
  340.         if (sl * el != 0) {// 两个日期全部选择了
  341.             DateFormat df = DateFormat.getDateInstance();
  342.             Date sd = null;
  343.             Date ed = null;
  344.             try {
  345.                 sd = df.parse(startDate);
  346.                 ed = df.parse(endDate);
  347.             } catch (ParseException ex) {
  348.                 Logger.getLogger(AdvancedSearchDialog.class.getName()).log(Level.SEVERE, null, ex);
  349.             }
  350.             if (ed.before(sd)) {
  351.                 JOptionPane.showMessageDialog(null, "“终止日期”不能在“起始日期”之前,请重新选择!", "友情提示", JOptionPane.INFORMATION_MESSAGE);
  352.             } else {
  353.                 dealWithSearchResult(
  354.                         dao.selectSpaceSign(keyword, keywordArea, startDate, endDate, sort, sortArea));
  355.             }
  356.         } else {// 存在未选择的日期
  357.             if (sl + el != 0) {// 只选择了一个日期
  358.                 if (sl == 0) {// 未选择开始日期
  359.                     JOptionPane.showMessageDialog(null, "请填写“起始日期”!", "友情提示", JOptionPane.INFORMATION_MESSAGE);
  360.                 } else {// 未选择结束日期
  361.                     JOptionPane.showMessageDialog(null, "请填写“终止日期”!", "友情提示", JOptionPane.INFORMATION_MESSAGE);
  362.                 }
  363.             } else {// 未选择任何日期
  364.                 if (keyword.length() > 0 || sort != null) {// 输入了查询条件
  365.                     dealWithSearchResult(dao.selectAppointSign(keyword, keywordArea, "", "", sort, sortArea));
  366.                 } else {// 未输入任何查询条件
  367.                     JOptionPane.showMessageDialog(null, new String[]{"至少填写:", "        标记文本", "        创建日期", "        所属类别", "中的一个搜索条件!"}, "友情提示", JOptionPane.INFORMATION_MESSAGE);
  368.                 }
  369.             }
  370.         }
  371.     }
  372. }                                            
  373.     private void dealWithSearchResult(Vector<Vector> searchResult) {
  374.         this.searchResult.clear();
  375.         this.searchResult.addAll(searchResult);
  376.         if (searchResult.size() == 0) {
  377.             JOptionPane.showMessageDialog(null, "没有符合条件的标记!", "友情提示", JOptionPane.INFORMATION_MESSAGE);
  378.         } else {
  379.             final String[] items = new String[searchResult.size()];
  380.             for (int i = 0; i < items.length; i++) {
  381.                 items[i] = " " + (i + 1) + "、" + searchResult.get(i).get(4);
  382.             }
  383.             searchResultList.setModel(new javax.swing.AbstractListModel() {
  384.                 public int getSize() {
  385.                     return items.length;
  386.                 }
  387.                 public Object getElementAt(int i) {
  388.                     return items[i];
  389.                 }
  390.             });
  391.             setVisible(false);
  392.         }
  393.     }
  394. private void exitButtonActionPerformed(java.awt.event.ActionEvent evt) {                                           
  395. // TODO add your handling code here:
  396.     this.setVisible(false);
  397. }                                          
  398. private void clearButtonActionPerformed(java.awt.event.ActionEvent evt) {                                            
  399. // TODO add your handling code here:
  400.     keywordTextField.setText(null);
  401.     allRadioButton.setSelected(true);
  402.     appointRadioButton.setSelected(true);
  403.     appointPanel.setEnabled(true);
  404.     appointPanel.getTextField().setText(null);
  405.     compareComboBox.setSelectedIndex(0);
  406.     spaceStartPanel.setEnabled(false);
  407.     spaceStartPanel.getTextField().setText(null);
  408.     spaceEndPanel.setEnabled(false);
  409.     spaceEndPanel.getTextField().setText(null);
  410.     sortTreePanel.getTextField().setText(null);
  411.     childTreeRadioButton.setSelected(true);
  412.     keywordTextField.requestFocus();
  413. }                                           
  414.     /**
  415.      * @param args the command line arguments
  416.      */
  417.     public static void main(String args[]) {
  418.         java.awt.EventQueue.invokeLater(new Runnable() {
  419.             public void run() {
  420.                 AdvancedSearchDialog dialog = new AdvancedSearchDialog(new javax.swing.JFrame(), true, null, null);
  421.                 dialog.addWindowListener(new java.awt.event.WindowAdapter() {
  422.                     @Override
  423.                     public void windowClosing(java.awt.event.WindowEvent e) {
  424.                         System.exit(0);
  425.                     }
  426.                 });
  427.                 dialog.setVisible(true);
  428.             }
  429.         });
  430.     }
  431.     // Variables declaration - do not modify                     
  432.     private javax.swing.JRadioButton allRadioButton;
  433.     private com.mwq.map.calendar.CalendarPanel appointPanel;
  434.     private javax.swing.JRadioButton appointRadioButton;
  435.     private javax.swing.JRadioButton childTreeRadioButton;
  436.     private javax.swing.JButton clearButton;
  437.     private javax.swing.JComboBox compareComboBox;
  438.     private javax.swing.JRadioButton currentNodeRadioButton;
  439.     private javax.swing.JButton exitButton;
  440.     private javax.swing.JRadioButton explainRadioButton;
  441.     private javax.swing.JLabel jLabel1;
  442.     private javax.swing.JLabel jLabel2;
  443.     private javax.swing.JLabel keywordLabel;
  444.     private javax.swing.JTextField keywordTextField;
  445.     private javax.swing.JRadioButton nameRadioButton;
  446.     private javax.swing.JButton searchButton;
  447.     private javax.swing.ButtonGroup sortButtonGroup;
  448.     private javax.swing.JLabel sortLabel;
  449.     private javax.swing.JPanel sortPanel;
  450.     private com.mwq.map.mwing.MTreePanel sortTreePanel;
  451.     private com.mwq.map.calendar.CalendarPanel spaceEndPanel;
  452.     private javax.swing.JLabel spaceLabel;
  453.     private javax.swing.JRadioButton spaceRadioButton;
  454.     private com.mwq.map.calendar.CalendarPanel spaceStartPanel;
  455.     private javax.swing.ButtonGroup textButtonGroup;
  456.     private javax.swing.JPanel textPanel;
  457.     private javax.swing.ButtonGroup timeButtonGroup;
  458.     private javax.swing.JPanel timePanel;
  459.     // End of variables declaration                   
  460. }