public final class NodeOp extends Object
Since version 7.9 this class supports creation of a lazy node - a node that displays basic information about the original node behind it, without touching the original. As soon as the node is expanded, or a pop up menu is invoked on it, it switches to the real delegates and since then everything is being bridged to the real node. This method is especially useful when used from layers. Use following XML snippet to register your node into Services tab:
<folder name="UI"> <folder name="Runtime"> <file name="org-yourorg-yourpgk-YourNode.instance"> <attr name="instanceCreate" methodvalue="org.openide.nodes.NodeOp.factory"/> <attr name="name" stringvalue="YourNode"/> <attr name="displayName" bundlevalue="org.yourorg.yourpkg.Bundle#NAME-KEY"/> <attr name="shortDescription" bundlevalue="org.yourorg.yourpkg.Bundle#SHORT-KEY"/> <attr name="iconResource" stringvalue="org/yourorg/yourpkg/image.png"/> <attr name="original" newvalue="org.yourorg.yourpkg.YourNode"/> <file/> <folder/> <folder/>
Modifier and Type | Method and Description |
---|---|
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)
Computes a common popup menu for the specified nodes.
|
static Node |
findPath(Node start,
Enumeration<String> 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 |
registerPropertyEditors()
Registers Property Editors and sets the Property Editors search path.
|
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.
|
@Deprecated public static SystemAction[] getDefaultActions()
@Deprecated public static void setDefaultActions(SystemAction[] def)
public static JPopupMenu findContextMenu(Node[] nodes)
Component action maps are not taken into consideration.
Utilities.actionsToPopup(Action[], Component)
is a better choice
if you want to use actions such as "Paste" which look at action maps.
nodes
- the nodespublic static Action[] findActions(Node[] nodes)
nodes
- array of nodes to compose actions forpublic static boolean isSon(Node parent, Node son)
parent
- parent nodeson
- son nodetrue
if sopublic static String[] createPath(Node node, Node parent)
node
- the node to start inparent
- parent node to stop in (can be null
for the root)IllegalArgumentException
- if node
's getName()
method returns null
public static Node findChild(Node node, String name)
node
- node to search inname
- name of child to look fornull
if there is no such childpublic static Node findPath(Node start, Enumeration<String> names) throws NodeNotFoundException
start
- node to start searching atnames
- enumeration of names of nodes
along the pathNodeNotFoundException
- if the node with such name
does not exists; the exception contains additional information
about the failure.public static Node findPath(Node start, String[] names) throws NodeNotFoundException
start
- node to start searching atnames
- names of nodes
along the pathNodeNotFoundException
- if the node with such name
does not exists; the exception contains additional information
about the failure.public static Node findRoot(Node node)
node
- the nodepublic static int[] computePermutation(Node[] arr1, Node[] arr2) throws IllegalArgumentException
arr1
- first arrayarr2
- second arraynull
if the arrays are the sameIllegalArgumentException
- if the arrays cannot be permuted to each other. Either
they have different sizes or they do not contain the same elements.public static Node.Handle[] toHandles(Node[] nodes)
nodes
- array of nodespublic static Node[] fromHandles(Node.Handle[] handles) throws IOException
handles
- array of handlesIOException
- if a node cannot be created from the handlepublic static NodeListener weakNodeListener(NodeListener l, Object source)
l
- the listener to delegate tosource
- the source that the listener should detach from when
listener l
is freed, can be null
l
.public static void registerPropertyEditors()
PropertyEditorSearchPath
,
PropertyEditorRegistration