jefdirtreenode.java

来自「JavaExplorer是一个独立于平台的浏览器」· Java 代码 · 共 231 行

JAVA
231
字号
/**  * File and FTP Explorer  * Copyright 2002  * BOESCH Vincent  *  * 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 (at your option) 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 javaexplorer.gui.treenode.xfile;import java.util.*;import javaexplorer.model.*;import javaexplorer.util.filter.DirectoryFilter;import javax.swing.tree.*;public class JEFDirTreeNode extends AbstractEFTreeNode {    private static DirectoryFilter _df = new DirectoryFilter();    private Vector _lstChild = new Vector(5, 5);    private boolean exploreDone = false;    /**     *  Constructeur objet JEFDirTreeNode     */    public JEFDirTreeNode() {    }    /**     *  Constructeur objet JEFDirTreeNode     *     *@param  ef  Description of the Parameter     */    public JEFDirTreeNode(XFile ef) {        this(ef, true);    }    /**     *  Constructor for the JZipTreeNode object     *     *@param  ef       Description of the Parameter     *@param  explore  Description of the Parameter     */    public JEFDirTreeNode(XFile ef, boolean explore) {        try {            _ef = ef;            if (explore) {                makeChildrenNode(false);            }        } catch (Exception e) {            javaexplorer.util.Log.addError(e);        }    }    /**     *  Adds a feature to the Child attribute     *  of the JZipTreeNode object     *     *@param  e_ztn  The feature to be added     *      to the Child attribute     */    public void addChild(JEFDirTreeNode e_ztn) {        _lstChild.addElement(e_ztn);    }    /**     *  Description of the Method     *     *@return    Description of the Returned     *      Value     */    public Enumeration children() {        if (!exploreDone) {            makeChildrenNode(false);        }        return _lstChild.elements();    }    /**     *  Gets the AllowsChildren attribute of     *  the JZipTreeNode object     *     *@return    The AllowsChildren value     */    public boolean getAllowsChildren() {        return true;    }    /**     *  Gets the ChildAt attribute of the JZipTreeNode     *  object     *     *@param  childIndex  Description of Parameter     *@return             The ChildAt value     */    public TreeNode getChildAt(int childIndex) {        if (!exploreDone) {            makeChildrenNode(false);        }        return (JEFDirTreeNode) _lstChild.elementAt(childIndex);    }    /**     *  Gets the ChildCount attribute of the     *  JZipTreeNode object     *     *@return    The ChildCount value     */    public int getChildCount() {        if (!exploreDone) {            makeChildrenNode(false);        }        return _lstChild.size();    }    /**     *  Gets the Index attribute of the JZipTreeNode     *  object     *     *@param  node  Description of Parameter     *@return       The Index value     */    public int getIndex(TreeNode node) {        if (!exploreDone) {            makeChildrenNode(false);        }        return _lstChild.indexOf(node);    }    /**     *  Gets the Parent attribute of the JZipTreeNode     *  object     *     *@return    The Parent value     */    public TreeNode getParent() {        XFile ePar = _ef.getXParent();        if (ePar == null) {            return null;        }        return new JEFDirTreeNode(ePar, false);    }    /**     *  Gets the Leaf attribute of the JZipTreeNode     *  object     *     *@return    The Leaf value     */    public boolean isLeaf() {        return false;    }    /**     *  Description de la methode     *     *@param  explore  Description of the Parameter     */    private void makeChildrenNode(boolean explore) {        XFile[] eFiles = _ef.listXFiles(_df);        if (eFiles != null) {            for (int i = 0; i < eFiles.length; i++) {                addChild(new JEFDirTreeNode(eFiles[i], explore));            }        }        exploreDone = true;    }    /**     *  Description de la methode     */    public void refreshChildren() {        _lstChild.removeAllElements();        _ef.refreshChildren();                makeChildrenNode(false);    }    /**     *  Sets the exploreDone attribute of the     *  JEFDirTreeNode object     *     *@param  done  The new exploreDone value     */    public void setExploreDone(boolean done) {        exploreDone = done;    }    /**     *  Description of the Method     *     *@return    Description of the Returned     *      Value     */    public String toString() {        if (_ef == null) {            return "Null";        }        if (_ef.getXParent() == null) {            return _ef.toString();        }        return _ef.getName();    }        /**     * M閠hode permettant de renvoyer le noeud correspondant au XFile     * n閏essitant un rafraichissement     * Cette m閠hode n'explore que les noeuds d閖

⌨️ 快捷键说明

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