|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.beans.FeatureDescriptor | +--org.openide.nodes.Node | +--org.openide.nodes.AbstractNode
A basic implementation of a 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.
Inner classes inherited from class org.openide.nodes.Node |
Node.Cookie, Node.Handle, Node.IndexedProperty, Node.Property, Node.PropertySet |
Field Summary | |
protected MessageFormat |
displayFormat
Message format to use for creation of the display name. |
protected SystemAction[] |
systemActions
Actions for the node. |
Fields inherited from class org.openide.nodes.Node |
EMPTY, PROP_COOKIE, PROP_DISPLAY_NAME, PROP_ICON, PROP_NAME, PROP_OPENED_ICON, PROP_PARENT_NODE, PROP_PROPERTY_SETS, PROP_SHORT_DESCRIPTION |
Constructor Summary | |
AbstractNode(Children children)
Create a new abstract node with a given child set. |
Method Summary | |
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()
Lazily initialize set of node's actions (overridable). |
protected void |
createPasteTypes(Transferable t,
List 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()
Get all actions for the node. |
Node.Cookie |
getCookie(Class type)
Get a cookie from the node. |
protected CookieSet |
getCookieSet()
Get the cookie set. |
Component |
getCustomizer()
Get the customizer. |
SystemAction |
getDefaultAction()
Get the default action for this node. |
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. |
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)
Set a default action for the node. |
void |
setIconBase(String base)
Change the icon. |
void |
setName(String s)
Set the system name. |
protected void |
setSheet(Sheet s)
Set the set of properties. |
Methods inherited from class java.beans.FeatureDescriptor |
attributeNames, getDisplayName, getName, getShortDescription, getValue, isExpert, isHidden, isPreferred, setExpert, setHidden, setPreferred, setValue |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
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 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.
protected SystemAction[] systemActions
Constructor Detail |
public AbstractNode(Children children)
children
- the children to use for this nodeMethod Detail |
public Node cloneNode()
Cloneable
,
that is used; otherwise a filter node
is created.cloneNode
in class Node
public void setName(String s)
displayFormat
.setName
in class Node
s
- the new namepublic void setIconBase(String base)
For example, for the base /resource/MyIcon
, the
following images may be used according to the icon state and
presentation type
:
/resource/MyIcon.gif
/resource/MyIconOpen.gif
/resource/MyIcon32.gif
/resource/MyIconOpen32.gif
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.
base
- base resouce namepublic Image getIcon(int type)
icon set
.getIcon
in class Node
type
- constants from BeanInfo
public Image getOpenedIcon(int type)
getOpenedIcon
in class Node
type
- as in getIcon(int)
public HelpCtx getHelpCtx()
Node
getHelpCtx
in class Node
org.openide.nodes.Node
null
or HelpCtx.DEFAULT_HELP
)public boolean canRename()
canRename
in class Node
false
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()
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()
setSheet(org.openide.nodes.Sheet)
, that sheet
is returned. Otherwise createSheet()
is called.null
)public Node.PropertySet[] getPropertySets()
getPropertySets
in class Node
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()
canCopy
in class Node
true
public boolean canCut()
canCut
in class Node
false
protected void createPasteTypes(Transferable t, List 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)
createPasteTypes(java.awt.datatransfer.Transferable, java.util.List)
.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
org.openide.nodes.Node
public SystemAction getDefaultAction()
Node
Node.getActions()
. If so, the popup menu returned from Node.getContextMenu()
is encouraged to highlight the action.getDefaultAction
in class Node
org.openide.nodes.Node
null
if there should be nonepublic void setDefaultAction(SystemAction action)
action
- the new default action, or null
for nonepublic SystemAction[] getActions()
createActions()
, or with the superclass's list.getActions
in class Node
protected SystemAction[] createActions()
null
.
Warning: do not call getActions()
within this method.
If necessary, call NodeOp.getDefaultActions()
to merge in.
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 implementationprotected final void setCookieSet(CookieSet s)
Node.PROP_COOKIE
change events.s
- the cookie set to useprotected final CookieSet getCookieSet()
setCookieSet(org.openide.nodes.CookieSet)
, or an empty set (never null
)public Node.Cookie getCookie(Class type)
getCookieSet()
.getCookie
in class Node
type
- the representation classnull
public Node.Handle getHandle()
getHandle
in class Node
DefaultHandle
in the default implementation
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |