ftptreenode.java

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

JAVA
195
字号
/**  * 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.ftp;import java.util.Enumeration;import java.util.Vector;import javaexplorer.util.ftp.*;import javax.swing.tree.TreeNode;public class FtpTreeNode implements TreeNode {    private Ftp _ftp;    private FtpTreeNode _parent;    /**     *  Constructeur objet FtpTreeNode     */    public FtpTreeNode() {    }    /**     *  Constructor for the JFileTreeNode object     *     *@param  ftp           Description of     *      the Parameter     */    public FtpTreeNode(Ftp ftp) {        super();        setFtp(ftp);    }    /**     *  Constructeur objet FtpTreeNode     *     *@param  ftp     Description of the Parameter     *@param  parent  Description of the Parameter     */    public FtpTreeNode(Ftp ftp, FtpTreeNode parent) {        super();        setFtp(ftp);        _parent = parent;    }    /**     *@return    Description of the Return     *      Value     */    public Enumeration children() {        if (!(_ftp instanceof FtpContainer)) {            return null;        }        Ftp[] tb_ftp = ((FtpContainer) _ftp).getFtps();        if (tb_ftp == null) {            return null;        }        Vector v = new Vector(5, 5);        for (int i = 0; i < tb_ftp.length; i++) {            v.addElement(new FtpTreeNode(tb_ftp[i]));        }        return v.elements();    }    /**     *  Gets the allowsChildren attribute of     *  the FtpTreeNode object     *     *@return    The allowsChildren value     */    public boolean getAllowsChildren() {        return (_ftp instanceof FtpContainer);    }    /**     *  Gets the childAt attribute of the FtpTreeNode     *  object     *     *@param  index  Description of the Parameter     *@return        The childAt value     */    public TreeNode getChildAt(int index) {        if ((index < 0) || (index > getChildCount())) {            return null;        }        return new FtpTreeNode(((FtpContainer) _ftp).getFtpAt(index), this);    }    /**     *  Gets the childCount attribute of the     *  FtpTreeNode object     *     *@return    The childCount value     */    public int getChildCount() {        if (isLeaf()) {            return 0;        }        return ((FtpContainer) _ftp).getChildCount();    }    /**     *  Gets the ftp attribute of the FtpTreeNode     *  object     *     *@return    The ftp value     */    public Ftp getFtp() {        return _ftp;    }    /**     *  Gets the index attribute of the FtpTreeNode     *  object     *     *@param  tn  Description of the Parameter     *@return     The index value     */    public int getIndex(TreeNode tn) {        if (!(tn instanceof FtpTreeNode)) {            return -1;        }        if (isLeaf()) {            return -1;        }        Ftp sc = ((FtpTreeNode) tn).getFtp();        return ((FtpContainer) _ftp).getFtpIndex(sc.getTitle());    }    /**     *  Gets the parent attribute of the FtpTreeNode     *  object     *     *@return    The parent value     */    public TreeNode getParent() {        return _parent;    }    /**     *  Gets the leaf attribute of the FtpTreeNode     *  object     *     *@return    The leaf value     */    public boolean isLeaf() {        return (!(_ftp instanceof FtpContainer));    }    /**     *  Sets the ftp attribute of the FtpTreeNode     *  object     *     *@param  ftp  The new ftp value     */    public void setFtp(Ftp ftp) {        _ftp = ftp;    }    /**     *@return    Description of the Return     *      Value     */    public String toString() {        return _ftp.getTitle();    }}

⌨️ 快捷键说明

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