|
||||||||||
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.FilterNode
A proxy for another node.
Unless otherwise mentioned, all methods of the original node are delegated to.
If desired, you can disable delegation of certain methods which are concrete in Node
by calling disableDelegation(int)
.
Note: it is fine to subclass this class and use
it to filter things. But please do not ever try to cast a node to
FilterNode
: it probably means you are doing something
wrong. Instead, ask whatever Node
you have for a proper
kind of cookie (e.g. DataObject
).
Inner Class Summary | |
static class |
FilterNode.Children
Children for a filter node. |
protected static class |
FilterNode.NodeAdapter
Adapter that listens on changes in an original node and refires them in a proxy. |
protected static class |
FilterNode.PropertyChangeAdapter
Adapter that listens on changes in an original node and refires them in a proxy. |
Inner classes inherited from class org.openide.nodes.Node |
Node.Cookie, Node.Handle, Node.IndexedProperty, Node.Property, Node.PropertySet |
Field Summary | |
protected static int |
DELEGATE_DESTROY
Whether to delegate destroy . |
protected static int |
DELEGATE_GET_ACTIONS
Whether to delegate getActions . |
protected static int |
DELEGATE_GET_CONTEXT_ACTIONS
Whether to delegate getContextActions . |
protected static int |
DELEGATE_GET_DISPLAY_NAME
Whether to delegate getDisplayName . |
protected static int |
DELEGATE_GET_NAME
Whether to delegate getName . |
protected static int |
DELEGATE_GET_SHORT_DESCRIPTION
Whether to delegate getShortDescription . |
protected static int |
DELEGATE_SET_DISPLAY_NAME
Whether to delegate setDisplayName . |
protected static int |
DELEGATE_SET_NAME
Whether to delegate setName . |
protected static int |
DELEGATE_SET_SHORT_DESCRIPTION
Whether to delegate setShortDescription . |
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 | |
FilterNode(Node original)
Create proxy. |
|
FilterNode(Node original,
Children children)
Create proxy with a different set of children. |
Method Summary | |
boolean |
canCopy()
Test whether this node permits copying. |
boolean |
canCut()
Test whether this node permits cutting. |
boolean |
canDestroy()
Test whether this node can be deleted. |
boolean |
canRename()
Test whether this node can be renamed. |
protected void |
changeOriginal(Node original,
boolean changeChildren)
Changes the original node for this node. |
Transferable |
clipboardCopy()
Called when a node is to be copied to the clipboard. |
Transferable |
clipboardCut()
Called when a node is to be cut to the clipboard. |
Node |
cloneNode()
Create new filter node for the original. |
protected NodeListener |
createNodeListener()
Creates a node listener that allows listening on the original node and propagating events to the proxy. |
protected PropertyChangeListener |
createPropertyChangeListener()
Create a property change listener that allows listening on the original node properties (contained in property sets) and propagating them to the proxy. |
void |
destroy()
Remove the node from its parent and deletes it. |
protected void |
disableDelegation(int mask)
Disable delegation of a set of methods. |
Transferable |
drag()
Called when a drag is started with this node. |
protected void |
enableDelegation(int mask)
Enable delegation of a set of methods. |
boolean |
equals(Object o)
Test equality of original nodes. |
protected void |
finalize()
Removes all listeners (property and node) on the original node. |
SystemAction[] |
getActions()
Get the set of actions associated with this node. |
SystemAction[] |
getContextActions()
Get a special set of actions for situations when this node is displayed as a context. |
Node.Cookie |
getCookie(Class type)
Get a cookie for this node. |
Component |
getCustomizer()
Get the customizer component. |
SystemAction |
getDefaultAction()
Get the default action for this node. |
String |
getDisplayName()
|
PasteType |
getDropType(Transferable t,
int action,
int index)
Determine if there is a paste operation that can be performed on provided transferable. |
Node.Handle |
getHandle()
If this is FilterNode without any changes (subclassed, changed children) and the original provides handle, stores them and returns a new handle for the proxy. |
HelpCtx |
getHelpCtx()
Get context help associated with this node. |
Image |
getIcon(int type)
Find an icon for this node (in the closed state). |
String |
getName()
|
NewType[] |
getNewTypes()
Get the new types that can be created in this node. |
Image |
getOpenedIcon(int type)
Find an icon for this node (in the open state). |
protected Node |
getOriginal()
Get the original node. |
PasteType[] |
getPasteTypes(Transferable t)
Determine which paste operations are allowed when a given transferable is in the clipboard. |
Node.PropertySet[] |
getPropertySets()
Get the list of property sets for this node. |
String |
getShortDescription()
|
boolean |
hasCustomizer()
Test whether there is a customizer for this node. |
int |
hashCode()
Hash by original nodes. |
void |
setDisplayName(String s)
Set the display name. |
void |
setName(String s)
Set the system name. |
void |
setShortDescription(String s)
Set the short description of the node. |
Methods inherited from class org.openide.nodes.Node |
addNodeListener, addPropertyChangeListener, clone, fireCookieChange, fireDisplayNameChange, fireIconChange, fireNameChange, fireNodeDestroyed, fireOpenedIconChange, firePropertyChange, firePropertySetsChange, fireShortDescriptionChange, getChildren, getContextMenu, getParentNode, hasPropertyChangeListener, isLeaf, removeNodeListener, removePropertyChangeListener, toString |
Methods inherited from class java.beans.FeatureDescriptor |
attributeNames, getValue, isExpert, isHidden, isPreferred, setExpert, setHidden, setPreferred, setValue |
Methods inherited from class java.lang.Object |
getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
protected static final int DELEGATE_SET_NAME
setName
.protected static final int DELEGATE_GET_NAME
getName
.protected static final int DELEGATE_SET_DISPLAY_NAME
setDisplayName
.protected static final int DELEGATE_GET_DISPLAY_NAME
getDisplayName
.protected static final int DELEGATE_SET_SHORT_DESCRIPTION
setShortDescription
.protected static final int DELEGATE_GET_SHORT_DESCRIPTION
getShortDescription
.protected static final int DELEGATE_DESTROY
destroy
.protected static final int DELEGATE_GET_ACTIONS
getActions
.protected static final int DELEGATE_GET_CONTEXT_ACTIONS
getContextActions
.Constructor Detail |
public FilterNode(Node original)
original
- the node to delegate topublic FilterNode(Node original, Children children)
original
- the node to delegate tochildren
- a set of children for this nodeMethod Detail |
protected void finalize()
NodeListener.nodeDestroyed(org.openide.nodes.NodeEvent)
,
but can be called by any subclass to stop reflecting changes
in the original node.finalize
in class Object
protected final void enableDelegation(int mask)
mask
- bitwise disjunction of DELEGATE_XXX
constantsIllegalArgumentException
- if the mask is invalidprotected final void disableDelegation(int mask)
Node
.
For example, if you wish to subclass FilterNode
, giving your
node a distinctive display name and tooltip, and performing some special
action upon deletion, you may do so without risk of affecting the original
node as follows:
public MyNode extends FilterNode {
public MyNode (Node orig) {
super (orig, new MyChildren (orig));
disableDelegation (DELEGATE_GET_DISPLAY_NAME | DELEGATE_SET_DISPLAY_NAME |
DELEGATE_GET_SHORT_DESCRIPTION | DELEGATE_SET_SHORT_DESCRIPTION |
DELEGATE_DESTROY);
// these will affect only the filter node:
setDisplayName ("Linking -> " + orig.getDisplayName ());
setShortDescription ("Something different.");
}
public boolean canRename () { return false; }
public void destroy () throws IOException {
doMyCleanup ();
super.destroy (); // calls Node.destroy(), not orig.destroy()
}
}
You may still manually delegate where desired using getOriginal()
.
Other methods abstract in Node
may simply be overridden without
any special handling.
mask
- bitwise disjunction of DELEGATE_XXX
constantsIllegalArgumentException
- if the mask is invalidpublic Node cloneNode()
cloneNode
in class Node
protected final void changeOriginal(Node original, boolean changeChildren)
original
- The new original node.changeChildren
- If set to true
changes children
of this node according to the new original node. If you pass
children which are not instance of class
FilterNode.Children
into the constructor set this
parameter to false
.IllegalStateException
- if children which are not
instance of FilterNode.Children
were passed
into the constructor and the method was called with the parameter
changeChildren
set to true
.public void setName(String s)
Node
setName
in class Node
org.openide.nodes.Node
s
- the new nameIllegalArgumentException
- if the new name cannot represent
a valid node namepublic String getName()
getName
in class FeatureDescriptor
public void setDisplayName(String s)
Node
setDisplayName
in class Node
org.openide.nodes.Node
s
- the new namepublic String getDisplayName()
getDisplayName
in class FeatureDescriptor
public void setShortDescription(String s)
Node
This description may be used for tool tips, etc.
setShortDescription
in class Node
org.openide.nodes.Node
s
- the new descriptionpublic String getShortDescription()
getShortDescription
in class FeatureDescriptor
public Image getIcon(int type)
Node
getIcon
in class Node
org.openide.nodes.Node
type
- constant from BeanInfo
public Image getOpenedIcon(int type)
Node
getOpenedIcon
in class Node
org.openide.nodes.Node
type
- constant from BeanInfo
public HelpCtx getHelpCtx()
Node
getHelpCtx
in class Node
org.openide.nodes.Node
null
or HelpCtx.DEFAULT_HELP
)public boolean canRename()
Node
FeatureDescriptor.getName()
to obtain the current name and
Node.setName(java.lang.String)
to change it.canRename
in class Node
org.openide.nodes.Node
true
if the node can be renamedpublic boolean canDestroy()
Node
canDestroy
in class Node
org.openide.nodes.Node
true
if canpublic void destroy() throws IOException
Node
children's lock
, and removes
the node from its parent (if any). Also fires a property change.
This may be overridden by subclasses to do any additional cleanup.
destroy
in class Node
org.openide.nodes.Node
IOException
- if something failspublic Node.PropertySet[] getPropertySets()
Node
getPropertySets
in class Node
org.openide.nodes.Node
public Transferable clipboardCopy() throws IOException
Node
clipboardCopy
in class Node
org.openide.nodes.Node
IOException
- when the
copy cannot be performedpublic Transferable clipboardCut() throws IOException
Node
clipboardCut
in class Node
org.openide.nodes.Node
IOException
- when the
cut cannot be performedpublic boolean canCopy()
Node
canCopy
in class Node
org.openide.nodes.Node
true
if sopublic boolean canCut()
Node
canCut
in class Node
org.openide.nodes.Node
true
if sopublic Transferable drag() throws IOException
Node
drag
in class Node
org.openide.nodes.Node
IOException
- if a drag cannot be startedpublic PasteType getDropType(Transferable t, int action, int index)
Node
getDropType
in class Node
org.openide.nodes.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 PasteType[] getPasteTypes(Transferable t)
Node
getPasteTypes
in class Node
org.openide.nodes.Node
t
- the transferable in the clipboardpublic NewType[] getNewTypes()
Node
getNewTypes
in class Node
org.openide.nodes.Node
public SystemAction[] getActions()
Node
context menu
.
By default returns the actions in NodeOp.getDefaultActions()
.
getActions
in class Node
org.openide.nodes.Node
public SystemAction[] getContextActions()
Node
For example, right-clicking on a parent node in a hierarchical view (such as
the normal Explorer) should use getActions
. However, if this node
is serving as the parent of a (say) a window tab full of icons (e.g., in
IconView
), and the users right-clicks on
the empty space in this pane, then this method should be used to get
the appropriate actions for a popup menu.
Note that in the Windows UI system, e.g., these action sets are quite different.
getContextActions
in class Node
org.openide.nodes.Node
Node.getActions()
.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 boolean hasCustomizer()
Node
Node.getCustomizer()
.hasCustomizer
in class Node
org.openide.nodes.Node
true
if there is a customizerpublic Component getCustomizer()
Node
getCustomizer
in class Node
org.openide.nodes.Node
null
if there is no customizerpublic Node.Cookie getCookie(Class type)
Node
The set of cookies can change. If a node changes its set of
cookies, it fires a property change event with Node.PROP_COOKIE
.
getCookie
in class Node
org.openide.nodes.Node
type
- the representation class of the cookienull
if this node has no such cookiepublic Node.Handle getHandle()
Subclasses must override this if they wish for their nodes to be properly serializable.
getHandle
in class Node
null
if this node is subclassed or
uses changed childrenpublic boolean equals(Object o)
FilterNode
, or filter nodes with non-default children,
the test reverts to object identity.
Note: if you wish that the Index
cookie works correctly on
filtered nodes and their subnodes, and you are subclassing FilterNode
or
using non-default children, you will probably want to override this method to test
equality of the specified node with this filter node's original node; otherwise Move Up
and Move Down actions may be disabled.
Note though that it is often better to provide your own index cookie from a filter
node. Only then it is possible to change the number of children relative to the original.
And in many cases this is easier anyway, as for example with
data folders
.
equals
in class Object
o
- something to compare to, presumably a node or FilterNode
of onepublic int hashCode()
FilterNode
, or filter nodes with non-default children,
the hash reverts to the identity hash code.hashCode
in class Object
protected Node getOriginal()
Yes this is supposed to be protected! If you
are not subclassing FilterNode
yourself, you should
not be calling it (nor casting to FilterNode
). Use
cookies instead.
protected PropertyChangeListener createPropertyChangeListener()
This method is called during initialization and allows subclasses to modify the default behaviour.
FilterNode.PropertyChangeAdapter
in the default implementationprotected NodeListener createNodeListener()
Intended for overriding by subclasses, as with createPropertyChangeListener()
.
FilterNode.NodeAdapter
in the default implementation
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |