|
org.openide.nodes 6.7.22 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.beans.FeatureDescriptor org.openide.nodes.Node org.openide.nodes.AbstractNode
public class 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.
Nested Class Summary |
---|
Nested classes/interfaces 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_LEAF, 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. |
|
AbstractNode(Children children,
Lookup lookup)
Create a new abstract node with a given child set and associated lookup. |
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()
Deprecated. Override Node.getActions(boolean) instead. |
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()
Deprecated. Override Node.getActions(boolean) instead. |
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()
Deprecated. Use 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 getPreferredAction() instead. |
void |
setIconBase(String base)
Deprecated. Use setIconBaseWithExtension(java.lang.String) |
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. |
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 |
---|
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 nodepublic AbstractNode(Children children, Lookup lookup)
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 getCookie(java.lang.Class)
Method Detail |
---|
public Node cloneNode()
Cloneable
,
that is used; otherwise a filter node
is created.
public void setName(String s)
displayFormat
.
s
- the new namepublic void setIconBase(String base)
setIconBaseWithExtension(java.lang.String)
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 getIcon(int type)
icon set
.
type
- constants from BeanInfo
public Image getOpenedIcon(int type)
getOpenedIcon
in class Node
type
- as in 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()
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 flavor
IOException
- if it could not copyNodeTransfer
public Transferable clipboardCut() throws IOException
clipboardCut
in class Node
ExTransferable.Single
with one cut flavor
IOException
- if it could not cutNodeTransfer
public Transferable drag() throws IOException
IOException
- when the
cut cannot be performedpublic boolean canCopy()
public boolean canCut()
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 clipboard
public 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 specified
public NewType[] getNewTypes()
Node
getNewTypes
in class Node
public Action getPreferredAction()
getPreferredAction
in class Node
Node.getPreferredAction()
public SystemAction getDefaultAction()
getPreferredAction()
instead.
getDefaultAction
in class Node
public void setDefaultAction(SystemAction action)
getPreferredAction()
instead.
action
- the new default action, or null
for nonepublic SystemAction[] getActions()
Node.getActions(boolean)
instead.
createActions()
, or with the superclass's list.
getActions
in class Node
protected SystemAction[] createActions()
Node.getActions(boolean)
instead.
null
.
Warning: do not call 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 implementationprotected final void setCookieSet(CookieSet s)
Node.PROP_COOKIE
change events.
s
- the cookie set to use
IllegalStateException
- If you pass a Lookup instance into the constructor, this
method cannot be called.protected final CookieSet getCookieSet()
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 Node.Cookie getCookie(Class type)
getCookieSet()
.
type
- the representation class
null
Lookup
public Node.Handle getHandle()
DefaultHandle
in the default implementation
|
org.openide.nodes 6.7.22 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |