Class DataNode

java.lang.Object
java.beans.FeatureDescriptor
org.openide.nodes.Node
org.openide.nodes.AbstractNode
org.openide.loaders.DataNode
All Implemented Interfaces:
org.openide.util.HelpCtx.Provider, org.openide.util.Lookup.Provider
Direct Known Subclasses:
DataFolder.FolderNode

public class DataNode extends org.openide.nodes.AbstractNode
Standard node representing a data object.
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.openide.nodes.Node

    org.openide.nodes.Node.Cookie, org.openide.nodes.Node.Handle, org.openide.nodes.Node.IndexedProperty<T,E>, org.openide.nodes.Node.Property<T>, org.openide.nodes.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

    Constructors
    Constructor
    Description
    DataNode(DataObject obj, org.openide.nodes.Children ch)
    Create a data node with the given children set for the given data object.
    DataNode(DataObject obj, org.openide.nodes.Children ch, org.openide.util.Lookup lookup)
    Create a data node for a given data object.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    boolean
     
    boolean
    Indicate whether the node may be destroyed.
    boolean
    Indicate whether the node may be renamed.
    Copy this node to the clipboard.
    Cut this node to the clipboard.
    protected org.openide.util.actions.SystemAction[]
    Deprecated.
    Use getActions(boolean) or do nothing and let the data loader specify actions.
    protected void
    createPasteTypes(Transferable t, List<org.openide.util.datatransfer.PasteType> s)
     
    protected org.openide.nodes.Sheet
     
    void
    Removes the node from its parent, deletes it and fires a property change.
    org.openide.util.actions.SystemAction[]
    Deprecated.
    Use getActions(boolean)
    getActions(boolean context)
    Get actions for this data object.
    <T extends org.openide.nodes.Node.Cookie>
    T
    Get a cookie.
    Get the represented data object.
    Get the display name for the node.
    org.openide.nodes.Node.Handle
    Handle for location of given data object.
    org.openide.util.HelpCtx
     
    Get a display name formatted using the limited HTML subset supported by HtmlRenderer.
    getIcon(int type)
    Get the displayed icon for this node.
    getOpenedIcon(int type)
    Get the displayed icon for this node.
    Get default action.
    static boolean
    Determine whether file extensions should be shown by default.
    getValue(String attributeName)
     
    void
     
    void
    setName(String name, boolean rename)
    Changes the name of the node and may also rename the data object.
    static void
    Set whether file extensions should be shown by default.

    Methods inherited from class org.openide.nodes.AbstractNode

    cloneNode, drag, getCookieSet, getCustomizer, getDefaultAction, getDropType, getNewTypes, getPasteTypes, getPropertySets, getSheet, hasCustomizer, 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, getChildren, getContextActions, getContextMenu, getLookup, getParentNode, hashCode, hasPropertyChangeListener, isLeaf, removeNodeListener, removePropertyChangeListener, setChildren, setDisplayName, setHidden, setShortDescription, toString

    Methods inherited from class Object

    finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • DataNode

      public DataNode(DataObject obj, org.openide.nodes.Children ch)
      Create a data node with the given children set for the given data object.
      Parameters:
      obj - object to work with
      ch - children container for the node
      See Also:
    • DataNode

      public DataNode(DataObject obj, org.openide.nodes.Children ch, org.openide.util.Lookup lookup)
      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
      lookup - the lookup to provide content of Node.getLookup() and also getCookie(Class)
      Since:
      5.6
      See Also:
  • Method Details

    • 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)
      Overrides:
      setName in class org.openide.nodes.AbstractNode
    • getDisplayName

      public String getDisplayName()
      Get the display name for the node. A filesystem may specially alter this. Subclassers overriding this method should consider the recommendations in DataObject.createNodeDelegate().
      Overrides:
      getDisplayName in class FeatureDescriptor
      Returns:
      the desired name
    • getHtmlDisplayName

      public String getHtmlDisplayName()
      Get a display name formatted using the limited HTML subset supported by HtmlRenderer. If the underlying StatusDecorator supports HTML annotations, this method will return non-null if status information is added.
      Overrides:
      getHtmlDisplayName in class org.openide.nodes.Node
      Returns:
      a string containing compliant HTML markup or null
      Since:
      4.13
      See Also:
      • HtmlRenderer
      • Node.getHtmlDisplayName()
    • getIcon

      public Image getIcon(int type)
      Get the displayed icon for this node. Subclassers overriding this method should consider the recommendations in DataObject.createNodeDelegate().
      Overrides:
      getIcon in class org.openide.nodes.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. Subclassers overriding this method should consider the recommendations in DataObject.createNodeDelegate().
      Overrides:
      getOpenedIcon in class org.openide.nodes.AbstractNode
      Parameters:
      type - the icon type from BeanInfo
      Returns:
      the desired icon
    • getHelpCtx

      public org.openide.util.HelpCtx getHelpCtx()
      Specified by:
      getHelpCtx in interface org.openide.util.HelpCtx.Provider
      Overrides:
      getHelpCtx in class org.openide.nodes.AbstractNode
    • canRename

      public boolean canRename()
      Indicate whether the node may be renamed.
      Overrides:
      canRename in class org.openide.nodes.AbstractNode
      Returns:
      tests DataObject.isRenameAllowed()
    • canDestroy

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

      public void destroy() throws IOException
      Removes the node from its parent, deletes it and fires a property change. Since a DataNode is always bound to a DataObject, which itself is rooted in a filesystem, destroying a DataNode also implies deleting the associated FileObject.
      Overrides:
      destroy in class org.openide.nodes.Node
      Throws:
      IOException
    • canCopy

      public boolean canCopy()
      Overrides:
      canCopy in class org.openide.nodes.AbstractNode
    • canCut

      public boolean canCut()
      Overrides:
      canCut in class org.openide.nodes.AbstractNode
    • createPasteTypes

      protected void createPasteTypes(Transferable t, List<org.openide.util.datatransfer.PasteType> s)
      Overrides:
      createPasteTypes in class org.openide.nodes.AbstractNode
    • createActions

      @Deprecated protected org.openide.util.actions.SystemAction[] createActions()
      Deprecated.
      Use getActions(boolean) or do nothing and let the data loader specify actions.
      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 org.openide.nodes.AbstractNode
      Returns:
      null
    • getActions

      public Action[] getActions(boolean context)
      Get actions for this data object.
      Overrides:
      getActions in class org.openide.nodes.Node
      Returns:
      array of actions or null
      See Also:
    • getActions

      @Deprecated public org.openide.util.actions.SystemAction[] getActions()
      Deprecated.
      Use getActions(boolean)
      Get actions for this data object.
      Overrides:
      getActions in class org.openide.nodes.AbstractNode
      Returns:
      array of actions or null
    • getPreferredAction

      public Action getPreferredAction()
      Get default action. In the current implementation the null is returned in case the underlying data object is a template. The templates should not have any default action.
      Overrides:
      getPreferredAction in class org.openide.nodes.AbstractNode
      Returns:
      no 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 (false) method is used.
    • getCookie

      public <T extends org.openide.nodes.Node.Cookie> T getCookie(Class<T> cl)
      Get a cookie. First of all DataObject.getCookie(Class) is called. If it produces non-null result, that is returned. Otherwise the superclass is tried. Subclassers overriding this method should consider the recommendations in DataObject.createNodeDelegate(). Since version 5.6, if non-null Lookup is passed to the constructor, then this method directly delegates to super.getCookie and does not query data object at all. This is supposed to provide consistency between results in getLookup().lookup and getCookie.
      Overrides:
      getCookie in class org.openide.nodes.AbstractNode
      Returns:
      the cookie or null
    • createSheet

      protected org.openide.nodes.Sheet createSheet()
      Overrides:
      createSheet in class org.openide.nodes.AbstractNode
    • getValue

      public Object getValue(String attributeName)
      Overrides:
      getValue in class FeatureDescriptor
    • clipboardCopy

      public Transferable clipboardCopy() throws IOException
      Copy this node to the clipboard.
      Overrides:
      clipboardCopy in 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
      Cut this node to the clipboard.
      Overrides:
      clipboardCut in class org.openide.nodes.AbstractNode
      Returns:
      ExTransferable.Single with one cut flavor
      Throws:
      IOException - if it could not cut
      See Also:
      • NodeTransfer
    • getHandle

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

      public static boolean getShowFileExtensions()
      Determine whether file extensions should 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.

      Note that this method affects all DataNodes.

      Parameters:
      s - true if so