Class BeanNode<T>
- Type Parameters:
T- the type of bean to be represented
- All Implemented Interfaces:
org.openide.util.HelpCtx.Provider, org.openide.util.Lookup.Provider
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classDescriptor of three types of properties.Nested classes/interfaces inherited from class Node
Node.Cookie, Node.Handle, Node.IndexedProperty<T,E>, Node.Property<T>, Node.PropertySet -
Field Summary
Fields inherited from class AbstractNode
displayFormat, systemActionsFields inherited from class Node
EMPTY, PROP_COOKIE, PROP_DISPLAY_NAME, PROP_ICON, PROP_LEAF, PROP_NAME, PROP_OPENED_ICON, PROP_PARENT_NODE, PROP_PROPERTY_SETS, PROP_SHORT_DESCRIPTION -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanCopy()Can this node be copied?booleancanCut()Can this node be cut?booleanCan this node be removed?booleanCan this node be renamed?static BeanNode.DescriptorcomputeProperties(Object bean, BeanInfo info) Computes a descriptor for properties from a bean info.protected voidcreateProperties(T bean, BeanInfo info) Prepare node properties based on the bean, storing them into the current property sheet.voiddestroy()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 TgetBean()Provides access to the bean represented by this BeanNode.Get the customizer.org.openide.util.HelpCtxGet context help associated with this node.getIcon(int type) Get an icon for this node in the closed state.getOpenedIcon(int type) Get an icon for this node in the open state.Gets preferred action.booleanDoes this node have a customizer?voidSet the node name.protected voidsetSynchronizeName(boolean watch) Set whether or not to keep the node name and Bean name synchronized automatically.Methods inherited from class AbstractNode
clipboardCopy, clipboardCut, cloneNode, createActions, createPasteTypes, createSheet, drag, getActions, getCookie, getCookieSet, getDefaultAction, getDropType, getHandle, getNewTypes, getPasteTypes, getPropertySets, getSheet, setCookieSet, setDefaultAction, setIconBase, setIconBaseWithExtension, setSheetMethods inherited from class Node
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, toStringMethods inherited from class FeatureDescriptor
attributeNames, getDisplayName, getName, getShortDescription, getValue, isExpert, isHidden, isPreferred, setExpert, setPreferred, setValue
-
Constructor Details
-
BeanNode
Constructs a node for a JavaBean. If the bean is aBeanContext, creates a child list as well.- Parameters:
bean- the bean this node will be based on- Throws:
IntrospectionException- if the bean cannot be analyzed
-
BeanNode
Constructs a node for a JavaBean with a defined child list. Intended for use by subclasses with different strategies for computing the children.- Parameters:
bean- the bean this node will be based onchildren- children for the node (default if null)- Throws:
IntrospectionException- if the bean cannot be analyzed
-
BeanNode
protected BeanNode(T bean, Children children, org.openide.util.Lookup lkp) throws IntrospectionException Constructs a node for a JavaBean. The subclass can provide its ownChildrenimplementation or leave the default implementation. It can also provide a Lookup, but if you provide one, please do not call methodsAbstractNode.getCookieSet()andAbstractNode.setCookieSet(CookieSet)they will throw an exception.More info on the correct usage of constructor with Lookup can be found in the
Node(org.openide.nodes.Children, org.openide.util.Lookup)javadoc.- Parameters:
bean- the bean this node will be based onchildren- children for the node (default if null)lkp- the lookup to provide content ofNode.getLookup()and alsoAbstractNode.getCookie(Class)- Throws:
IntrospectionException- if the bean cannot be analyzed- Since:
- 6.9
-
-
Method Details
-
setSynchronizeName
protected void setSynchronizeName(boolean watch) Set whether or not to keep the node name and Bean name synchronized automatically. If enabled, the node will listen to changes in the name of the bean and update the (system) name of the node appropriately. The name of the bean can be obtained by callinggetName (),getDisplayName ()or fromFeatureDescriptor.getDisplayName().Also when the (system) name of the node is changing, the change propagates if possible to methods
setName (String)orsetDisplayName (String). (This does not apply to setting the display name of the node, however.)By default this feature is turned on.
- Parameters:
watch-trueif the name of the node should be synchronized with the name of the bean,falseif the name of the node should be independent or manually updated
-
getBean
Provides access to the bean represented by this BeanNode.- Returns:
- instance of the bean represented by this BeanNode
-
destroy
Detaches all listeners from the bean and destroys it.- Overrides:
destroyin classNode- Throws:
IOException- if there was a problem
-
canDestroy
public boolean canDestroy()Can this node be removed?- Overrides:
canDestroyin classAbstractNode- Returns:
truein this implementation
-
setName
Set the node name. Also may attempt to change the name of the bean, according tosetSynchronizeName(boolean).- Overrides:
setNamein classAbstractNode- Parameters:
s- the new name
-
canRename
public boolean canRename()Can this node be renamed?- Overrides:
canRenamein classAbstractNode- Returns:
trueif there is no name synchronization, or there is a valid setter method for the name
-
getIcon
Get an icon for this node in the closed state. Uses the Bean's icon if possible.- Overrides:
getIconin classAbstractNode- Parameters:
type- constant fromBeanInfo- Returns:
- icon to use
-
getOpenedIcon
Get an icon for this node in the open state.- Overrides:
getOpenedIconin classAbstractNode- Parameters:
type- type constants- Returns:
- icon to use. The default implementation just uses
getIcon(int).
-
getHelpCtx
public org.openide.util.HelpCtx getHelpCtx()Description copied from class:NodeGet context help associated with this node.- Specified by:
getHelpCtxin interfaceorg.openide.util.HelpCtx.Provider- Overrides:
getHelpCtxin classAbstractNode- Returns:
- the context help object (could be
nullorHelpCtx.DEFAULT_HELP)
-
createProperties
Prepare node properties based on the bean, storing them into the current property sheet. Called when the bean info is ready. This implementation always creates a set for standard properties and may create a set for expert ones if there are any.- Parameters:
bean- bean to compute properties forinfo- information about the bean- See Also:
-
canCopy
public boolean canCopy()Can this node be copied?- Overrides:
canCopyin classAbstractNode- Returns:
truein the default implementation
-
canCut
public boolean canCut()Can this node be cut?- Overrides:
canCutin classAbstractNode- Returns:
falsein the default implementation
-
getActions
Description copied from class:NodeGet the set of actions that are associated with this node. This set is used to construct the context menu for the 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.
- Overrides:
getActionsin classNode- Parameters:
context- whether to find actions for context meaning or for the node itself- Returns:
- a list of actions (you may include nulls for separators)
-
hasCustomizer
public boolean hasCustomizer()Description copied from class:AbstractNodeDoes this node have a customizer?- Overrides:
hasCustomizerin classAbstractNode- Returns:
false
-
getCustomizer
Description copied from class:AbstractNodeGet the customizer.- Overrides:
getCustomizerin classAbstractNode- Returns:
nullin the default implementation
-
computeProperties
Computes a descriptor for properties from a bean info.Property code names are taken from the property descriptor names according to the JavaBeans specification. For example, a pair of methods
getFooandsetFoowould result in a node property with code namefoo. If you callMyBean.setFoo(...), this should result in a property change event with namefoo; if you are using these properties in some other context (attached to something other than aBeanNode) then be careful to fire changes with the correct name, or there may be problems with refreshing display of the property etc.- Parameters:
bean- bean to create properties forinfo- about the bean- Returns:
- three property lists
-
getPreferredAction
Description copied from class:AbstractNodeGets preferred action. By default, null.- Overrides:
getPreferredActionin classAbstractNode- Returns:
- preferred action
- See Also:
-