|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.beans.FeatureDescriptor | +--org.openide.nodes.Node
A node represents one element in a hierarchy of objects (beans). It provides all methods that are needed for communication between the IDE and the bean.
The node has three purposes:
Frequently nodes are created to represent data objects
.
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.
Inner Class Summary | |
static interface |
Node.Cookie
Marker interface for all cookies. |
static interface |
Node.Handle
Serializable node reference. |
static class |
Node.IndexedProperty
Description of an indexed property and operations on it. |
static class |
Node.Property
Description of a Bean property on a node, and operations on it. |
static class |
Node.PropertySet
Class that represents one set of properties. |
Field Summary | |
static Node |
EMPTY
An empty leaf node. |
static String |
PROP_COOKIE
Property for a node's cookie set. |
static String |
PROP_DISPLAY_NAME
Property for node display name. |
static String |
PROP_ICON
Property for the normal (closed) icon of a node. |
static String |
PROP_NAME
Property for internal (not displayable) name of a node. |
static String |
PROP_OPENED_ICON
Property for the opened icon of a node. |
static String |
PROP_PARENT_NODE
Property for a node's parent. |
static String |
PROP_PROPERTY_SETS
Property for a node's list of property sets. |
static String |
PROP_SHORT_DESCRIPTION
Property for short description of a node. |
Constructor Summary | |
protected |
Node(Children h)
Creates a new node with a given hierarchy of children. |
Method Summary | |
void |
addNodeListener(NodeListener l)
Add a listener to changes in the node's intrinsic properties (name, cookies, etc.). |
void |
addPropertyChangeListener(PropertyChangeListener l)
Add a listener to the node's computed Bean properties. |
abstract boolean |
canCopy()
Test whether this node permits copying. |
abstract boolean |
canCut()
Test whether this node permits cutting. |
abstract boolean |
canDestroy()
Test whether this node can be deleted. |
abstract boolean |
canRename()
Test whether this node can be renamed. |
abstract Transferable |
clipboardCopy()
Called when a node is to be copied to the clipboard. |
abstract Transferable |
clipboardCut()
Called when a node is to be cut to the clipboard. |
protected Object |
clone()
Implements Object.clone() to behave correctly if cloning is desired. |
abstract Node |
cloneNode()
Clone the node. |
void |
destroy()
Remove the node from its parent and deletes it. |
abstract Transferable |
drag()
Called when a drag is started with this node. |
protected void |
fireCookieChange()
Fires a change event for PROP_COOKIE . |
protected void |
fireDisplayNameChange(String o,
String n)
Allow subclasses that override the getDisplayName method to fire the changes of the name by itself. |
protected void |
fireIconChange()
Fire a change event for PROP_ICON . |
protected void |
fireNameChange(String o,
String n)
Allow subclasses that override the getName method to fire the changes of the name by itself. |
protected void |
fireNodeDestroyed()
To all node listeners fire node destroyed notification. |
protected void |
fireOpenedIconChange()
Fire a change event for PROP_OPENED_ICON . |
protected void |
firePropertyChange(String name,
Object o,
Object n)
Fire a property change event. |
protected void |
firePropertySetsChange(Node.PropertySet[] o,
Node.PropertySet[] n)
Fires a (Bean) property change event (for PROP_PROPERTY_SETS ). |
protected void |
fireShortDescriptionChange(String o,
String n)
Allow subclasses that override the getShortDescription method to fire the changes of the description by itself. |
SystemAction[] |
getActions()
Get the set of actions associated with this node. |
Children |
getChildren()
Get the list of children. |
SystemAction[] |
getContextActions()
Get a special set of actions for situations when this node is displayed as a context. |
JPopupMenu |
getContextMenu()
Make a context menu for this node. |
abstract Node.Cookie |
getCookie(Class type)
Get a cookie for this node. |
abstract Component |
getCustomizer()
Get the customizer component. |
abstract SystemAction |
getDefaultAction()
Get the default action for this node. |
abstract PasteType |
getDropType(Transferable t,
int action,
int index)
Determine if there is a paste operation that can be performed on provided transferable. |
abstract Node.Handle |
getHandle()
Obtain handle for this node (for serialization). |
abstract HelpCtx |
getHelpCtx()
Get context help associated with this node. |
abstract Image |
getIcon(int type)
Find an icon for this node (in the closed state). |
abstract NewType[] |
getNewTypes()
Get the new types that can be created in this node. |
abstract Image |
getOpenedIcon(int type)
Find an icon for this node (in the open state). |
Node |
getParentNode()
Get the parent node. |
abstract PasteType[] |
getPasteTypes(Transferable t)
Determine which paste operations are allowed when a given transferable is in the clipboard. |
abstract Node.PropertySet[] |
getPropertySets()
Get the list of property sets for this node. |
abstract boolean |
hasCustomizer()
Test whether there is a customizer for this node. |
protected boolean |
hasPropertyChangeListener()
Allows to figure out, whether the node has any PropertyChangeListeners attached. |
boolean |
isLeaf()
Test whether the node is a leaf, or may contain children. |
void |
removeNodeListener(NodeListener l)
Remove a node listener. |
void |
removePropertyChangeListener(PropertyChangeListener l)
Remove a Bean property change listener. |
void |
setDisplayName(String s)
Set the display name. |
void |
setName(String s)
Set the system name. |
void |
setShortDescription(String s)
Set the short description of the node. |
String |
toString()
|
Methods inherited from class java.beans.FeatureDescriptor |
attributeNames, getDisplayName, getName, getShortDescription, getValue, isExpert, isHidden, isPreferred, setExpert, setHidden, setPreferred, setValue |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final Node EMPTY
public static final String PROP_DISPLAY_NAME
public static final String PROP_NAME
public static final String PROP_SHORT_DESCRIPTION
public static final String PROP_ICON
public static final String PROP_OPENED_ICON
public static final String PROP_PARENT_NODE
public static final String PROP_PROPERTY_SETS
public static final String PROP_COOKIE
Constructor Detail |
protected Node(Children h) throws IllegalStateException
IllegalStateException
- if the hierarchy is already in use by
a different nodeMethod Detail |
protected Object clone() throws CloneNotSupportedException
Object.clone()
to behave correctly if cloning is desired.
But Cloneable
is not declared by default.
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.
clone
in class Object
CloneNotSupportedException
- if the children cannot be cloned
in spite of implementing Cloneable
public abstract Node cloneNode()
public void setName(String s)
setName
in class FeatureDescriptor
s
- the new nameIllegalArgumentException
- if the new name cannot represent
a valid node namepublic void setDisplayName(String s)
setDisplayName
in class FeatureDescriptor
s
- the new namepublic void setShortDescription(String s)
This description may be used for tool tips, etc.
setShortDescription
in class FeatureDescriptor
s
- the new descriptionpublic abstract Image getIcon(int type)
type
- constant from BeanInfo
public abstract Image getOpenedIcon(int type)
type
- constant from BeanInfo
public abstract HelpCtx getHelpCtx()
null
or HelpCtx.DEFAULT_HELP
)public final Children getChildren()
public final boolean isLeaf()
true
if the children list is actually Children.LEAF
public final Node getParentNode()
null
if this node is the root of a hierarchypublic abstract boolean canRename()
FeatureDescriptor.getName()
to obtain the current name and
setName(java.lang.String)
to change it.true
if the node can be renamedpublic abstract boolean canDestroy()
true
if canpublic void destroy() throws IOException
children's lock
, and removes
the node from its parent (if any). Also fires a property change.
This may be overridden by subclasses to do any additional cleanup.
IOException
- if something failspublic abstract Node.PropertySet[] getPropertySets()
public abstract Transferable clipboardCopy() throws IOException
IOException
- when the
copy cannot be performedpublic abstract Transferable clipboardCut() throws IOException
IOException
- when the
cut cannot be performedpublic abstract Transferable drag() throws IOException
IOException
- if a drag cannot be startedpublic abstract boolean canCopy()
true
if sopublic abstract boolean canCut()
true
if sopublic abstract PasteType[] getPasteTypes(Transferable t)
t
- the transferable in the clipboardpublic abstract PasteType getDropType(Transferable t, int action, int index)
t
- the transferableaction
- the drag'n'drop action to do DnDConstants.ACTION_MOVE, ACTION_COPY, ACTION_LINKindex
- index between children the drop occured at or -1 if not specifiedpublic abstract NewType[] getNewTypes()
public SystemAction[] getActions()
context menu
.
By default returns the actions in NodeOp.getDefaultActions()
.
public SystemAction[] getContextActions()
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 popup menu.
Note that in the Windows UI system, e.g., these action sets are quite different.
getActions()
.public abstract SystemAction getDefaultAction()
getActions()
. If so, the popup menu returned from getContextMenu()
is encouraged to highlight the action.null
if there should be nonepublic final JPopupMenu getContextMenu()
getActions()
.public abstract boolean hasCustomizer()
getCustomizer()
.true
if there is a customizerpublic abstract Component getCustomizer()
null
if there is no customizerpublic abstract Node.Cookie getCookie(Class type)
The set of cookies can change. If a node changes its set of
cookies, it fires a property change event with PROP_COOKIE
.
type
- the representation class of the cookienull
if this node has no such cookiepublic abstract Node.Handle getHandle()
Node.Handle.getNode()
used after
deserialization to obtain the original node.null
if this node is not persistablepublic final void addNodeListener(NodeListener l)
l
- the listener to addpublic final void removeNodeListener(NodeListener l)
l
- the listenerpublic final void addPropertyChangeListener(PropertyChangeListener l)
l
- the listenerprotected final boolean hasPropertyChangeListener()
public final void removePropertyChangeListener(PropertyChangeListener l)
l
- the listenerprotected final void firePropertyChange(String name, Object o, Object n)
name
- name of changed property (from getPropertySets()
)o
- old valuen
- new valueprotected final void fireNameChange(String o, String n)
protected final void fireDisplayNameChange(String o, String n)
protected final void fireShortDescriptionChange(String o, String n)
protected final void fireIconChange()
PROP_ICON
.protected final void fireOpenedIconChange()
PROP_OPENED_ICON
.protected final void fireNodeDestroyed()
protected final void firePropertySetsChange(Node.PropertySet[] o, Node.PropertySet[] n)
PROP_PROPERTY_SETS
).o
- the old setn
- the new setprotected final void fireCookieChange()
PROP_COOKIE
.
The old and new values are set to null.public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |