站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc 5.0.0

BeanNode (NetBeans Nodes API) - NetBeans API Javadoc 5.0.0

 

org.openide.nodes
Class BeanNode

java.lang.Object
  extended byjava.beans.FeatureDescriptor
      extended byorg.openide.nodes.Node
          extended byorg.openide.nodes.AbstractNode
              extended byorg.openide.nodes.BeanNode
All Implemented Interfaces:
HelpCtx.Provider, Lookup.Provider

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.


Nested Class Summary
static class BeanNode.Descriptor
          Descriptor of three types of properties.
 
Nested classes inherited from class org.openide.nodes.Node
Node.Cookie, Node.Handle, Node.IndexedProperty, Node.Property, Node.PropertySet
 
Field Summary
 
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_LEAF, 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.
 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.
 
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, setIconBaseWithExtension, setSheet
 
Methods inherited from class org.openide.nodes.Node
addNodeListener, addPropertyChangeListener, clone, equals, fireCookieChange, fireDisplayNameChange, fireIconChange, fireNameChange, fireNodeDestroyed, fireOpenedIconChange, firePropertyChange, firePropertySetsChange, fireShortDescriptionChange, getActions, getChildren, getContextActions, getContextMenu, getHtmlDisplayName, getLookup, getParentNode, hasPropertyChangeListener, isLeaf, removeNodeListener, removePropertyChangeListener, setChildren, 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
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.

Specified by:
getHelpCtx in interface HelpCtx.Provider
Overrides:
getHelpCtx in class AbstractNode

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.

Overrides:
createActions in class 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
Returns:
false

getCustomizer

public Component getCustomizer()
Description copied from class: AbstractNode
Get the customizer.

Overrides:
getCustomizer in class 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.

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.

Parameters:
bean - bean to create properties for
info - about the bean
Returns:
three property lists

getPreferredAction

public Action getPreferredAction()
Description copied from class: AbstractNode
Gets preferred action. By default, null.

Overrides:
getPreferredAction in class AbstractNode
Returns:
preferred action
See Also:
Node.getPreferredAction()

 

Built on May 3 2007.  |  Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.