Frequently nodes are created to represent DataObjects.
But they may also represent anything to be displayed to the user or manipulated programmatically,
even if they have no data directly stored behind them; for example, a control panel or debugger
breakpoint.

There are two listeners in this class: PropertyChangeListener
and NodeListener (which extends PropertyChangeListener). The first
is designed to listen on properties that can be returned from
getPropertySets(), the later for listening on changes in the
node itself (including the name, children, parent, set of properties,
icons, etc.). Be sure to distinguish between these two.

The node is cloneable. When a node is cloned, it is initialized
with an empty set of listeners and no parent. The display name and short description
are copied to the new node. The set of properties is shared.

Return a variant of the display name containing HTML markup
conforming to the limited subset of font-markup HTML supported by
the lightweight HTML renderer org.openide.awt.HtmlRenderer
(font color, bold, italic and strike-through supported; font
colors can be UIManager color keys if they are prefixed with
a ! character, i.e.

As the lookup needs to be constructed before Node's constructor is called,
it might not be obvious how to add Node or other objects into it without
type casting. Here is the recommended suggestion that uses public/private
pair of constructors:

publicMyNode(Childrench,FileObjectfile){this(ch, file,newInstanceContent());}/** A private constructor that takes an InstanceContent and * uses it as internals for the Node lookup and also allow us * to modify the content, for example by adding a reference * to the node itself or any other object we want to represent. * * @param ch children we wish to use * @param file sample object we wish to have in lookup * @param content the content created by the first constructor */privateMyNode(Childrench,FileObjectfile,InstanceContentcontent){super(ch,newAbstractLookup(content));// adds the node to our own lookupcontent.add(this);// adds additional items to the lookupcontent.add(file);}

Method Detail

clone

The default implementation checks whether the child list implements
Cloneable, and if so, it clones the children.
If the child list does not support cloning, Children.LEAF is used
instead for the children. The parent of this node is set to null and an empty set
of listeners is attached to the node.

cloneNode

Clone the node. The newly created node should reference the same
object as this node does, but it may be added as a child
to a different parent node. Also it should have an empty set of listeners.
In all other respects the node should behave exactly as the
original one does.

getContextActions

Get a special set of actions
for situations when this node is displayed as a context.

For example, right-clicking on a parent node in a hierarchical view (such as
the normal Explorer) should use getActions. However, if this node
is serving as the parent of a (say) a window tab full of icons (e.g., in
IconView), and the users right-clicks on
the empty space in this pane, then this method should be used to get
the appropriate actions for a context menu.

Note that in the Windows UI system, e.g., these action sets are quite different.

getPreferredAction

Gets the preferred action for this node.
This action can but need not to be one from the action array returned
from getActions(boolean).
In case it is, the context menu created from those actions
is encouraged to highlight the preferred action.
Override in subclasses accordingly.

getHtmlDisplayName

Return a variant of the display name containing HTML markup
conforming to the limited subset of font-markup HTML supported by
the lightweight HTML renderer org.openide.awt.HtmlRenderer
(font color, bold, italic and strike-through supported; font
colors can be UIManager color keys if they are prefixed with
a ! character, i.e. <font color='!controlShadow'>).
Enclosing <html> tags are not needed. If returning non-null, HTML
markup characters that should be literally rendered must be
escaped (> becomes &gt; and so forth).

This method should return either an HTML display name
or null; it should not return the non-HTML display name.

Note the specified foreground color has to have a high luminescence difference
to the background color in order to be used (displayed).
If not, the specified foreground color will be ignored and the default color will be used.
Luminescence of a color is calculated as following:
(Red value * 299 + Green value * 587 + Blue value * 114) / 1000
and the difference has to be greater or equal to 80.

Note there is no property corresponding to the HTML display name -
if it should change, a change in the display name should be fired; this
should not be a mechanism for returning anything other than a marked
up version of the return value of getDisplayName.

fireShortDescriptionChange

Allow subclasses that override the getShortDescription method to fire
the changes of the description by itself. Please notice that default
implementation of setShortDescription will fire the change by itself.