public class FilterNode extends Node
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).
| Modifier and Type | Class | Description |
|---|---|---|
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.
|
Node.Cookie, Node.Handle, Node.IndexedProperty<T,E>, Node.Property<T>, Node.PropertySet| Modifier and Type | Field | Description |
|---|---|---|
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_GET_VALUE |
Whether to delegate
getValue. |
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. |
protected static int |
DELEGATE_SET_VALUE |
Whether to delegate
setValue. |
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 | Description |
|---|---|
FilterNode(Node original) |
Create proxy.
|
FilterNode(Node original,
Children children) |
Create proxy with a different set of children.
|
FilterNode(Node original,
Children children,
org.openide.util.Lookup lookup) |
Constructs new filter node with a provided children and lookup.
|
| Modifier and Type | Method | Description |
|---|---|---|
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.
|
java.awt.datatransfer.Transferable |
clipboardCopy() |
Called when a node is to be copied to the clipboard.
|
java.awt.datatransfer.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 java.beans.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() |
Called when a node is deleted.
|
protected void |
disableDelegation(int mask) |
Disable delegation of a set of methods.
|
java.awt.datatransfer.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(java.lang.Object o) |
Test equality of original nodes.
|
org.openide.util.actions.SystemAction[] |
getActions() |
Deprecated.
|
javax.swing.Action[] |
getActions(boolean context) |
Get the set of actions that are associated with this node.
|
org.openide.util.actions.SystemAction[] |
getContextActions() |
Deprecated.
|
<T extends Node.Cookie> |
getCookie(java.lang.Class<T> type) |
Delegates to original, if no special lookup provided in constructor,
Otherwise it delegates to the lookup.
|
java.awt.Component |
getCustomizer() |
Get the customizer component.
|
org.openide.util.actions.SystemAction |
getDefaultAction() |
Deprecated.
|
java.lang.String |
getDisplayName() |
|
org.openide.util.datatransfer.PasteType |
getDropType(java.awt.datatransfer.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.
|
org.openide.util.HelpCtx |
getHelpCtx() |
Get context help associated with this node.
|
java.lang.String |
getHtmlDisplayName() |
Get a display name containing HTML markup.
|
java.awt.Image |
getIcon(int type) |
Find an icon for this node (in the closed state).
|
java.lang.String |
getName() |
|
org.openide.util.datatransfer.NewType[] |
getNewTypes() |
Get the new types that can be created in this node.
|
java.awt.Image |
getOpenedIcon(int type) |
Find an icon for this node (in the open state).
|
protected Node |
getOriginal() |
Get the original node.
|
org.openide.util.datatransfer.PasteType[] |
getPasteTypes(java.awt.datatransfer.Transferable t) |
Determine which paste operations are allowed when a given transferable is in the clipboard.
|
javax.swing.Action |
getPreferredAction() |
Gets the preferred action for this node.
|
Node.PropertySet[] |
getPropertySets() |
Get the list of property sets for this node.
|
java.lang.String |
getShortDescription() |
|
java.lang.Object |
getValue(java.lang.String attributeName) |
|
boolean |
hasCustomizer() |
Test whether there is a customizer for this node.
|
int |
hashCode() |
Hash by original nodes.
|
void |
setDisplayName(java.lang.String s) |
Set the display name.
|
void |
setName(java.lang.String s) |
Set the system name.
|
void |
setShortDescription(java.lang.String s) |
Set the short description of the node.
|
void |
setValue(java.lang.String attributeName,
java.lang.Object value) |
attributeNames, isExpert, isHidden, isPreferred, setExpert, setPreferredaddNodeListener, addPropertyChangeListener, clone, fireCookieChange, fireDisplayNameChange, fireIconChange, fireNameChange, fireNodeDestroyed, fireOpenedIconChange, firePropertyChange, firePropertySetsChange, fireShortDescriptionChange, getChildren, getContextMenu, getLookup, getParentNode, hasPropertyChangeListener, isLeaf, removeNodeListener, removePropertyChangeListener, setChildren, setHidden, toStringprotected 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.protected static final int DELEGATE_SET_VALUE
setValue.protected static final int DELEGATE_GET_VALUE
getValue.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 nodepublic FilterNode(Node original, Children children, org.openide.util.Lookup lookup)
getCookie(java.lang.Class<T>) calls that just call
lookup.lookup(clazz). If this constructor is used,
the code shall not override getCookie(java.lang.Class<T>) method, but do all
its state manipulation in the lookup. Look at Node(org.openide.nodes.Children, org.openide.util.Lookup)
constructor for best practices usage of this constructor.original - the node we delegate tochildren - the children to use for the filter node or null if
default children should be providedlookup - lookup to use. Do not pass orginal.getLookup() into this parameter.
In such case use the #FilterNode(Node, Children) constructor.protected final void enableDelegation(int mask)
mask - bitwise disjunction of DELEGATE_XXX constantsjava.lang.IllegalArgumentException - 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 constantsjava.lang.IllegalArgumentException - if the mask is invalidpublic Node cloneNode()
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. Be aware
that this method aquires
write lock on the nodes hierarchy (Children.MUTEX). Take care not to call this method
under read lock.java.lang.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 setValue(java.lang.String attributeName,
java.lang.Object value)
setValue in class java.beans.FeatureDescriptorpublic java.lang.Object getValue(java.lang.String attributeName)
getValue in class java.beans.FeatureDescriptorpublic void setName(java.lang.String s)
Nodepublic java.lang.String getName()
getName in class java.beans.FeatureDescriptorpublic void setDisplayName(java.lang.String s)
NodesetDisplayName in class Nodes - the new namepublic java.lang.String getDisplayName()
getDisplayName in class java.beans.FeatureDescriptorpublic void setShortDescription(java.lang.String s)
NodeThis description may be used for tool tips, etc.
setShortDescription in class Nodes - the new descriptionpublic java.lang.String getShortDescription()
getShortDescription in class java.beans.FeatureDescriptorpublic java.awt.Image getIcon(int type)
Nodepublic java.awt.Image getOpenedIcon(int type)
NodegetOpenedIcon in class Nodetype - constant from BeanInfopublic org.openide.util.HelpCtx getHelpCtx()
NodegetHelpCtx in class Nodenull or HelpCtx.DEFAULT_HELP)public boolean canRename()
NodeFeatureDescriptor.getName() to obtain the current name and
Node.setName(java.lang.String) to change it.public boolean canDestroy()
NodecanDestroy in class Nodetrue if canpublic void destroy()
throws java.io.IOException
Node
The default
implementation obtains write access to
Children.MUTEX, and removes
the node from its parent (if any). Also fires a property change.
Subclasses which return true from Node.canDestroy() should override
this method to remove the associated model object from its parent. There
is no need to call the super method in this case.
There is no guarantee that after this method has been called, other
methods such as Node.getIcon(int) will not also be called for a little while.
public Node.PropertySet[] getPropertySets()
NodegetPropertySets in class Nodepublic java.awt.datatransfer.Transferable clipboardCopy()
throws java.io.IOException
NodeclipboardCopy in class Nodejava.io.IOException - when the
copy cannot be performedpublic java.awt.datatransfer.Transferable clipboardCut()
throws java.io.IOException
NodeclipboardCut in class Nodejava.io.IOException - when the
cut cannot be performedpublic boolean canCopy()
Nodepublic boolean canCut()
Nodepublic java.awt.datatransfer.Transferable drag()
throws java.io.IOException
Nodepublic org.openide.util.datatransfer.PasteType getDropType(java.awt.datatransfer.Transferable t,
int action,
int index)
NodegetDropType in class Nodet - the transferableaction - the drag'n'drop action to do DnDConstants.ACTION_MOVE, ACTION_COPY, ACTION_LINKindex - index between children the drop occurred at or -1 if not specifiedpublic org.openide.util.datatransfer.PasteType[] getPasteTypes(java.awt.datatransfer.Transferable t)
NodegetPasteTypes in class Nodet - the transferable in the clipboardpublic org.openide.util.datatransfer.NewType[] getNewTypes()
NodegetNewTypes in class Node@Deprecated public org.openide.util.actions.SystemAction[] getActions()
Nodecontext menu.
By default returns the actions in NodeOp.getDefaultActions().
getActions in class Node@Deprecated public org.openide.util.actions.SystemAction[] getContextActions()
NodeFor 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 context menu.
Note that in the Windows UI system, e.g., these action sets are quite different.
getContextActions in class NodeNode.getActions(boolean).@Deprecated public org.openide.util.actions.SystemAction getDefaultAction()
NodegetDefaultAction in class Nodenull indicating there should be none default actionpublic javax.swing.Action[] getActions(boolean context)
NodeBy default this method delegates to the deprecated getActions or getContextActions method depending on the value of supplied argument.
It is supposed to be overridden by subclasses accordingly.
getActions in class Nodecontext - whether to find actions for context meaning or for the
node itselfpublic javax.swing.Action getPreferredAction()
NodeNode.getActions(boolean).
In case it is, the context menu created from those actions
is encouraged to highlight the preferred action.
Override in subclasses accordingly.getPreferredAction in class Nodenull if there is nonepublic java.lang.String getHtmlDisplayName()
getDisplayName(), this method will
always return null unless you override it as well (assuming that if you're
changing the display name, you don't want an HTML display name constructed
from the original node's display name to be what shows up in views of
this node). If getDisplayName() is not overridden,
this method will return whatever the original node returns from this
method.
Note that if you do override getDisplayName, you should also override
this method to return null.
getHtmlDisplayName in class NodeNode.getHtmlDisplayName()public boolean hasCustomizer()
NodeNode.getCustomizer().hasCustomizer in class Nodetrue if there is a customizerpublic java.awt.Component getCustomizer()
NodegetCustomizer in class Nodenull if there is no customizerpublic <T extends Node.Cookie> T getCookie(java.lang.Class<T> type)
getCookie in class Nodetype - the class to look forNode.getCookie(java.lang.Class<T>)public Node.Handle getHandle()
Subclasses must override this if they wish for their nodes to be properly serializable.
public boolean equals(java.lang.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
DataFolder.Index for data folders.
public int hashCode()
FilterNode, or filter nodes with non-default children,
the hash reverts to the identity hash code.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 java.beans.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 implementationBuilt on April 24 2018. | Portions Copyright 1997-2018 Oracle. All rights reserved.