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 Node
Node.Cookie, Node.Handle, Node.IndexedProperty<T,E>, Node.Property<T>, Node.PropertySet -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected MessageFormatMessage format to use for creation of the display name.protected org.openide.util.actions.SystemAction[]Deprecated.Fields inherited from class 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 TypeMethodDescriptionbooleancanCopy()Can this node be copied?booleancanCut()Can this node be cut?booleanCan this node be destroyed?booleanCan 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 voidcreatePasteTypes(Transferable t, List<org.openide.util.datatransfer.PasteType> s) Accumulate the paste types that this node can handle for a given transferable.protected SheetInitialize 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 CookieSetGet the cookie set.Get the customizer.org.openide.util.actions.SystemActionDeprecated.UsegetPreferredAction()instead.org.openide.util.datatransfer.PasteTypegetDropType(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.HelpCtxGet 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 SheetgetSheet()Get the current property sheet.booleanDoes this node have a customizer?protected final voidDeprecated.just use getCookieSet().add(...) insteadvoidsetDefaultAction(org.openide.util.actions.SystemAction action) Deprecated.OverridegetPreferredAction()instead.voidsetIconBase(String base) Deprecated.final voidsetIconBaseWithExtension(String baseExt) Change the icon.voidSet the system name.protected final voidSet the set of properties.Methods inherited from class 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, toStringMethods inherited from class 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(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(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(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(Class)- Since:
- 3.11
-
-
Method Details
-
cloneNode
Clone the node. If the object implementsCloneable, that is used; otherwise afilter nodeis 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.pngthe following images may be used according to the icon state andpresentation type:org/foo/resource/MyIcon.pngorg/foo/resource/MyIconOpen.pngorg/foo/resource/MyIcon32.pngorg/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:
getOpenedIconin 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:NodeGet context help associated with this node.- Specified by:
getHelpCtxin interfaceorg.openide.util.HelpCtx.Provider- Specified by:
getHelpCtxin classNode- Returns:
- the context help object (could be
nullorHelpCtx.DEFAULT_HELP)
-
canRename
-
canDestroy
public boolean canDestroy()Can this node be destroyed?- Specified by:
canDestroyin 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_SETSchange 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
getSheetin 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(Sheet), that sheet is returned. OtherwisecreateSheet()is called.- Returns:
- the sheet (never
null)
-
getPropertySets
Get a list of property sets.- Specified by:
getPropertySetsin classNode- Returns:
- the property sets for this node
- See Also:
-
clipboardCopy
Copy this node to the clipboard.- Specified by:
clipboardCopyin classNode- Returns:
ExTransferable.Singlewith one copy flavor- Throws:
IOException- if it could not copy- See Also:
-
clipboardCut
Cut this node to the clipboard.- Specified by:
clipboardCutin classNode- Returns:
ExTransferable.Singlewith 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:
dragin 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(Transferable), and if so, it obtains the paste types from thetransfer dataand 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
AbstractNodeis generally desirable to retain.- Parameters:
t- a transferable containing clipboard datas- a list ofPasteTypes 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(Transferable, List).- Specified by:
getPasteTypesin 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:
getDropTypein 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:NodeGet 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:
getNewTypesin classNode- Returns:
- array of new type operations that are allowed
-
getPreferredAction
Gets preferred action. By default, null.- Overrides:
getPreferredActionin classNode- Returns:
- preferred action
- Since:
- 3.29
- See Also:
-
getDefaultAction
Deprecated.UsegetPreferredAction()instead.Gets the default action. Overrides superclass method.- Overrides:
getDefaultActionin 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, ornullfor none
-
getActions
Deprecated.OverrideNode.getActions(boolean)instead.Get all actions for the node. Initialized withcreateActions(), or with the superclass's list.- Overrides:
getActionsin 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
nullto use the default node actions
-
hasCustomizer
public boolean hasCustomizer()Does this node have a customizer?- Specified by:
hasCustomizerin classNode- Returns:
false
-
getCustomizer
Get the customizer.- Specified by:
getCustomizerin classNode- Returns:
nullin 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_COOKIEchange 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(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:
getHandlein classNode- Returns:
- a
DefaultHandlein the default implementation
-
Node.getActions(boolean)instead of using this field.