shortcutcontainer.java

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

JAVA
155
字号
/**  * 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.util.shortcut;import objectxml.*;import java.util.Arrays;import javaexplorer.util.comparator.ShortcutComparator;/** * Conteneur de raccourci *@author     BOESCH Vincent *@created    21 janvier 2002 *@version    3.3 */public class ShortcutContainer extends Shortcut {    private Shortcut[] _shortcuts = null;    /**     *  Constructeur objet ShortcutContainer     */    public ShortcutContainer() {        super();    }    /**     *  Adds a feature to the Shortcut attribute     *  of the ShortcutContainer object     *     *@param  shortcut  The feature to be added     *      to the Shortcut attribute     */    public void addShortcut(Shortcut shortcut) {        if (shortcut == null) {            return;        }        if (_shortcuts == null) {            _shortcuts = new Shortcut[1];            _shortcuts[0] = shortcut;        } else {            int index = getShortcutIndex(shortcut.getTitle());            if (index != -1) {                _shortcuts[index] = shortcut;            } else {                Shortcut[] newSc = new Shortcut[_shortcuts.length + 1];                System.arraycopy(_shortcuts, 0, newSc, 0, _shortcuts.length);                newSc[newSc.length - 1] = shortcut;                _shortcuts = newSc;            }            Arrays.sort(_shortcuts, ShortcutComparator.getComparator());        }    }    /**     *  Gets the childCount attribute of the     *  ShortcutContainer object     *     *@return    The childCount value     */    public int getChildCount() {        return ((_shortcuts == null) ? 0 : _shortcuts.length);    }    /**     *  Gets the shortcut attribute of the     *  ShortcutContainer object     *     *@param  title  Description of the Parameter     *@return        The shortcut value     */    public Shortcut getShortcut(String title) {        int index = getShortcutIndex(title);        if (index == -1) {            return null;        }        return _shortcuts[index];    }    /**     *  Gets the shortcutAt attribute of the     *  ShortcutContainer object     *     *@param  index  Description of the Parameter     *@return        The shortcutAt value     */    public Shortcut getShortcutAt(int index) {        if ((index < 0) || (index > getChildCount())) {            return null;        }        return _shortcuts[index];    }    /**     *  Gets the shortcutIndex attribute of     *  the ShortcutContainer object     *     *@param  title  Description of the Parameter     *@return        The shortcutIndex value     */    public int getShortcutIndex(String title) {        if ((_shortcuts == null) || (title == null)) {            return -1;        }        for (int i = 0; i < _shortcuts.length; i++) {            if (title.equalsIgnoreCase(_shortcuts[i].getTitle())) {                return i;            }        }        return -1;    }    /**     *  Gets the shortcuts attribute of the     *  ShortcutContainer object     *     *@return    The shortcuts value     */    public Shortcut[] getShortcuts() {        return _shortcuts;    }    /**     *@param  title  Description of the Parameter     */    public void removeShortcut(String title) {        int index = getShortcutIndex(title);        //Shortcut non trouv

⌨️ 快捷键说明

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