shortcuttreenode.java
来自「JavaExplorer是一个独立于平台的浏览器」· Java 代码 · 共 198 行
JAVA
198 行
/** * 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.shortcut;import java.util.Enumeration;import java.util.Vector;import javaexplorer.util.shortcut.*;import javax.swing.tree.TreeNode;public class ShortcutTreeNode implements TreeNode { private ShortcutTreeNode _parent; private Shortcut _shortcut; /** * Constructeur objet ShortcutTreeNode */ public ShortcutTreeNode() { } /** * Constructor for the JFileTreeNode object * *@param shortcut Description of * the Parameter */ public ShortcutTreeNode(Shortcut shortcut) { super(); setShortcut(shortcut); } /** * Constructeur objet ShortcutTreeNode * *@param shortcut Description of the * Parameter *@param parent Description of the * Parameter */ public ShortcutTreeNode(Shortcut shortcut, ShortcutTreeNode parent) { super(); setShortcut(shortcut); _parent = parent; } /** *@return Description of the Return * Value */ public Enumeration children() { if (!(_shortcut instanceof ShortcutContainer)) { return null; } Shortcut[] tb_shortcut = ((ShortcutContainer) _shortcut).getShortcuts(); if (tb_shortcut == null) { return null; } Vector v = new Vector(5, 5); for (int i = 0; i < tb_shortcut.length; i++) { v.addElement(new ShortcutTreeNode(tb_shortcut[i])); } return v.elements(); } /** * Gets the allowsChildren attribute of * the ShortcutTreeNode object * *@return The allowsChildren value */ public boolean getAllowsChildren() { return (_shortcut instanceof ShortcutContainer); } /** * Gets the childAt attribute of the ShortcutTreeNode * 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 ShortcutTreeNode(((ShortcutContainer) _shortcut).getShortcutAt( index), this); } /** * Gets the childCount attribute of the * ShortcutTreeNode object * *@return The childCount value */ public int getChildCount() { if (isLeaf()) { return 0; } return ((ShortcutContainer) _shortcut).getChildCount(); } /** * Gets the index attribute of the ShortcutTreeNode * object * *@param tn Description of the Parameter *@return The index value */ public int getIndex(TreeNode tn) { if (!(tn instanceof ShortcutTreeNode)) { return -1; } if (isLeaf()) { return -1; } Shortcut sc = ((ShortcutTreeNode) tn).getShortcut(); return ((ShortcutContainer) _shortcut).getShortcutIndex(sc.getTitle()); } /** * Gets the parent attribute of the ShortcutTreeNode * object * *@return The parent value */ public TreeNode getParent() { return _parent; } /** * Gets the shortcut attribute of the * ShortcutTreeNode object * *@return The shortcut value */ public Shortcut getShortcut() { return _shortcut; } /** * Gets the leaf attribute of the ShortcutTreeNode * object * *@return The leaf value */ public boolean isLeaf() { return (!(_shortcut instanceof ShortcutContainer)); } /** * Sets the shortcut attribute of the * ShortcutTreeNode object * *@param shortcut The new shortcut value */ public void setShortcut(Shortcut shortcut) { _shortcut = shortcut; } /** *@return Description of the Return * Value */ public String toString() { return _shortcut.getTitle(); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?