org.openide.src.nodes
Class ElementNode

java.lang.Object
  |
  +--java.beans.FeatureDescriptor
        |
        +--org.openide.nodes.Node
              |
              +--org.openide.nodes.AbstractNode
                    |
                    +--org.openide.src.nodes.ElementNode
All Implemented Interfaces:
ElementProperties, org.openide.src.nodes.IconStrings
Direct Known Subclasses:
InitializerElementNode, MemberElementNode

public abstract class ElementNode
extends AbstractNode
implements org.openide.src.nodes.IconStrings, ElementProperties

Superclass of nodes representing elements in the source hierarchy.

Element nodes generally:


Inner classes inherited from class org.openide.nodes.Node
Node.Cookie, Node.Handle, Node.IndexedProperty, Node.Property, Node.PropertySet
 
Field Summary
static String CLASS
           
static String CONSTRUCTOR_PACKAGE
           
static String CONSTRUCTOR_PRIVATE
           
static String CONSTRUCTOR_PROTECTED
           
static String CONSTRUCTOR_PUBLIC
           
static String CONSTRUCTORS_CATEGORY
           
protected  Element element
          Associated element.
protected  ElementFormat elementFormat
          Format for FeatureDescriptor.getDisplayName().
static String ERROR
           
static String FIELD_PACKAGE
           
static String FIELD_PRIVATE
           
static String FIELD_PROTECTED
           
static String FIELD_PUBLIC
           
static String FIELD_ST_PACKAGE
           
static String FIELD_ST_PRIVATE
           
static String FIELD_ST_PROTECTED
           
static String FIELD_ST_PUBLIC
           
static String FIELDS_CATEGORY
           
static String INITIALIZER
           
static String INITIALIZER_ST
           
static String INTERFACE
           
static String METHOD_PACKAGE
           
static String METHOD_PRIVATE
           
static String METHOD_PROTECTED
           
static String METHOD_PUBLIC
           
static String METHOD_ST_PACKAGE
           
static String METHOD_ST_PRIVATE
           
static String METHOD_ST_PROTECTED
           
static String METHOD_ST_PUBLIC
           
static String METHODS_CATEGORY
           
protected static SourceOptions sourceOptions
          Options for the display name format.
static String WAIT
           
protected  boolean writeable
          Is this node read-only or are modifications permitted?
 
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
 
Fields inherited from interface org.openide.src.ElementProperties
PROP_ALL_CLASSES, PROP_BODY, PROP_CLASS_OR_INTERFACE, PROP_CLASSES, PROP_CONSTRUCTORS, PROP_EXCEPTIONS, PROP_FIELDS, PROP_IMPORTS, PROP_INIT_VALUE, PROP_INITIALIZERS, PROP_INTERFACES, PROP_JAVADOC, PROP_MEMBERS, PROP_METHODS, PROP_MODIFIERS, PROP_NAME, PROP_PACKAGE, PROP_PARAMETERS, PROP_RETURN, PROP_STATIC, PROP_STATUS, PROP_SUPERCLASS, PROP_TYPE, PROP_VALID
 
Constructor Summary
ElementNode(Element element, Children children, boolean writeable)
          Create a new element node.
 
Method Summary
 boolean canCopy()
          Test whether this node can be copied.
 boolean canCut()
          Test whether this node can be cut.
 boolean canDestroy()
          Test whether this node can be deleted.
 boolean canRename()
          Test whether this node can be renamed.
 Transferable clipboardCopy()
          Copy this node to the clipboard.
 Transferable clipboardCut()
          Cut this node to the clipboard.
 boolean equals(Object o)
          Test for equality.
 Node.Cookie getCookie(Class type)
          Get a cookie from this node.
 ElementFormat getElementFormat()
          Get a format for the element's display name.
 Node.Handle getHandle()
          Get a handle.
 HelpCtx getHelpCtx()
          Get context help associated with this node.
protected abstract  ElementFormat getHintElementFormat()
          Get a format for creating this node's short description.
protected  String[] getIconAffectingProperties()
          Get the names of all element properties which might affect the choice of icon.
 String getShortDescription()
           
 int hashCode()
          Get a hash code.
protected abstract  String resolveIconBase()
          Get the currently appropriate icon base.
 void setActions(SystemAction[] actions)
          Set all actions for this node.
 void setElementFormat(ElementFormat elementFormat)
          Set the format for the display name.
 
Methods inherited from class org.openide.nodes.AbstractNode
cloneNode, createActions, createPasteTypes, createSheet, drag, getActions, getCookieSet, getCustomizer, getDefaultAction, getDropType, getIcon, getNewTypes, getOpenedIcon, getPasteTypes, getPropertySets, getSheet, hasCustomizer, setCookieSet, setDefaultAction, setIconBase, setName, setSheet
 
Methods inherited from class org.openide.nodes.Node
addNodeListener, addPropertyChangeListener, clone, destroy, 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, getValue, isExpert, isHidden, isPreferred, setExpert, setHidden, setPreferred, setValue
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

sourceOptions

protected static final SourceOptions sourceOptions
Options for the display name format.

element

protected Element element
Associated element.

elementFormat

protected ElementFormat elementFormat
Format for FeatureDescriptor.getDisplayName().

writeable

protected boolean writeable
Is this node read-only or are modifications permitted?

FIELD_PUBLIC

public static final String FIELD_PUBLIC

FIELD_PROTECTED

public static final String FIELD_PROTECTED

FIELD_PRIVATE

public static final String FIELD_PRIVATE

FIELD_PACKAGE

public static final String FIELD_PACKAGE

FIELD_ST_PUBLIC

public static final String FIELD_ST_PUBLIC

FIELD_ST_PROTECTED

public static final String FIELD_ST_PROTECTED

FIELD_ST_PRIVATE

public static final String FIELD_ST_PRIVATE

FIELD_ST_PACKAGE

public static final String FIELD_ST_PACKAGE

CONSTRUCTOR_PUBLIC

public static final String CONSTRUCTOR_PUBLIC

CONSTRUCTOR_PROTECTED

public static final String CONSTRUCTOR_PROTECTED

CONSTRUCTOR_PRIVATE

public static final String CONSTRUCTOR_PRIVATE

CONSTRUCTOR_PACKAGE

public static final String CONSTRUCTOR_PACKAGE

METHOD_PUBLIC

public static final String METHOD_PUBLIC

METHOD_PROTECTED

public static final String METHOD_PROTECTED

METHOD_PRIVATE

public static final String METHOD_PRIVATE

METHOD_PACKAGE

public static final String METHOD_PACKAGE

METHOD_ST_PUBLIC

public static final String METHOD_ST_PUBLIC

METHOD_ST_PROTECTED

public static final String METHOD_ST_PROTECTED

METHOD_ST_PRIVATE

public static final String METHOD_ST_PRIVATE

METHOD_ST_PACKAGE

public static final String METHOD_ST_PACKAGE

INITIALIZER

public static final String INITIALIZER

INITIALIZER_ST

public static final String INITIALIZER_ST

CLASS

public static final String CLASS

INTERFACE

public static final String INTERFACE

WAIT

public static final String WAIT

ERROR

public static final String ERROR

FIELDS_CATEGORY

public static final String FIELDS_CATEGORY

CONSTRUCTORS_CATEGORY

public static final String CONSTRUCTORS_CATEGORY

METHODS_CATEGORY

public static final String METHODS_CATEGORY
Constructor Detail

ElementNode

public ElementNode(Element element,
                   Children children,
                   boolean writeable)
Create a new element node.
Parameters:
element - element to represent
children - child nodes
writeable - true if this node should allow modifications. These include writable properties, clipboard operations, deletions, etc.
Method Detail

getShortDescription

public String getShortDescription()
Overrides:
getShortDescription in class FeatureDescriptor

resolveIconBase

protected abstract String resolveIconBase()
Get the currently appropriate icon base. Subclasses should make this sensitive to the state of the element--for example, a private variable may have a different icon than a public one. The icon will be automatically changed whenever a relevant change is made to the element.
Returns:
icon base
See Also:
AbstractNode.setIconBase(java.lang.String)

getIconAffectingProperties

protected String[] getIconAffectingProperties()
Get the names of all element properties which might affect the choice of icon. The default implementation just returns ElementProperties.PROP_MODIFIERS.
Returns:
the property names, from ElementProperties

getElementFormat

public final ElementFormat getElementFormat()
Get a format for the element's display name. The display name will be automatically updated whenever a relevant change is made to the element.
Returns:
the format

setElementFormat

public final void setElementFormat(ElementFormat elementFormat)
Set the format for the display name.
Parameters:
elementFormat - the new format
Throws:
IllegalArgumentException - if the format object is inappropriate for this type of Element. No assignment is made in such case.

getHintElementFormat

protected abstract ElementFormat getHintElementFormat()
Get a format for creating this node's short description.

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)

canRename

public boolean canRename()
Test whether this node can be renamed. The default implementation assumes it can if this node is writeable.
Overrides:
canRename in class AbstractNode
Returns:
true if this node can be renamed

canDestroy

public boolean canDestroy()
Test whether this node can be deleted. The default implementation assumes it can if this node is writeable.
Overrides:
canDestroy in class AbstractNode
Returns:
true if this node can be renamed

clipboardCopy

public Transferable clipboardCopy()
                           throws IOException
Description copied from class: AbstractNode
Copy this node to the clipboard.
Overrides:
clipboardCopy in class AbstractNode
Following copied from class: org.openide.nodes.AbstractNode
Returns:
ExTransferable.Single with one copy flavor
Throws:
IOException - if it could not copy
See Also:
NodeTransfer

clipboardCut

public Transferable clipboardCut()
                          throws IOException
Description copied from class: AbstractNode
Cut this node to the clipboard.
Overrides:
clipboardCut in class AbstractNode
Following copied from class: org.openide.nodes.AbstractNode
Returns:
ExTransferable.Single with one cut flavor
Throws:
IOException - if it could not cut
See Also:
NodeTransfer

canCopy

public boolean canCopy()
Test whether this node can be copied. The default implementation returns true.
Overrides:
canCopy in class AbstractNode
Returns:
true if it can

canCut

public boolean canCut()
Test whether this node can be cut. The default implementation assumes it can if this node is writeable.
Overrides:
canCut in class AbstractNode
Returns:
true if it can

setActions

public void setActions(SystemAction[] actions)
Set all actions for this node.
Parameters:
actions - new list of actions

getCookie

public Node.Cookie getCookie(Class type)
Get a cookie from this node. First tries the node itself, then Element.getCookie(java.lang.Class). Since Element implements Node.Cookie, it is possible to find the element from a node using code such as:

 Node someNode = ...;
 MethodElement element = (MethodElement) someNode.getCookie (MethodElement.class);
 if (element != null) { ... }
 
Overrides:
getCookie in class AbstractNode
Parameters:
type - the cookie class
Returns:
the cookie or null

equals

public boolean equals(Object o)
Test for equality.
Overrides:
equals in class Object
Returns:
true if the represented Elements are equal

hashCode

public int hashCode()
Get a hash code.
Overrides:
hashCode in class Object
Returns:
the hash code from the represented Element

getHandle

public Node.Handle getHandle()
Get a handle. If this is part of a hierarchy and its position can be stored, this is done. Otherwise the handle will restore using the default factory.
Overrides:
getHandle in class AbstractNode
Following copied from class: org.openide.nodes.AbstractNode
Returns:
a DefaultHandle in the default implementation


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