Class AbstractNode
- All Implemented Interfaces:
org.openide.util.HelpCtx.Provider
,org.openide.util.Lookup.Provider
- Direct Known Subclasses:
BeanNode
,IndexedNode
It simplifies creation of the display name, based on a message format and the system name. It also simplifies working with icons: one need only specify the base name and all icons will be loaded when needed. Other common requirements are handled as well.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.openide.nodes.Node
Node.Cookie, Node.Handle, Node.IndexedProperty<T,
E>, Node.Property<T>, Node.PropertySet -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected MessageFormat
Message format to use for creation of the display name.protected org.openide.util.actions.SystemAction[]
Deprecated.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
ConstructorsConstructorDescriptionAbstractNode
(Children children) Create a new abstract node with a given child set.AbstractNode
(Children children, org.openide.util.Lookup lookup) Create a new abstract node with a given child set and associated lookup. -
Method Summary
Modifier and TypeMethodDescriptionboolean
canCopy()
Can this node be copied?boolean
canCut()
Can this node be cut?boolean
Can this node be destroyed?boolean
Can this node be renamed?Copy this node to the clipboard.Cut this node to the clipboard.Clone the node.protected org.openide.util.actions.SystemAction[]
Deprecated.OverrideNode.getActions(boolean)
instead.protected void
createPasteTypes
(Transferable t, List<org.openide.util.datatransfer.PasteType> s) Accumulate the paste types that this node can handle for a given transferable.protected Sheet
Initialize a default property sheet; commonly overridden.drag()
This implementation only calls clipboardCopy supposing that copy to clipboard and copy by d'n'd are similar.org.openide.util.actions.SystemAction[]
Deprecated.OverrideNode.getActions(boolean)
instead.<T extends Node.Cookie>
TGet a cookie from the node.protected final CookieSet
Get the cookie set.Get the customizer.org.openide.util.actions.SystemAction
Deprecated.UsegetPreferredAction()
instead.org.openide.util.datatransfer.PasteType
getDropType
(Transferable t, int action, int index) Default implementation that tries to delegate the implementation to the createPasteTypes method.Get a serializable handle for this node.org.openide.util.HelpCtx
Get context help associated with this node.getIcon
(int type) Find an icon for this node.org.openide.util.datatransfer.NewType[]
Get the new types that can be created in this node.getOpenedIcon
(int type) Finds an icon for this node when opened.final org.openide.util.datatransfer.PasteType[]
Determine which paste operations are allowed when a given transferable is in the clipboard.Gets preferred action.Get a list of property sets.protected final Sheet
getSheet()
Get the current property sheet.boolean
Does this node have a customizer?protected final void
Deprecated.just use getCookieSet().add(...) insteadvoid
setDefaultAction
(org.openide.util.actions.SystemAction action) Deprecated.OverridegetPreferredAction()
instead.void
setIconBase
(String base) Deprecated.final void
setIconBaseWithExtension
(String baseExt) Change the icon.void
Set the system name.protected final void
Set the set of properties.Methods inherited from class org.openide.nodes.Node
addNodeListener, addPropertyChangeListener, clone, destroy, equals, fireCookieChange, fireDisplayNameChange, fireIconChange, fireNameChange, fireNodeDestroyed, fireOpenedIconChange, firePropertyChange, firePropertySetsChange, fireShortDescriptionChange, getActions, getChildren, getContextActions, getContextMenu, getHtmlDisplayName, getLookup, getParentNode, hashCode, hasPropertyChangeListener, isLeaf, removeNodeListener, removePropertyChangeListener, setChildren, setDisplayName, setHidden, setShortDescription, toString
Methods inherited from class java.beans.FeatureDescriptor
attributeNames, getDisplayName, getName, getShortDescription, getValue, isExpert, isHidden, isPreferred, setExpert, setPreferred, setValue
-
Field Details
-
displayFormat
Message format to use for creation of the display name. It permits conversion of text fromFeatureDescriptor.getName()
to the one sent toNode.setDisplayName(java.lang.String)
. The format can take one parameter,{0}
, which will be filled by a value fromgetName()
.The default format just uses the simple name; subclasses may change it, though it will not take effect until the next
setName(java.lang.String)
call.Can be set to
null
. Then there is no connection between the name and display name; they may be independently modified. -
systemActions
Deprecated.OverrideNode.getActions(boolean)
instead of using this field.Actions for the node. They are used only for the pop-up menus of this node.
-
-
Constructor Details
-
AbstractNode
Create a new abstract node with a given child set.- Parameters:
children
- the children to use for this node
-
AbstractNode
Create a new abstract node with a given child set and associated lookup. If you use this constructor, please do not call methodsgetCookieSet()
andsetCookieSet(org.openide.nodes.CookieSet)
they will throw an exception.More info on the correct usage of constructor with Lookup can be found in the
Node(org.openide.nodes.Children, org.openide.util.Lookup)
javadoc.- Parameters:
children
- the children to use for this nodelookup
- the lookup to provide content ofNode.getLookup()
and alsogetCookie(java.lang.Class<T>)
- Since:
- 3.11
-
-
Method Details
-
cloneNode
Clone the node. If the object implementsCloneable
, that is used; otherwise afilter node
is created. -
setName
Set the system name. Fires a property change event. Also may change the display name according todisplayFormat
. -
setIconBase
Deprecated.Change the icon. One need only specify the base resource name without extension; the real name of the icon is obtained by the applying icon message formats. The method effectively behaves as if it was just delegating tosetIconBaseWithExtension(java.lang.String)
usingbase + ".gif"
as parameter.- Parameters:
base
- base resouce name (no initial slash)
-
setIconBaseWithExtension
Change the icon. One need only specify the base name of the icon resource, including the resource extension; the real name of the icon is obtained by inserting proper infixes into the resource name.For example, for the base
org/foo/resource/MyIcon.png
the following images may be used according to the icon state andpresentation type
:org/foo/resource/MyIcon.png
org/foo/resource/MyIconOpen.png
org/foo/resource/MyIcon32.png
org/foo/resource/MyIconOpen32.png
This method may be used to dynamically switch between different sets of icons for different configurations. If the set is changed, an icon property change event is fired.
- Parameters:
baseExt
- base resouce name with extension (no initial slash)- Since:
- org.openide.nodes 6.5
-
getIcon
-
getOpenedIcon
Finds an icon for this node when opened. This icon should represent the node only when it is opened (when it can have children).- Specified by:
getOpenedIcon
in classNode
- Parameters:
type
- as ingetIcon(int)
- Returns:
- icon to use to represent the bean when opened
-
getHelpCtx
public org.openide.util.HelpCtx getHelpCtx()Description copied from class:Node
Get context help associated with this node.- Specified by:
getHelpCtx
in interfaceorg.openide.util.HelpCtx.Provider
- Specified by:
getHelpCtx
in classNode
- Returns:
- the context help object (could be
null
orHelpCtx.DEFAULT_HELP
)
-
canRename
-
canDestroy
public boolean canDestroy()Can this node be destroyed?- Specified by:
canDestroy
in classNode
- Returns:
false
-
setSheet
Set the set of properties. A listener is attached to the provided sheet and any change of the sheet is propagated to the node by firing aNode.PROP_PROPERTY_SETS
change event.- Parameters:
s
- the sheet to use
-
createSheet
Initialize a default property sheet; commonly overridden. IfgetSheet()
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.
- Returns:
- the sheet with initialized values (never
null
)
-
getSheet
Get the current property sheet. If the sheet has been previously set by a call tosetSheet(org.openide.nodes.Sheet)
, that sheet is returned. OtherwisecreateSheet()
is called.- Returns:
- the sheet (never
null
)
-
getPropertySets
Get a list of property sets.- Specified by:
getPropertySets
in classNode
- Returns:
- the property sets for this node
- See Also:
-
clipboardCopy
Copy this node to the clipboard.- Specified by:
clipboardCopy
in classNode
- Returns:
ExTransferable.Single
with one copy flavor- Throws:
IOException
- if it could not copy- See Also:
-
clipboardCut
Cut this node to the clipboard.- Specified by:
clipboardCut
in classNode
- Returns:
ExTransferable.Single
with one cut flavor- Throws:
IOException
- if it could not cut- See Also:
-
drag
This implementation only calls clipboardCopy supposing that copy to clipboard and copy by d'n'd are similar.- Specified by:
drag
in classNode
- Returns:
- transferable to represent this node during a drag
- Throws:
IOException
- when the cut cannot be performed
-
canCopy
-
canCut
-
createPasteTypes
Accumulate the paste types that this node can handle for a given transferable.The default implementation simply tests whether the transferable supports intelligent pasting via
NodeTransfer.findPaste(java.awt.datatransfer.Transferable)
, and if so, it obtains the paste types from thetransfer data
and inserts them into the set.Subclass implementations should typically call super (first or last) so that they add to, rather than replace, a superclass's available paste types; especially as the default implementation in
AbstractNode
is generally desirable to retain.- Parameters:
t
- a transferable containing clipboard datas
- a list ofPasteType
s that will have added to it all types valid for this node (ordered as they will be presented to the user)
-
getPasteTypes
Determine which paste operations are allowed when a given transferable is in the clipboard. Subclasses should overridecreatePasteTypes(java.awt.datatransfer.Transferable, java.util.List<org.openide.util.datatransfer.PasteType>)
.- Specified by:
getPasteTypes
in classNode
- Parameters:
t
- the transferable in the clipboard- Returns:
- array of operations that are allowed
-
getDropType
Default implementation that tries to delegate the implementation to the createPasteTypes method. Simply calls the method and tries to take the first provided argument. Ignores the action argument and index.- Specified by:
getDropType
in classNode
- Parameters:
t
- the transferableaction
- the drag'n'drop action to do DnDConstants.ACTION_MOVE, ACTION_COPY, ACTION_LINKindex
- index between children the drop occured at or -1 if not specified- Returns:
- null if the transferable cannot be accepted or the paste type to execute when the drop occures
-
getNewTypes
public org.openide.util.datatransfer.NewType[] getNewTypes()Description copied from class:Node
Get the new types that can be created in this node. For example, a node representing a Java package will permit classes to be added.- Specified by:
getNewTypes
in classNode
- Returns:
- array of new type operations that are allowed
-
getPreferredAction
Gets preferred action. By default, null.- Overrides:
getPreferredAction
in classNode
- Returns:
- preferred action
- Since:
- 3.29
- See Also:
-
getDefaultAction
Deprecated.UsegetPreferredAction()
instead.Gets the default action. Overrides superclass method.- Overrides:
getDefaultAction
in classNode
- Returns:
- if there is a default action set, then returns it
-
setDefaultAction
Deprecated.OverridegetPreferredAction()
instead.Set a default action for the node.- Parameters:
action
- the new default action, ornull
for none
-
getActions
Deprecated.OverrideNode.getActions(boolean)
instead.Get all actions for the node. Initialized withcreateActions()
, or with the superclass's list.- Overrides:
getActions
in classNode
- Returns:
- actions for the node
-
createActions
Deprecated.OverrideNode.getActions(boolean)
instead.Lazily initialize set of node's actions (overridable). The default implementation returnsnull
.Warning: do not call
getActions()
within this method.- Returns:
- array of actions for this node, or
null
to use the default node actions
-
hasCustomizer
public boolean hasCustomizer()Does this node have a customizer?- Specified by:
hasCustomizer
in classNode
- Returns:
false
-
getCustomizer
Get the customizer.- Specified by:
getCustomizer
in classNode
- Returns:
null
in the default implementation
-
setCookieSet
Deprecated.just use getCookieSet().add(...) insteadSet the cookie set. A listener is attached to the provided cookie set, and any change of the sheet is propagated to the node by firingNode.PROP_COOKIE
change events.- Parameters:
s
- the cookie set to use- Throws:
IllegalStateException
- If you pass a Lookup instance into the constructor, this method cannot be called.
-
getCookieSet
Get the cookie set.- Returns:
- the cookie set created by
setCookieSet(org.openide.nodes.CookieSet)
, or an empty set (nevernull
) - Throws:
IllegalStateException
- If you pass a Lookup instance into the constructor, this method cannot be called.
-
getCookie
Get a cookie from the node. Uses the cookie set as determined bygetCookieSet()
. -
getHandle
Get a serializable handle for this node.- Specified by:
getHandle
in classNode
- Returns:
- a
DefaultHandle
in the default implementation
-
Node.getActions(boolean)
instead of using this field.