⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 searchfilesdialog.java

📁 eq跨平台查询工具源码 eq跨平台查询工具源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * SearchFilesDialog.java * * Copyright (C) 2002, 2003, 2004, 2005, 2006 Takis Diakoumis * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. * */package org.executequery.search;import java.awt.Container;import java.awt.Dimension;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.Insets;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.io.File;import java.util.Vector;import javax.swing.BorderFactory;import javax.swing.DefaultComboBoxModel;import javax.swing.JButton;import javax.swing.JCheckBox;import javax.swing.JComboBox;import javax.swing.JDialog;import javax.swing.JFileChooser;import javax.swing.JLabel;import javax.swing.JList;import javax.swing.JPanel;import javax.swing.JScrollPane;import javax.swing.JTextArea;import javax.swing.ListSelectionModel;import org.executequery.Constants;import org.executequery.GUIUtilities;import org.underworldlabs.swing.DisabledField;import org.executequery.components.FileChooserDialog;/* ---------------------------------------------------------- * CVS NOTE: Changes to the CVS repository prior to the  *           release of version 3.0.0beta1 has meant a  *           resetting of CVS revision numbers. * ---------------------------------------------------------- *//** * * @author   Takis Diakoumis * @version  $Revision: 1.4 $ * @date     $Date: 2006/09/14 06:42:28 $ */public class SearchFilesDialog extends JDialogimplements FileSearchView {        /** The search text area */    private JTextArea findTextArea;    /** The replace text area */    private JTextArea replaceTextArea;    /** The file types combo box */    private JComboBox fileTypesCombo;    /** The search paths combo box */    private JComboBox pathCombo;    /** The match case check box */    private JCheckBox matchCaseCheck;    /** The replace check box */    private JCheckBox replaceCheck;    /** The whole words check box */    private JCheckBox wholeWordsCheck;    /** The search subdirs check box */    private JCheckBox searchSubdirsCheck;    /** The use regex check box */    private JCheckBox regexCheck;        /** The results area scroller */    private JScrollPane resultsScroll;    /** The results text area */    private JTextArea resultsTextArea;    /** The results list */    private JList resultsList;    /** The results summary bar */    private DisabledField resultsSummary;    /** The search utility performing the work */    private FileSearch fileSearch;        public SearchFilesDialog() {        super(GUIUtilities.getParentFrame(), "Search Files", false);                try {            jbInit();        } catch (Exception e) {            e.printStackTrace();        }                        pack();        this.setLocation(GUIUtilities.getLocationForDialog(this.getSize()));        setVisible(true);        requestFocus();        findTextArea.requestFocus();        findTextArea.setCaretPosition(0);    }        private void jbInit() throws Exception {        wholeWordsCheck = new JCheckBox("Whole words only", true);        matchCaseCheck = new JCheckBox("Match case");        searchSubdirsCheck = new JCheckBox("Search Subdirectories", true);        replaceCheck = new JCheckBox("Replace:");        regexCheck = new JCheckBox("Regular expressions");                findTextArea = new JTextArea();        findTextArea.setLineWrap(true);        findTextArea.setWrapStyleWord(true);        JScrollPane findScroll = new JScrollPane(findTextArea);                replaceTextArea = new JTextArea();        replaceTextArea.setLineWrap(true);        replaceTextArea.setWrapStyleWord(true);        JScrollPane replaceScroll = new JScrollPane(replaceTextArea);                Insets textAreaMargin = new Insets(2,2,2,2);        findTextArea.setMargin(textAreaMargin);        replaceTextArea.setMargin(textAreaMargin);                Dimension textAreaDim = new Dimension(200, 45);        findScroll.setPreferredSize(textAreaDim);        replaceScroll.setPreferredSize(textAreaDim);                replaceCheck.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent e) {                enableReplaceTextArea(replaceCheck.isSelected());            }        });                enableReplaceTextArea(false);                fileTypesCombo = new JComboBox(FileSearch.getTypesValues());        pathCombo = new JComboBox(FileSearch.getPathValues());        fileTypesCombo.setEditable(true);        pathCombo.setEditable(true);                Dimension comboDim = new Dimension(fileTypesCombo.getWidth(), 22);        fileTypesCombo.setPreferredSize(comboDim);        pathCombo.setPreferredSize(comboDim);                JButton browseButton = new JButton("Browse");        browseButton.setMargin(new Insets(0,0,0,0));        browseButton.setPreferredSize(new Dimension(85, 22));                JButton findButton = new JButton("Find");        JButton cancelButton = new JButton("Close");                findButton.setPreferredSize(Constants.BUTTON_SIZE);        cancelButton.setPreferredSize(Constants.BUTTON_SIZE);                resultsList = new JList();        resultsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);        resultsScroll = new JScrollPane(resultsList);        resultsScroll.setPreferredSize(textAreaDim);                /*        resultsTextArea = new JTextArea();        resultsTextArea.setEditable(false);        resultsTextArea.setMargin(new Insets(2,2,2,2));        resultsTextArea.setFont(new Font("monospaced", Font.PLAIN, 12));        */                resultsSummary = new DisabledField();        resultsSummary.setPreferredSize(new Dimension(100, 19));                JPanel panel = new JPanel(new GridBagLayout());        GridBagConstraints gbc = new GridBagConstraints();        gbc.insets = new Insets(5,5,5,5);        gbc.anchor = GridBagConstraints.NORTHWEST;        panel.add(new JLabel("Find:"), gbc);        gbc.gridx = 1;        gbc.gridwidth = 2;        gbc.fill = GridBagConstraints.BOTH;        gbc.insets.left = 0;        panel.add(findScroll, gbc);        gbc.gridy = 1;        panel.add(replaceScroll, gbc);        gbc.weighty = 0;        gbc.fill = GridBagConstraints.HORIZONTAL;        gbc.gridy = 2;        panel.add(fileTypesCombo, gbc);        gbc.gridy = 1;        gbc.gridx = 0;        gbc.weightx = 0;        gbc.gridwidth = 1;        gbc.fill = GridBagConstraints.NONE;        gbc.insets.left = 2;        panel.add(replaceCheck, gbc);        gbc.gridy = 2;        gbc.weightx = 0;        gbc.gridwidth = 1;        gbc.fill = GridBagConstraints.NONE;        gbc.insets.left = 5;        panel.add(new JLabel("File Types:"), gbc);        gbc.gridy = 3;        panel.add(new JLabel("Search Path:"), gbc);        gbc.gridx = 1;        gbc.fill = GridBagConstraints.HORIZONTAL;        gbc.insets.left = 0;        panel.add(pathCombo, gbc);        gbc.weightx = 0;        gbc.gridx = 2;        gbc.fill = GridBagConstraints.NONE;        panel.add(browseButton, gbc);                JPanel optionsPanel = new JPanel(new GridBagLayout());        optionsPanel.setBorder(BorderFactory.createTitledBorder("Options"));        gbc.insets.top = 0;        gbc.gridx = 0;        gbc.gridy = 0;        optionsPanel.add(matchCaseCheck, gbc);        gbc.gridx = 1;        gbc.insets.left = 20;        optionsPanel.add(searchSubdirsCheck, gbc);        gbc.gridx = 0;        gbc.gridy = 1;        gbc.insets.left = 0;        optionsPanel.add(wholeWordsCheck, gbc);        gbc.gridx = 1;        gbc.insets.left = 20;        optionsPanel.add(regexCheck, gbc);                gbc.gridy = 4;        gbc.gridx = 0;        gbc.fill = GridBagConstraints.BOTH;        gbc.insets.top = 5;        gbc.insets.left = 5;        gbc.gridwidth = GridBagConstraints.REMAINDER;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -