⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 defaulttreeselectionmodel.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* DefaultTreeSelectionModel.java    Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.   This file is part of GNU Classpath.GNU Classpath is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version.GNU Classpath is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU Classpath; see the file COPYING.  If not, write to theFree Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA02110-1301 USA.Linking this library statically or dynamically with other modules ismaking a combined work based on this library.  Thus, the terms andconditions of the GNU General Public License cover the wholecombination.As a special exception, the copyright holders of this library give youpermission to link this library with independent modules to produce anexecutable, regardless of the license terms of these independentmodules, and to copy and distribute the resulting executable underterms of your choice, provided that you also meet, for each linkedindependent module, the terms and conditions of the license of thatmodule.  An independent module is a module which is not derived fromor based on this library.  If you modify this library, you may extendthis exception to your version of the library, but you are notobligated to do so.  If you do not wish to do so, delete thisexception statement from your version. */package javax.swing.tree;import java.beans.PropertyChangeListener;import java.io.IOException;import java.io.ObjectInputStream;import java.io.ObjectOutputStream;import java.io.Serializable;import java.util.EventListener;import java.util.Vector;import javax.swing.DefaultListSelectionModel;import javax.swing.event.EventListenerList;import javax.swing.event.SwingPropertyChangeSupport;import javax.swing.event.TreeSelectionEvent;import javax.swing.event.TreeSelectionListener;/** * DefaultTreeSelectionModel *  * @author Andrew Selkirk */public class DefaultTreeSelectionModel		implements Cloneable, Serializable, TreeSelectionModel{	static final long serialVersionUID = 3288129636638950196L;	/**	 * SELECTION_MODE_PROPERTY	 */	public static final String SELECTION_MODE_PROPERTY = "selectionMode";	/**	 * Our Swing property change support.	 */	protected SwingPropertyChangeSupport changeSupport;	/**	 * The current selection.	 */	protected TreePath[] selection;	/**	 * Our TreeSelectionListeners.	 */	protected EventListenerList listenerList;	/**	 * The current RowMapper.	 */	protected transient RowMapper rowMapper;	/**	 * The current listSelectionModel.	 */	protected DefaultListSelectionModel listSelectionModel;	/**	 * The current selection mode.	 */	protected int selectionMode;	/**	 * The path that has been added last.	 */	protected TreePath leadPath;	/**	 * The index of the last added path.	 */	protected int leadIndex;	/**	 * The row of the last added path according to the RowMapper.	 */	protected int leadRow;	/**	 * Constructs a new DefaultTreeSelectionModel.	 */	public DefaultTreeSelectionModel()	{		setSelectionMode(SINGLE_TREE_SELECTION);		listenerList = new EventListenerList();	}	/**	 * Creates a clone of this DefaultTreeSelectionModel with the same	 * selection.	 * 	 * @exception CloneNotSupportedException should not be thrown here	 * 	 * @return a clone of this DefaultTreeSelectionModel	 */	public Object clone() throws CloneNotSupportedException	{		return null; // TODO	}	/**	 * Returns a string that shows this object's properties.	 * 	 * @return a string that shows this object's properties	 */	public String toString()	{		return null; // TODO	}	/**	 * writeObject	 * 	 * @param value0 TODO	 * @exception IOException TODO	 */	private void writeObject(ObjectOutputStream value0) throws IOException	{		// TODO	}	/**	 * readObject	 * 	 * @param value0 TODO	 * @exception IOException TODO	 * @exception ClassNotFoundException TODO	 */	private void readObject(ObjectInputStream value0) throws IOException,			ClassNotFoundException	{		// TODO	}	/**	 * Sets the RowMapper that should be used to map between paths and their	 * rows.	 * 	 * @param rowMapper the RowMapper to set	 * 	 * @see RowMapper	 */	public void setRowMapper(RowMapper rowMapper)	{		// TODO	}	/**	 * Returns the RowMapper that is currently used to map between paths and	 * their rows.	 * 	 * @return the current RowMapper	 * 	 * @see RowMapper	 */	public RowMapper getRowMapper()	{		return rowMapper;	}	/**	 * Sets the current selection mode. Possible values are	 * {@link #SINGLE_TREE_SELECTION}, {@link #CONTIGUOUS_TREE_SELECTION} and	 * {@link #DISCONTIGUOUS_TREE_SELECTION}.	 * 	 * @param mode the selection mode to be set	 * 	 * @see #getSelectionMode	 * @see #SINGLE_TREE_SELECTION	 * @see #CONTIGUOUS_TREE_SELECTION	 * @see #DISCONTIGUOUS_TREE_SELECTION	 */	public void setSelectionMode(int mode)	{		selectionMode = mode;	}	/**	 * Returns the current selection mode.	 * 	 * @return the current selection mode	 * 	 * @see #setSelectionMode	 * @see #SINGLE_TREE_SELECTION	 * @see #CONTIGUOUS_TREE_SELECTION	 * @see #DISCONTIGUOUS_TREE_SELECTION	 */	public int getSelectionMode()	{		return selectionMode;	}	/**	 * Sets this path as the only selection.	 * 	 * If this changes the selection the registered TreeSelectionListeners are	 * notified.	 * 	 * @param path the path to set as selection	 */	public void setSelectionPath(TreePath path)	{		selection = new TreePath[] {			path };	}	/**	 * Sets the paths as selection. This method checks for duplicates and	 * removes them.	 * 	 * If this changes the selection the registered TreeSelectionListeners are	 * notified.	 * 	 * @param paths the paths to set as selection	 */	public void setSelectionPaths(TreePath[] paths)	{		// TODO	}	/**	 * Adds a path to the list of selected paths. This method checks if the path	 * is already selected and doesn't add the same path twice.	 * 	 * If this changes the selection the registered TreeSelectionListeners are	 * notified.	 * 	 * @param path the path to add to the selection	 */	public void addSelectionPath(TreePath path)	{		if (!isPathSelected(path))		{			if (isSelectionEmpty())				setSelectionPath(path);			else			{				TreePath[] temp = new TreePath[selection.length + 1];				System.arraycopy(selection, 0, temp, 0, selection.length);				temp[temp.length - 1] = path;				selection = new TreePath[temp.length];				System.arraycopy(temp, 0, selection, 0, temp.length);			}			leadPath = path;			fireValueChanged(new TreeSelectionEvent(this, path, true,					leadPath, path));		}	}	/**	 * Adds the paths to the list of selected paths. This method checks if the	 * paths are already selected and doesn't add the same path twice.	 * 	 * If this changes the selection the registered TreeSelectionListeners are	 * notified.	 * 	 * @param paths the paths to add to the selection	 */	public void addSelectionPaths(TreePath[] paths)	{		if (paths != null)		{			TreePath v0 = null;			for (int i = 0; i < paths.length; i++)			{				v0 = paths[i];				if (!isPathSelected(v0))				{					if (isSelectionEmpty())						setSelectionPath(v0);					else					{						TreePath[] temp = new TreePath[selection.length + 1];						System.arraycopy(selection, 0, temp, 0,								selection.length);						temp[temp.length - 1] = v0;						selection = new TreePath[temp.length];						System.arraycopy(temp, 0, selection, 0, temp.length);					}					leadPath = paths[paths.length - 1];					fireValueChanged(new TreeSelectionEvent(this, v0, true,							leadPath, paths[0]));				}			}		}	}	/**	 * Removes the path from the selection.	 * 	 * If this changes the selection the registered TreeSelectionListeners are	 * notified.	 * 	 * @param path the path to remove	 */	public void removeSelectionPath(TreePath path)	{		int index = -1;		if (isPathSelected(path))		{			for (int i = 0; i < selection.length; i++)			{				if (selection[i].equals(path))				{					index = i;					break;				}			}			TreePath[] temp = new TreePath[selection.length - 1];			System.arraycopy(selection, 0, temp, 0, index);			System.arraycopy(selection, index + 1, temp, index,					selection.length - index - 1);			selection = new TreePath[temp.length];			System.arraycopy(temp, 0, selection, 0, temp.length);			fireValueChanged(new TreeSelectionEvent(this, path, false,					leadPath, path));		}	}	/**	 * Removes the paths from the selection.	 * 	 * If this changes the selection the registered TreeSelectionListeners are	 * notified.	 * 	 * @param paths the paths to remove	 */	public void removeSelectionPaths(TreePath[] paths)	{		if (paths != null)		{			int index = -1;			TreePath v0 = null;			for (int i = 0; i < paths.length; i++)			{				v0 = paths[i];				if (isPathSelected(v0))				{					for (int x = 0; x < selection.length; x++)					{						if (selection[i].equals(v0))						{

⌨️ 快捷键说明

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