jsearchdisk.java

来自「JavaExplorer是一个独立于平台的浏览器」· Java 代码 · 共 526 行 · 第 1/2 页

JAVA
526
字号
    }    /**     *  Description of the Method     */    public void init() {        XFileTreeNode xftn = null;        if (_xroot != null) {            xftn = new JEFDirTreeNode(_xroot);            jTree1.setRootVisible(true);        } else {            xftn = new JExplorerEFTreeNode(_launcher);        }        jTree1.setModel(new ExtendedTreeModel(xftn));    }    /**     *  Description of the Method     *     *@param  e  Description of Parameter     */    private void xtable_mouseClicked(MouseEvent e) {        if ((e.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) {            int index = xtable.rowAtPoint(e.getPoint());            if (xtable.isRowSelected(index)) {                _launcher.getMDIModel().makeXFilesPopup(getSelectedEntries(),                    (int) xtable.getLocationOnScreen().getX() + e.getX(),                    (int) xtable.getLocationOnScreen().getY() + e.getY());            } else {                if (index != -1) {                    XFile xf = (XFile) xtable.getValueAt(index, 0);                    _launcher.getMDIModel().makeXFilesPopup(new XFile[] { xf },                        (int) xtable.getLocationOnScreen().getX() + e.getX(),                        (int) xtable.getLocationOnScreen().getY() + e.getY());                }            }            return;        }        if (e.getClickCount() == 2) {            _launcher.getFileModel().processXFileBuffer(getSelectedEntries());        }    }    /**     *  Description of the Method     *     *@exception  Exception  Description of     *      Exception     */    private void jbInit() throws Exception {        titledBorder2 = new TitledBorder("");        setLayout(borderLayout1);        titledBorder1 = new TitledBorder("");        border1 = BorderFactory.createLineBorder(new Color(153, 153, 153), 2);        border2 = BorderFactory.createLineBorder(new Color(153, 153, 153), 2);        JPanelSearchCriteria.setLayout(new GridLayout(0, 1)); ///borderLayout2);        JPanelSearchCriteriaFileName.setLayout(new BorderLayout());        JPanelSearchCriteriaFileContents.setLayout(new BorderLayout());        JPanelSearchCriteriaFileContents.add(BorderLayout.CENTER,            JTextFieldSearchForText);        JCheckBoxMatchCase.setText(" " + TextRessource.SEARCHSCREEN_MATCH_CASE +            " ");        JPanelSearchCriteriaFileContents.add(BorderLayout.EAST,            JCheckBoxMatchCase);        JLabelSearchForText.setText(" " + TextRessource.SEARCHSCREEN_FIND_TEXT +            " ");        JPanelSearchCriteriaFileContents.add(BorderLayout.WEST,            JLabelSearchForText);        JPanelSearchCriteriaFileDate.setLayout(new GridLayout(1, 0));        JLabelDateFrom.setText(" " + TextRessource.SEARCHSCREEN_FROM_DATE +            " ");        JPanelSearchCriteriaFileDate.add(JLabelDateFrom);        JTextFieldFromDate.setToolTipText(TextRessource.SEARCHSCREEN_LEAVE_BLANK_TOOLTIPTEXT);        JPanelSearchCriteriaFileDate.add(JTextFieldFromDate);        JLabelDateTo.setText(" " + TextRessource.SEARCHSCREEN_TO_DATE + " ");        JPanelSearchCriteriaFileDate.add(JLabelDateTo);        JTextFieldToDate.setToolTipText(TextRessource.SEARCHSCREEN_LEAVE_BLANK_TOOLTIPTEXT);        JPanelSearchCriteriaFileDate.add(JTextFieldToDate);        JTextFieldFileCriteria.setText("*.*");        JTextFieldFileCriteria.addActionListener(this);        JButtonSearch.setText(TextRessource.SEARCHSCREEN_SEARCH);        JButtonSearch.addActionListener(this);        JPanelSearchCriteriaFileName.setBorder(border1);        JPanelSearchCriteriaFileContents.setBorder(border2);        JPanelSearchCriteria.add(JPanelSearchCriteriaFileName);        JPanelSearchCriteria.add(JPanelSearchCriteriaFileContents);        JPanelSearchCriteria.add(JPanelSearchCriteriaFileDate);        jLabel1.setText("");        JPanelSearchResults.setLayout(borderLayout3);        JPanelTab1Main.setLayout(borderLayout4);        xtable.addMouseListener(new java.awt.event.MouseAdapter() {                /**                 *  Description of the Method                 *                 *@param  e  Description of Parameter                 */                public void mouseClicked(MouseEvent e) {                    xtable_mouseClicked(e);                }            });        JLabelStatus.setText(TextRessource.SEARCHSCREEN_ELEMENTS_FOUND);        jScrollPane2.setBorder(BorderFactory.createEtchedBorder());        borderLayout3.setHgap(5);        borderLayout3.setVgap(5);        add(jTabbedPane1, BorderLayout.CENTER);        jTabbedPane1.add(JPanelTab1Main, TextRessource.SEARCHSCREEN_CRITERIA);        JPanelTab1Main.add(JPanelSearchCriteria, BorderLayout.NORTH);        JPanelSearchCriteriaFileName.add(JTextFieldFileCriteria,            BorderLayout.CENTER);        JPanelSearchCriteriaFileName.add(JButtonSearch, BorderLayout.EAST);        JPanelTab1Main.add(jLabel1, BorderLayout.SOUTH);        JPanelTab1Main.add(jScrollPane1, BorderLayout.CENTER);        jTabbedPane1.add(JPanelSearchResults, TextRessource.SEARCHSCREEN_RESULT);        JPanelSearchResults.add(jScrollPane2, BorderLayout.CENTER);        JPanelSearchResults.add(BorderLayout.NORTH, JLabelStatus);        jTree1.setRootVisible(false);        jTree1.setCellRenderer(new XFileTreeCellRenderer());    }    /**     *@param  f  Description of the Parameter     */    public void refreshView(XFile f) {        if (f == null) {            return;        }        if (f.exists()) {            return;        }    }    /**     *  Main processing method for the JSearchDisk     *  object     */    public void run() {        xtable.removeAll();        cf.clearFilters();        JLabelStatus.setText(TextRessource.SEARCHSCREEN_PERFORMING_SEARCH +            " : " + TextRessource.SEARCHSCREEN_ELEMENTS_FOUND + " " + 0);        JButtonSearch.setText(TextRessource.SEARCHSCREEN_STOP);        String filter = JTextFieldFileCriteria.getText();        if (filter != null) {            StringTokenizer st = new StringTokenizer(filter, ";");            while (st.hasMoreTokens()) {                cf.addFilter(st.nextToken());            }            //Parcours des entr閑s s閘ectionn閑s :            TreePath[] tb_tp = jTree1.getSelectionPaths();            if (tb_tp != null) {                for (int i = 0; (i < tb_tp.length) && !_booSearchStopped;                        i++) {                    XFile f = ((XFileTreeNode) tb_tp[i].getLastPathComponent()).getXFile();                    addRecursive(f);                }            }        }        JLabelStatus.setText(TextRessource.SEARCHSCREEN_ELEMENTS_FOUND + " " +            xtable.getElementCount());        JButtonSearch.setText(TextRessource.SEARCHSCREEN_SEARCH);        _booSearchStopped = true;        threadSearcher = null;    }    /**     *  Sets the launcher attribute of the     *  JSearchDisk object     *     *@param  launcher  The new launcher value     */    public void setLauncher(Launcher launcher) {        _launcher = launcher;    }    /**    * This method returns a Calendar when given a JDBC formatted date string (i.e., YYYY-MM-DD).    * @param  the formatted date string    * @return   calendar    the calendar input    */    public static java.util.Calendar getCalendarDate(String JDBCDateString)        throws Exception {        java.util.Calendar calendar = java.util.Calendar.getInstance();        int Year = (new Integer(JDBCDateString.substring(0, 4))).intValue();        int Month = (new Integer(JDBCDateString.substring(5, 7))).intValue();        int DayOfMonth = (new Integer(JDBCDateString.substring(8, 10))).intValue();        calendar.set(java.util.Calendar.YEAR, Year);        calendar.set(java.util.Calendar.MONTH, Month - 1);        calendar.set(java.util.Calendar.DAY_OF_MONTH, DayOfMonth);        calendar.set(java.util.Calendar.HOUR_OF_DAY, 0);        calendar.set(java.util.Calendar.MINUTE, 0);        calendar.set(java.util.Calendar.SECOND, 0);        return calendar;    }    /**     *  Description of the Method     *     */    private void startStopSearch() {        if (_booSearchStopped) {            if ((JTextFieldFromDate.getText().length() > 0) ||                    (JTextFieldToDate.getText().length() > 0)) {                try {                    DateFrom = new java.util.Date(getCalendarDate(                                JTextFieldFromDate.getText()).getTime().getTime());                    java.util.Calendar DateToAtMidnight = getCalendarDate(JTextFieldToDate.getText());                    DateToAtMidnight.add(java.util.Calendar.DATE, 1);                    DateTo = new java.util.Date(DateToAtMidnight.getTime()                                                                .getTime());                    UseDateRange = true;                } catch (Exception exd) {                    javax.swing.JOptionPane.showMessageDialog(this,                        TextRessource.SEARCHSCREEN_DATE_FORMAT_MESSAGE); //"Date format should be yyyy-mm-dd");                    return;                }            } else {                UseDateRange = false;            }            SearchContents = (JTextFieldSearchForText.getText().length() > 0);            if (JCheckBoxMatchCase.isSelected()) {                SearchString = JTextFieldSearchForText.getText();            } else {                SearchString = JTextFieldSearchForText.getText().toLowerCase();            }        }        _booSearchStopped = !_booSearchStopped;        if ((threadSearcher != null) && threadSearcher.isAlive()) {            try {                threadSearcher.join();            } catch (Exception ex) {                ex.printStackTrace();            }            JButtonSearch.setText(TextRessource.SEARCHSCREEN_SEARCH);        } else {            threadSearcher = new Thread(this);            threadSearcher.setPriority(Thread.MIN_PRIORITY);            threadSearcher.start();        }    }}

⌨️ 快捷键说明

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