org.openide.nodes
Class BeanNode

java.lang.Object
  |
  +--java.beans.FeatureDescriptor
        |
        +--org.openide.nodes.Node
              |
              +--org.openide.nodes.AbstractNode
                    |
                    +--org.openide.nodes.BeanNode

public class BeanNode
extends AbstractNode

Represents one JavaBean in the nodes hierarchy. It provides all methods that are needed for communication between the IDE and the bean.

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.


Inner Class Summary
static class BeanNode.Descriptor
          Descriptor of three types of properties.
 
Inner classes inherited from class org.openide.nodes.Node
Node.Cookie, Node.Handle, Node.IndexedProperty, Node.Property, Node.PropertySet
 
Fields inherited from class org.openide.nodes.AbstractNode
displayFormat, systemActions
 
Fields inherited from class org.openide.nodes.Node
EMPTY, PROP_COOKIE, PROP_DISPLAY_NAME, PROP_ICON, PROP_NAME, PROP_OPENED_ICON, PROP_PARENT_NODE, PROP_PROPERTY_SETS, PROP_SHORT_DESCRIPTION
 
Constructor Summary
  BeanNode(Object bean)
          Constructs a node for a JavaBean.
protected BeanNode(Object bean, Children children)
          Constructs a node for a JavaBean with a defined child list.
 
Method Summary
 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  SystemAction[] createActions()
          Lazily initialize set of node's actions (overridable).
protected  void createProperties(Object 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.
protected  Object 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.
 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.
 
Methods inherited from class org.openide.nodes.AbstractNode
clipboardCopy, clipboardCut, cloneNode, createPasteTypes, createSheet, drag, getActions, getCookie, getCookieSet, getDefaultAction, getDropType, getHandle, getNewTypes, getPasteTypes, getPropertySets, getSheet, setCookieSet, setDefaultAction, setIconBase, setSheet
 
Methods inherited from class org.openide.nodes.Node
addNodeListener, addPropertyChangeListener, clone, fireCookieChange, fireDisplayNameChange, fireIconChange, fireNameChange, fireNodeDestroyed, fireOpenedIconChange, firePropertyChange, firePropertySetsChange, fireShortDescriptionChange, getChildren, getContextActions, getContextMenu, getParentNode, hasPropertyChangeListener, isLeaf, removeNodeListener, removePropertyChangeListener, setDisplayName, setShortDescription, 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
 

Constructor Detail

BeanNode

public BeanNode(Object bean)
         throws IntrospectionException
Constructs a node for a JavaBean. If the bean is a BeanContext, 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

protected BeanNode(Object bean,
                   Children children)
            throws IntrospectionException
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 on
children - children for the node (default if null)
Throws:
IntrospectionException - if the bean cannot be analyzed
Method Detail

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 calling 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.

Parameters:
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 updated

getBean

protected Object getBean()
Provides access to the bean represented by this BeanNode.
Returns:
instance of the bean represented by this BeanNode

destroy

public void destroy()
             throws IOException
Detaches all listeners from the bean and destroys it.
Overrides:
destroy in class Node
Throws:
IOException - if there was a problem

canDestroy

public boolean canDestroy()
Can this node be removed?
Overrides:
canDestroy in class AbstractNode
Returns:
true in this implementation

setName

public void setName(String s)
Set the node name. Also may attempt to change the name of the bean, according to setSynchronizeName(boolean).
Overrides:
setName in class AbstractNode
Parameters:
s - the new name

canRename

public boolean canRename()
Can this node be renamed?
Overrides:
canRename in class AbstractNode
Returns:
true if there is no name synchronization, or there is a valid setter method for the name

getIcon

public Image getIcon(int type)
Get an icon for this node in the closed state. Uses the Bean's icon if possible.
Overrides:
getIcon in class AbstractNode
Parameters:
type - constant from BeanInfo
Returns:
icon to use

getOpenedIcon

public Image getOpenedIcon(int type)
Get an icon for this node in the open state.
Overrides:
getOpenedIcon in class AbstractNode
Parameters:
type - type constants
Returns:
icon to use. The default implementation just uses getIcon(int).

getHelpCtx

public HelpCtx getHelpCtx()
Description copied from class: Node
Get context help associated with this node.
Overrides:
getHelpCtx in class AbstractNode
Following copied from class: org.openide.nodes.Node
Returns:
the context help object (could be null or HelpCtx.DEFAULT_HELP)

createProperties

protected void createProperties(Object bean,
                                BeanInfo info)
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 for
info - information about the bean
See Also:
computeProperties(java.lang.Object, java.beans.BeanInfo)

canCopy

public boolean canCopy()
Can this node be copied?
Overrides:
canCopy in class AbstractNode
Returns:
true in the default implementation

canCut

public boolean canCut()
Can this node be cut?
Overrides:
canCut in class AbstractNode
Returns:
false in the default implementation

createActions

protected SystemAction[] createActions()
Description copied from class: AbstractNode
Lazily initialize set of node's actions (overridable). The default implementation returns null.

Warning: do not call AbstractNode.getActions() within this method. If necessary, call NodeOp.getDefaultActions() to merge in.

Overrides:
createActions in class AbstractNode
Following copied from class: org.openide.nodes.AbstractNode
Returns:
array of actions for this node, or null to use the default node actions

hasCustomizer

public boolean hasCustomizer()
Description copied from class: AbstractNode
Does this node have a customizer?
Overrides:
hasCustomizer in class AbstractNode
Following copied from class: org.openide.nodes.AbstractNode
Returns:
false

getCustomizer

public Component getCustomizer()
Description copied from class: AbstractNode
Get the customizer.
Overrides:
getCustomizer in class AbstractNode
Following copied from class: org.openide.nodes.AbstractNode
Returns:
null in the default implementation

computeProperties

public static BeanNode.Descriptor computeProperties(Object bean,
                                                    BeanInfo info)
Computes a descriptor for properties from a bean info.
Parameters:
bean - bean to create properties for
info - about the bean
Returns:
three property lists


Built on December 12 2001.  |  Portions Copyright 1997-2001 Sun Microsystems, Inc. All rights reserved.