public class AbstractNode extends Node
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.
Node.Cookie, Node.Handle, Node.IndexedProperty<T,E>, Node.Property<T>, Node.PropertySet
Modifier and Type | Field and Description |
---|---|
protected MessageFormat |
displayFormat
Message format to use for creation of the display name.
|
protected SystemAction[] |
systemActions
Deprecated.
Override
Node.getActions(boolean) instead of using
this field. |
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 and Description |
---|
AbstractNode(Children children)
Create a new abstract node with a given child set.
|
AbstractNode(Children children,
Lookup lookup)
Create a new abstract node with a given child set and associated
lookup.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canCopy()
Can this node be copied?
|
boolean |
canCut()
Can this node be cut?
|
boolean |
canDestroy()
Can this node be destroyed?
|
boolean |
canRename()
Can this node be renamed?
|
Transferable |
clipboardCopy()
Copy this node to the clipboard.
|
Transferable |
clipboardCut()
Cut this node to the clipboard.
|
Node |
cloneNode()
Clone the node.
|
protected SystemAction[] |
createActions()
Deprecated.
Override
Node.getActions(boolean) instead. |
protected void |
createPasteTypes(Transferable t,
List<PasteType> s)
Accumulate the paste types that this node can handle
for a given transferable.
|
protected Sheet |
createSheet()
Initialize a default
property sheet; commonly overridden.
|
Transferable |
drag()
This implementation only calls clipboardCopy supposing that
copy to clipboard and copy by d'n'd are similar.
|
SystemAction[] |
getActions()
Deprecated.
Override
Node.getActions(boolean) instead. |
<T extends Node.Cookie> |
getCookie(Class<T> type)
Get a cookie from the node.
|
protected CookieSet |
getCookieSet()
Get the cookie set.
|
Component |
getCustomizer()
Get the customizer.
|
SystemAction |
getDefaultAction()
Deprecated.
Use
AbstractNode.getPreferredAction() instead. |
PasteType |
getDropType(Transferable t,
int action,
int index)
Default implementation that tries to delegate the implementation
to the createPasteTypes method.
|
Node.Handle |
getHandle()
Get a serializable handle for this node.
|
HelpCtx |
getHelpCtx()
Get context help associated with this node.
|
Image |
getIcon(int type)
Find an icon for this node.
|
NewType[] |
getNewTypes()
Get the new types that can be created in this node.
|
Image |
getOpenedIcon(int type)
Finds an icon for this node when opened.
|
PasteType[] |
getPasteTypes(Transferable t)
Determine which paste operations are allowed when a given transferable is in the clipboard.
|
Action |
getPreferredAction()
Gets preferred action.
|
Node.PropertySet[] |
getPropertySets()
Get a list of property sets.
|
protected Sheet |
getSheet()
Get the current property sheet.
|
boolean |
hasCustomizer()
Does this node have a customizer?
|
protected void |
setCookieSet(CookieSet s)
Deprecated.
just use getCookieSet().add(...) instead
|
void |
setDefaultAction(SystemAction action)
Deprecated.
Override
AbstractNode.getPreferredAction() instead. |
void |
setIconBase(String base)
Deprecated.
|
void |
setIconBaseWithExtension(String baseExt)
Change the icon.
|
void |
setName(String s)
Set the system name.
|
protected void |
setSheet(Sheet s)
Set the set of properties.
|
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
attributeNames, getDisplayName, getName, getShortDescription, getValue, isExpert, isHidden, isPreferred, setExpert, setPreferred, setValue
protected MessageFormat displayFormat
FeatureDescriptor.getName()
to the one sent to Node.setDisplayName(java.lang.String)
. The format can take
one parameter, {0}
, which will be filled by a value from getName()
.
The default format just uses the simple name; subclasses may
change it, though it will not take effect until the next AbstractNode.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.
@Deprecated protected SystemAction[] systemActions
Node.getActions(boolean)
instead of using
this field.public AbstractNode(Children children)
children
- the children to use for this nodepublic AbstractNode(Children children, Lookup lookup)
AbstractNode.getCookieSet()
and AbstractNode.setCookieSet(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.Node(org.openide.nodes.Children, org.openide.util.Lookup)
javadoc.
children
- the children to use for this nodelookup
- the lookup to provide content of Node.getLookup()
and also AbstractNode.getCookie(java.lang.Class<T>)
public Node cloneNode()
Cloneable
,
that is used; otherwise a filter node
is created.public void setName(String s)
AbstractNode.displayFormat
.@Deprecated public void setIconBase(String base)
AbstractNode.setIconBaseWithExtension(java.lang.String)
AbstractNode.setIconBaseWithExtension(java.lang.String)
using base + ".gif"
as parameter.base
- base resouce name (no initial slash)public final void setIconBaseWithExtension(String baseExt)
For example, for the base org/foo/resource/MyIcon.png
the following images may be used according to the icon
state and presentation 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.
baseExt
- base resouce name with extension (no initial slash)public Image getOpenedIcon(int type)
getOpenedIcon
in class Node
type
- as in AbstractNode.getIcon(int)
public HelpCtx getHelpCtx()
Node
getHelpCtx
in interface HelpCtx.Provider
getHelpCtx
in class Node
null
or HelpCtx.DEFAULT_HELP
)public boolean canRename()
public boolean canDestroy()
canDestroy
in class Node
false
protected final void setSheet(Sheet s)
Node.PROP_PROPERTY_SETS
change event.s
- the sheet to useprotected Sheet createSheet()
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.
null
)protected final Sheet getSheet()
AbstractNode.setSheet(org.openide.nodes.Sheet)
, that sheet
is returned. Otherwise AbstractNode.createSheet()
is called.null
)public Node.PropertySet[] getPropertySets()
getPropertySets
in class Node
AbstractNode.getSheet()
public Transferable clipboardCopy() throws IOException
clipboardCopy
in class Node
ExTransferable.Single
with one copy flavorIOException
- if it could not copyNodeTransfer
public Transferable clipboardCut() throws IOException
clipboardCut
in class Node
ExTransferable.Single
with one cut flavorIOException
- if it could not cutNodeTransfer
public Transferable drag() throws IOException
drag
in class Node
IOException
- when the
cut cannot be performedpublic boolean canCopy()
public boolean canCut()
protected void createPasteTypes(Transferable t, List<PasteType> s)
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 the transfer 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.
t
- a transferable containing clipboard datas
- a list of PasteType
s that will have added to it all types
valid for this node (ordered as they will be presented to the user)public final PasteType[] getPasteTypes(Transferable t)
AbstractNode.createPasteTypes(java.awt.datatransfer.Transferable, java.util.List<org.openide.util.datatransfer.PasteType>)
.getPasteTypes
in class Node
t
- the transferable in the clipboardpublic PasteType getDropType(Transferable t, int action, int index)
getDropType
in class Node
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 specifiedpublic NewType[] getNewTypes()
Node
getNewTypes
in class Node
public Action getPreferredAction()
getPreferredAction
in class Node
Node.getPreferredAction()
@Deprecated public SystemAction getDefaultAction()
AbstractNode.getPreferredAction()
instead.getDefaultAction
in class Node
@Deprecated public void setDefaultAction(SystemAction action)
AbstractNode.getPreferredAction()
instead.action
- the new default action, or null
for none@Deprecated public SystemAction[] getActions()
Node.getActions(boolean)
instead.AbstractNode.createActions()
, or with the superclass's list.getActions
in class Node
@Deprecated protected SystemAction[] createActions()
Node.getActions(boolean)
instead.null
.
Warning: do not call AbstractNode.getActions()
within this method.
null
to use the default node actionspublic boolean hasCustomizer()
hasCustomizer
in class Node
false
public Component getCustomizer()
getCustomizer
in class Node
null
in the default implementation@Deprecated protected final void setCookieSet(CookieSet s)
Node.PROP_COOKIE
change events.s
- the cookie set to useIllegalStateException
- If you pass a Lookup instance into the constructor, this
method cannot be called.protected final CookieSet getCookieSet()
AbstractNode.setCookieSet(org.openide.nodes.CookieSet)
, or an empty set (never null
)IllegalStateException
- If you pass a Lookup instance into the constructor, this
method cannot be called.public <T extends Node.Cookie> T getCookie(Class<T> type)
AbstractNode.getCookieSet()
.public Node.Handle getHandle()
getHandle
in class Node
DefaultHandle
in the default implementation