T
- the type of bean to be representedpublic class BeanNode<T> extends AbstractNode
Represents a JavaBeans component as a node.
You may use this node type for an already-existing JavaBean (possibly using BeanContext) in order for its JavaBean properties to be reflected as corresponding node properties. Thus, it serves as a compatibility wrapper.
The bean passed in the constructor will be available in the node's lookup,
though not directly. Instead, the node's Lookup
will contain
an InstanceCookie
from which you can retrieve the bean instance.
Modifier and Type | Class and Description |
---|---|
static class |
BeanNode.Descriptor
Descriptor of three types of properties.
|
Node.Cookie, Node.Handle, Node.IndexedProperty<T,E>, Node.Property<T>, Node.PropertySet
displayFormat, systemActions
EMPTY, PROP_COOKIE, PROP_DISPLAY_NAME, PROP_ICON, PROP_LEAF, PROP_NAME, PROP_OPENED_ICON, PROP_PARENT_NODE, PROP_PROPERTY_SETS, PROP_SHORT_DESCRIPTION
Modifier | Constructor and Description |
---|---|
|
BeanNode(T bean)
Constructs a node for a JavaBean.
|
protected |
BeanNode(T bean,
Children children)
Constructs a node for a JavaBean with a defined child list.
|
protected |
BeanNode(T bean,
Children children,
Lookup lkp)
Constructs a node for a JavaBean.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canCopy()
Can this node be copied?
|
boolean |
canCut()
Can this node be cut?
|
boolean |
canDestroy()
Can this node be removed?
|
boolean |
canRename()
Can this node be renamed?
|
static BeanNode.Descriptor |
computeProperties(Object bean,
BeanInfo info)
Computes a descriptor for properties from a bean info.
|
protected void |
createProperties(T bean,
BeanInfo info)
Prepare node properties based on the bean, storing them into the current property sheet.
|
void |
destroy()
Detaches all listeners from the bean and destroys it.
|
Action[] |
getActions(boolean context)
Get the set of actions that are associated with this node.
|
protected T |
getBean()
Provides access to the bean represented by this BeanNode.
|
Component |
getCustomizer()
Get the customizer.
|
HelpCtx |
getHelpCtx()
Get context help associated with this node.
|
Image |
getIcon(int type)
Get an icon for this node in the closed state.
|
Image |
getOpenedIcon(int type)
Get an icon for this node in the open state.
|
Action |
getPreferredAction()
Gets preferred action.
|
boolean |
hasCustomizer()
Does this node have a customizer?
|
void |
setName(String s)
Set the node name.
|
protected void |
setSynchronizeName(boolean watch)
Set whether or not to keep the node name and Bean name synchronized automatically.
|
clipboardCopy, clipboardCut, cloneNode, createActions, createPasteTypes, createSheet, drag, getActions, getCookie, getCookieSet, getDefaultAction, getDropType, getHandle, getNewTypes, getPasteTypes, getPropertySets, getSheet, setCookieSet, setDefaultAction, setIconBase, setIconBaseWithExtension, setSheet
addNodeListener, addPropertyChangeListener, clone, equals, fireCookieChange, fireDisplayNameChange, fireIconChange, fireNameChange, fireNodeDestroyed, fireOpenedIconChange, firePropertyChange, firePropertySetsChange, fireShortDescriptionChange, getChildren, getContextActions, getContextMenu, getHtmlDisplayName, getLookup, getParentNode, hashCode, hasPropertyChangeListener, isLeaf, removeNodeListener, removePropertyChangeListener, setChildren, setDisplayName, setHidden, setShortDescription, toString
attributeNames, getDisplayName, getName, getShortDescription, getValue, isExpert, isHidden, isPreferred, setExpert, setPreferred, setValue
public BeanNode(T bean) throws IntrospectionException
BeanContext
,
creates a child list as well.bean
- the bean this node will be based onIntrospectionException
- if the bean cannot be analyzedprotected BeanNode(T bean, Children children) throws IntrospectionException
bean
- the bean this node will be based onchildren
- children for the node (default if null)IntrospectionException
- if the bean cannot be analyzedprotected BeanNode(T bean, Children children, Lookup lkp) throws IntrospectionException
Children
implementation
or leave the default implementation.
It can also provide a Lookup, but if you provide one, please do not call
methods AbstractNode.getCookieSet()
and AbstractNode.setCookieSet(org.openide.nodes.CookieSet)
they will
throw an exception.
More info on the correct usage of constructor with Lookup can be found
in the Node.Node(org.openide.nodes.Children, org.openide.util.Lookup)
javadoc.
bean
- the bean this node will be based onchildren
- children for the node (default if null)lkp
- the lookup to provide content of Node.getLookup()
and also AbstractNode.getCookie(java.lang.Class<T>)
IntrospectionException
- if the bean cannot be analyzedprotected void setSynchronizeName(boolean watch)
getName ()
, getDisplayName ()
or from FeatureDescriptor.getDisplayName()
.
Also when the (system) name of the node is changing, the change propagates if possible to
methods setName (String)
or setDisplayName (String)
. (This
does not apply to setting the display name of the node, however.)
By default this feature is turned on.
watch
- true
if the name of the node should be synchronized with
the name of the bean, false
if the name of the node should be independent
or manually updatedprotected T getBean()
public void destroy() throws IOException
destroy
in class Node
IOException
- if there was a problempublic boolean canDestroy()
canDestroy
in class AbstractNode
true
in this implementationpublic void setName(String s)
BeanNode.setSynchronizeName(boolean)
.setName
in class AbstractNode
s
- the new namepublic boolean canRename()
canRename
in class AbstractNode
true
if there is no name synchronization, or there is
a valid setter method for the namepublic Image getIcon(int type)
getIcon
in class AbstractNode
type
- constant from BeanInfo
public Image getOpenedIcon(int type)
getOpenedIcon
in class AbstractNode
type
- type constantsBeanNode.getIcon(int)
.public HelpCtx getHelpCtx()
Node
getHelpCtx
in interface HelpCtx.Provider
getHelpCtx
in class AbstractNode
null
or HelpCtx.DEFAULT_HELP
)protected void createProperties(T bean, BeanInfo info)
bean
- bean to compute properties forinfo
- information about the beanBeanNode.computeProperties(java.lang.Object, java.beans.BeanInfo)
public boolean canCopy()
canCopy
in class AbstractNode
true
in the default implementationpublic boolean canCut()
canCut
in class AbstractNode
false
in the default implementationpublic Action[] getActions(boolean context)
Node
By default this method delegates to the deprecated getActions or getContextActions method depending on the value of supplied argument.
It is supposed to be overridden by subclasses accordingly.
getActions
in class Node
context
- whether to find actions for context meaning or for the
node itselfpublic boolean hasCustomizer()
AbstractNode
hasCustomizer
in class AbstractNode
false
public Component getCustomizer()
AbstractNode
getCustomizer
in class AbstractNode
null
in the default implementationpublic static BeanNode.Descriptor computeProperties(Object bean, BeanInfo info)
Property code names are taken from the property descriptor names
according to the JavaBeans specification. For example, a pair of
methods getFoo
and setFoo
would result in
a node property with code name foo
. If you call
MyBean.setFoo(...)
, this should result in a property
change event with name foo
; if you are using these
properties in some other context (attached to something other than
a BeanNode
) then be careful to fire changes with the correct
name, or there may be problems with refreshing display of the property etc.
bean
- bean to create properties forinfo
- about the beanpublic Action getPreferredAction()
AbstractNode
getPreferredAction
in class AbstractNode
Node.getPreferredAction()