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, systemActionsFields 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
ConstructorsConstructorDescriptionDataNode(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 TypeMethodDescriptionbooleancanCopy()booleancanCut()booleanIndicate whether the node may be destroyed.booleanIndicate 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.protected voidcreatePasteTypes(Transferable t, List<org.openide.util.datatransfer.PasteType> s) protected org.openide.nodes.Sheetvoiddestroy()Removes the node from its parent, deletes it and fires a property change.org.openide.util.actions.SystemAction[]Deprecated.Use getActions(boolean)Action[]getActions(boolean context) Get actions for this data object.<T extends org.openide.nodes.Node.Cookie>
TGet a cookie.Get the represented data object.Get the display name for the node.org.openide.nodes.Node.HandleHandle for location of given data object.org.openide.util.HelpCtxGet a display name formatted using the limited HTML subset supported byHtmlRenderer.getIcon(int type) Get the displayed icon for this node.getOpenedIcon(int type) Get the displayed icon for this node.Get default action.static booleanDetermine whether file extensions should be shown by default.voidvoidChanges the name of the node and may also rename the data object.static voidsetShowFileExtensions(boolean s) 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, setSheetMethods 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, toStringMethods inherited from class FeatureDescriptor
attributeNames, getName, getShortDescription, isExpert, isHidden, isPreferred, setExpert, setPreferred, setValue
-
Constructor Details
-
DataNode
Create a data node with the given children set for the given data object.- Parameters:
obj- object to work withch- children container for the node- See Also:
-
DataNode
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 withch- children container for the nodelookup- the lookup to provide content ofNode.getLookup()and alsogetCookie(Class)- Since:
- 5.6
- See Also:
-
-
Method Details
-
getDataObject
-
setName
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 objectrename- rename the data object?- Throws:
IllegalArgumentException- if the rename failed
-
setName
- Overrides:
setNamein classorg.openide.nodes.AbstractNode
-
getDisplayName
Get the display name for the node. A filesystem mayspecially alterthis. Subclassers overriding this method should consider the recommendations inDataObject.createNodeDelegate().- Overrides:
getDisplayNamein classFeatureDescriptor- Returns:
- the desired name
-
getHtmlDisplayName
Get a display name formatted using the limited HTML subset supported byHtmlRenderer. If the underlyingStatusDecoratorsupports HTML annotations, this method will return non-null if status information is added.- Overrides:
getHtmlDisplayNamein classorg.openide.nodes.Node- Returns:
- a string containing compliant HTML markup or null
- Since:
- 4.13
- See Also:
-
getIcon
Get the displayed icon for this node. Subclassers overriding this method should consider the recommendations inDataObject.createNodeDelegate().- Overrides:
getIconin classorg.openide.nodes.AbstractNode- Parameters:
type- the icon type fromBeanInfo- Returns:
- the desired icon
-
getOpenedIcon
Get the displayed icon for this node. Subclassers overriding this method should consider the recommendations inDataObject.createNodeDelegate().- Overrides:
getOpenedIconin classorg.openide.nodes.AbstractNode- Parameters:
type- the icon type fromBeanInfo- Returns:
- the desired icon
-
getHelpCtx
public org.openide.util.HelpCtx getHelpCtx()- Specified by:
getHelpCtxin interfaceorg.openide.util.HelpCtx.Provider- Overrides:
getHelpCtxin classorg.openide.nodes.AbstractNode
-
canRename
public boolean canRename()Indicate whether the node may be renamed.- Overrides:
canRenamein classorg.openide.nodes.AbstractNode- Returns:
- tests
DataObject.isRenameAllowed()
-
canDestroy
public boolean canDestroy()Indicate whether the node may be destroyed.- Overrides:
canDestroyin classorg.openide.nodes.AbstractNode- Returns:
- tests
DataObject.isDeleteAllowed()
-
destroy
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:
destroyin classorg.openide.nodes.Node- Throws:
IOException
-
canCopy
public boolean canCopy()- Overrides:
canCopyin classorg.openide.nodes.AbstractNode
-
canCut
public boolean canCut()- Overrides:
canCutin classorg.openide.nodes.AbstractNode
-
createPasteTypes
- Overrides:
createPasteTypesin classorg.openide.nodes.AbstractNode
-
createActions
Deprecated.UsegetActions(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:
createActionsin classorg.openide.nodes.AbstractNode- Returns:
- null
-
getActions
Get actions for this data object.- Overrides:
getActionsin classorg.openide.nodes.Node- Returns:
- array of actions or
null - See Also:
-
getActions
Deprecated.Use getActions(boolean)Get actions for this data object.- Overrides:
getActionsin classorg.openide.nodes.AbstractNode- Returns:
- array of actions or
null
-
getPreferredAction
Get default action. In the current implementation thenullis returned in case the underlying data object is a template. The templates should not have any default action.- Overrides:
getPreferredActionin classorg.openide.nodes.AbstractNode- Returns:
- no action if the underlying data object is a template.
Otherwise the abstract node's default action is returned, if
nullthen the first action returned from getActions (false) method is used.
-
getCookie
Get a cookie. First of allDataObject.getCookie(Class)is called. If it produces non-nullresult, that is returned. Otherwise the superclass is tried. Subclassers overriding this method should consider the recommendations inDataObject.createNodeDelegate(). Since version 5.6, if non-nullLookupis 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 ingetLookup().lookupandgetCookie.- Overrides:
getCookiein classorg.openide.nodes.AbstractNode- Returns:
- the cookie or
null
-
createSheet
protected org.openide.nodes.Sheet createSheet()- Overrides:
createSheetin classorg.openide.nodes.AbstractNode
-
getValue
- Overrides:
getValuein classFeatureDescriptor
-
clipboardCopy
Copy this node to the clipboard.- Overrides:
clipboardCopyin classorg.openide.nodes.AbstractNode- Returns:
ExTransferable.Singlewith one copy flavor- Throws:
IOException- if it could not copy- See Also:
-
clipboardCut
Cut this node to the clipboard.- Overrides:
clipboardCutin classorg.openide.nodes.AbstractNode- Returns:
ExTransferable.Singlewith one cut flavor- Throws:
IOException- if it could not cut- See Also:
-
getHandle
public org.openide.nodes.Node.Handle getHandle()Handle for location of given data object.- Overrides:
getHandlein classorg.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:
trueif 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-trueif so
-
getActions(boolean)or do nothing and let the data loader specify actions.