站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc 5.0.0

NodeOp (NetBeans Nodes API) - NetBeans API Javadoc 5.0.0

 

org.openide.nodes
Class NodeOp

java.lang.Object
  extended byorg.openide.nodes.NodeOp

public final class NodeOp
extends Object

Utility class for operations on nodes.


Method Summary
static int[] computePermutation(Node[] arr1, Node[] arr2)
          Compute a permutation between two arrays of nodes.
static String[] createPath(Node node, Node parent)
          Find a path (by name) from one node to the root or a parent.
static Action[] findActions(Node[] nodes)
          Asks the provided nodes for their actions and those that are common, to all of them returns.
static Node findChild(Node node, String name)
          Look for a node child of given name.
static JPopupMenu findContextMenu(Node[] nodes)
          Compute common menu for specified nodes.
static Node findPath(Node start, Enumeration names)
          Traverse a path from a parent node down, by an enumeration of names.
static Node findPath(Node start, String[] names)
          Traverse a path from a parent node down, by an enumeration of names.
static Node findRoot(Node node)
          Find the root for a given node.
static Node[] fromHandles(Node.Handle[] handles)
          Takes array of handles and creates array of nodes.
static SystemAction[] getDefaultActions()
          Deprecated. Do not use this method. It is useless now.
static boolean isSon(Node parent, Node son)
          Test whether the second node is a (direct) child of the first one.
static void setDefaultActions(SystemAction[] def)
          Deprecated. Useless.
static Node.Handle[] toHandles(Node[] nodes)
          Takes array of nodes and creates array of handles.
static NodeListener weakNodeListener(NodeListener l, Object source)
          Creates a weak implementation of NodeListener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getDefaultActions

public static SystemAction[] getDefaultActions()
Deprecated. Do not use this method. It is useless now.

Get the default actions for all nodes.

Returns:
array of default actions

setDefaultActions

public static void setDefaultActions(SystemAction[] def)
Deprecated. Useless.


findContextMenu

public static JPopupMenu findContextMenu(Node[] nodes)
Compute common menu for specified nodes. Provides only those actions supplied by all nodes in the list.

Parameters:
nodes - the nodes
Returns:
the menu for all nodes

findActions

public static Action[] findActions(Node[] nodes)
Asks the provided nodes for their actions and those that are common, to all of them returns.

Parameters:
nodes - array of nodes to compose actions for
Returns:
array of actions for the nodes or empty array if no actions were found
Since:
3.29

isSon

public static boolean isSon(Node parent,
                            Node son)
Test whether the second node is a (direct) child of the first one.

Parameters:
parent - parent node
son - son node
Returns:
true if so

createPath

public static String[] createPath(Node node,
                                  Node parent)
Find a path (by name) from one node to the root or a parent.

Parameters:
node - the node to start in
parent - parent node to stop in (can be null for the root)
Returns:
list of child names--i.e. a path from the parent to the child node
Throws:
IllegalArgumentException - if node's getName() method returns null

findChild

public static Node findChild(Node node,
                             String name)
Look for a node child of given name.

Parameters:
node - node to search in
name - name of child to look for
Returns:
the found child, or null if there is no such child

findPath

public static Node findPath(Node start,
                            Enumeration names)
                     throws NodeNotFoundException
Traverse a path from a parent node down, by an enumeration of names.

Parameters:
start - node to start searching at
names - enumeration of Strings containing names of nodes along the path
Returns:
the node with such a path from the start node
Throws:
NodeNotFoundException - if the node with such name does not exists; the exception contains additional information about the failure.

findPath

public static Node findPath(Node start,
                            String[] names)
                     throws NodeNotFoundException
Traverse a path from a parent node down, by an enumeration of names.

Parameters:
start - node to start searching at
names - names of nodes along the path
Returns:
the node with such a path from the start node
Throws:
NodeNotFoundException - if the node with such name does not exists; the exception contains additional information about the failure.

findRoot

public static Node findRoot(Node node)
Find the root for a given node.

Parameters:
node - the node
Returns:
its root

computePermutation

public static int[] computePermutation(Node[] arr1,
                                       Node[] arr2)
                                throws IllegalArgumentException
Compute a permutation between two arrays of nodes. The arrays must have the same size. The permutation then can be applied to the first array to create the second array.

Parameters:
arr1 - first array
arr2 - second array
Returns:
the permutation, or null if the arrays are the same
Throws:
IllegalArgumentException - if the arrays cannot be permuted to each other. Either they have different sizes or they do not contain the same elements.

toHandles

public static Node.Handle[] toHandles(Node[] nodes)
Takes array of nodes and creates array of handles. The nodes that do not have handles are not included in the resulting array.

Parameters:
nodes - array of nodes
Returns:
array of Node.Handles

fromHandles

public static Node[] fromHandles(Node.Handle[] handles)
                          throws IOException
Takes array of handles and creates array of nodes.

Parameters:
handles - array of handles
Returns:
array of nodes
Throws:
IOException - if a node cannot be created from the handle

weakNodeListener

public static NodeListener weakNodeListener(NodeListener l,
                                            Object source)
Creates a weak implementation of NodeListener.

Parameters:
l - the listener to delegate to
source - the source that the listener should detach from when listener l is freed, can be null
Returns:
a NodeListener delegating to l.
Since:
4.10

 

Built on May 3 2007.  |  Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.