org.openide.loaders
Class DataNode

java.lang.Object
  |
  +--java.beans.FeatureDescriptor
        |
        +--org.openide.nodes.Node
              |
              +--org.openide.nodes.AbstractNode
                    |
                    +--org.openide.loaders.DataNode
Direct Known Subclasses:
DataFolder.FolderNode

public class DataNode
extends AbstractNode

Standard node representing a data object.


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
DataNode(DataObject obj, Children ch)
          Create a data node for a given data object.
 
Method Summary
 boolean canCopy()
          Can this node be copied?
 boolean canCut()
          Can this node be cut?
 boolean canDestroy()
          Indicate whether the node may be destroyed.
 boolean canRename()
          Indicate whether the node may be renamed.
 Transferable clipboardCopy()
          Copy this node to the clipboard.
 Transferable clipboardCut()
          Cut this node to the clipboard.
protected  SystemAction[] createActions()
          This method returns null to signal that actions provide by DataLoader.getActions should be returned from method getActions.
protected  Sheet createSheet()
          Initialize a default property sheet; commonly overridden.
 void destroy()
          Remove the node from its parent and deletes it.
 SystemAction[] getActions()
          Get actions for this data object.
 Node.Cookie getCookie(Class cl)
          Get a cookie.
 DataObject getDataObject()
          Get the represented data object.
 SystemAction getDefaultAction()
          Get default action.
 String getDisplayName()
          Get the display name for the node.
 Node.Handle getHandle()
          Handle for location of given data object.
 HelpCtx getHelpCtx()
          Get context help associated with this node.
 Image getIcon(int type)
          Get the displayed icon for this node.
 Image getOpenedIcon(int type)
          Get the displayed icon for this node.
static boolean getShowFileExtensions()
          Should file extensions be shown by default? By default, no.
 void setName(String name)
          Set the system name.
 void setName(String name, boolean rename)
          Changes the name of the node and may also rename the data object.
static void setShowFileExtensions(boolean s)
          Set whether file extensions should be shown by default.
 
Methods inherited from class org.openide.nodes.AbstractNode
cloneNode, createPasteTypes, drag, getCookieSet, getCustomizer, getDropType, getNewTypes, getPasteTypes, getPropertySets, getSheet, hasCustomizer, 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, 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

DataNode

public DataNode(DataObject obj,
                Children ch)
Create a data node for a given data object. The provided children object will be used to hold all child nodes. The name is always set to the base name of the primary file; the display name may instead be set to the base name with extension.
Parameters:
obj - object to work with
ch - children container for the node
See Also:
getShowFileExtensions()
Method Detail

getDataObject

public DataObject getDataObject()
Get the represented data object.
Returns:
the data object

setName

public void setName(String name,
                    boolean rename)
Changes the name of the node and may also rename the data object. If the object is renamed and file extensions are to be shown, the display name is also updated accordingly.
Parameters:
name - new name for the object
rename - rename the data object?
Throws:
IllegalArgumentException - if the rename failed

setName

public void setName(String name)
Description copied from class: AbstractNode
Set the system name. Fires a property change event. Also may change the display name according to AbstractNode.displayFormat.
Overrides:
setName in class AbstractNode
Following copied from class: org.openide.nodes.AbstractNode
Parameters:
s - the new name

getDisplayName

public String getDisplayName()
Get the display name for the node. A filesystem may specially alter this.
Overrides:
getDisplayName in class FeatureDescriptor
Returns:
the desired name

getIcon

public Image getIcon(int type)
Get the displayed icon for this node. A filesystem may specially alter this.
Overrides:
getIcon in class AbstractNode
Parameters:
type - the icon type from BeanInfo
Returns:
the desired icon

getOpenedIcon

public Image getOpenedIcon(int type)
Get the displayed icon for this node. A filesystem may specially alter this.
Overrides:
getOpenedIcon in class AbstractNode
Parameters:
type - the icon type from BeanInfo
Returns:
the desired icon

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()
Indicate whether the node may be renamed.
Overrides:
canRename in class AbstractNode
Returns:
tests DataObject.isRenameAllowed()

canDestroy

public boolean canDestroy()
Indicate whether the node may be destroyed.
Overrides:
canDestroy in class AbstractNode
Returns:
tests DataObject.isDeleteAllowed()

destroy

public void destroy()
             throws IOException
Description copied from class: Node
Remove the node from its parent and deletes it. The default implementation obtains write access to the children's lock, and removes the node from its parent (if any). Also fires a property change.

This may be overridden by subclasses to do any additional cleanup.

Overrides:
destroy in class Node
Following copied from class: org.openide.nodes.Node
Throws:
IOException - if something fails

canCopy

public boolean canCopy()
Description copied from class: AbstractNode
Can this node be copied?
Overrides:
canCopy in class AbstractNode
Following copied from class: org.openide.nodes.AbstractNode
Returns:
true

canCut

public boolean canCut()
Description copied from class: AbstractNode
Can this node be cut?
Overrides:
canCut in class AbstractNode
Following copied from class: org.openide.nodes.AbstractNode
Returns:
false

createActions

protected SystemAction[] createActions()
This method returns null to signal that actions provide by DataLoader.getActions should be returned from method getActions. If overriden to provide some actions, then these actions will be preferred to the loader's ones.
Overrides:
createActions in class AbstractNode
Returns:
null

getActions

public SystemAction[] getActions()
Get actions for this data object.
Overrides:
getActions in class AbstractNode
Returns:
array of actions or null
See Also:
DataLoader.getActions()

getDefaultAction

public SystemAction getDefaultAction()
Get default action. A data node may have a default action if it represents a template.
Overrides:
getDefaultAction in class AbstractNode
Returns:
an instantiation action if the underlying data object is a template. Otherwise the abstract node's default action is returned, if null then the first action returned from getActions () method is used.

getCookie

public Node.Cookie getCookie(Class cl)
Get a cookie. First of all DataObject.getCookie(java.lang.Class) is called. If it produces non-null result, that is returned. Otherwise the superclass is tried.
Overrides:
getCookie in class AbstractNode
Returns:
the cookie or null

createSheet

protected Sheet createSheet()
Description copied from class: AbstractNode
Initialize a default property sheet; commonly overridden. If AbstractNode.getSheet() is called and there is not yet a sheet, this method is called to allow a subclass to specify its properties.

Warning: Do not call getSheet in this method.

The default implementation returns an empty sheet.

Overrides:
createSheet in class AbstractNode
Following copied from class: org.openide.nodes.AbstractNode
Returns:
the sheet with initialized values (never null)

clipboardCopy

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

clipboardCut

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

getHandle

public Node.Handle getHandle()
Handle for location of given data object.
Overrides:
getHandle in class AbstractNode
Returns:
handle that remembers the data object.

getShowFileExtensions

public static boolean getShowFileExtensions()
Should file extensions be shown by default? By default, no.
Returns:
true if so

setShowFileExtensions

public static void setShowFileExtensions(boolean s)
Set whether file extensions should be shown by default.
Parameters:
s - true if so


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