Class FilterNode
- All Implemented Interfaces:
org.openide.util.HelpCtx.Provider, org.openide.util.Lookup.Provider
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).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classChildren for a filter node.protected static classAdapter that listens on changes in an original node and refires them in a proxy.protected static classAdapter that listens on changes in an original node and refires them in a proxy.Nested classes/interfaces inherited from class Node
Node.Cookie, Node.Handle, Node.IndexedProperty<T,E>, Node.Property<T>, Node.PropertySet -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intWhether to delegatedestroy.protected static final intWhether to delegategetActions.protected static final intWhether to delegategetContextActions.protected static final intWhether to delegategetDisplayName.protected static final intWhether to delegategetName.protected static final intWhether to delegategetShortDescription.protected static final intWhether to delegategetValue.protected static final intWhether to delegatesetDisplayName.protected static final intWhether to delegatesetName.protected static final intWhether to delegatesetShortDescription.protected static final intWhether to delegatesetValue.Fields inherited from class 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
ConstructorsConstructorDescriptionFilterNode(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. -
Method Summary
Modifier and TypeMethodDescriptionbooleancanCopy()Test whether this node permits copying.booleancanCut()Test whether this node permits cutting.booleanTest whether this node can be deleted.booleanTest whether this node can be renamed.protected final voidchangeOriginal(Node original, boolean changeChildren) Changes the original node for this node.Called when a node is to be copied to the clipboard.Called when a node is to be cut to the clipboard.Create new filter node for the original.protected NodeListenerCreates a node listener that allows listening on the original node and propagating events to the proxy.protected PropertyChangeListenerCreate a property change listener that allows listening on the original node properties (contained in property sets) and propagating them to the proxy.voiddestroy()Called when a node is deleted.protected final voiddisableDelegation(int mask) Disable delegation of a set of methods.drag()Called when a drag is started with this node.protected final voidenableDelegation(int mask) Enable delegation of a set of methods.booleanTest equality of original nodes.org.openide.util.actions.SystemAction[]Deprecated.Action[]getActions(boolean context) Get the set of actions that are associated with this node.org.openide.util.actions.SystemAction[]Deprecated.<T extends Node.Cookie>
TDelegates to original, if no special lookup provided in constructor, Otherwise it delegates to the lookup.Get the customizer component.org.openide.util.actions.SystemActionDeprecated.org.openide.util.datatransfer.PasteTypegetDropType(Transferable t, int action, int index) Determine if there is a paste operation that can be performed on provided transferable.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.HelpCtxGet context help associated with this node.Get a display name containing HTML markup.getIcon(int type) Find an icon for this node (in the closed state).getName()org.openide.util.datatransfer.NewType[]Get the new types that can be created in this node.getOpenedIcon(int type) Find an icon for this node (in the open state).protected NodeGet the original node.org.openide.util.datatransfer.PasteType[]Determine which paste operations are allowed when a given transferable is in the clipboard.Gets the preferred action for this node.Get the list of property sets for this node.booleanTest whether there is a customizer for this node.inthashCode()Hash by original nodes.voidSet the display name.voidSet the system name.voidSet the short description of the node.voidMethods inherited from class Node
addNodeListener, addPropertyChangeListener, clone, fireCookieChange, fireDisplayNameChange, fireIconChange, fireNameChange, fireNodeDestroyed, fireOpenedIconChange, firePropertyChange, firePropertySetsChange, fireShortDescriptionChange, getChildren, getContextMenu, getLookup, getParentNode, hasPropertyChangeListener, isLeaf, removeNodeListener, removePropertyChangeListener, setChildren, setHidden, toStringMethods inherited from class FeatureDescriptor
attributeNames, isExpert, isHidden, isPreferred, setExpert, setPreferred
-
Field Details
-
DELEGATE_SET_NAME
protected static final int DELEGATE_SET_NAMEWhether to delegatesetName.- See Also:
-
DELEGATE_GET_NAME
protected static final int DELEGATE_GET_NAMEWhether to delegategetName.- See Also:
-
DELEGATE_SET_DISPLAY_NAME
protected static final int DELEGATE_SET_DISPLAY_NAMEWhether to delegatesetDisplayName.- See Also:
-
DELEGATE_GET_DISPLAY_NAME
protected static final int DELEGATE_GET_DISPLAY_NAMEWhether to delegategetDisplayName.- See Also:
-
DELEGATE_SET_SHORT_DESCRIPTION
protected static final int DELEGATE_SET_SHORT_DESCRIPTIONWhether to delegatesetShortDescription.- See Also:
-
DELEGATE_GET_SHORT_DESCRIPTION
protected static final int DELEGATE_GET_SHORT_DESCRIPTIONWhether to delegategetShortDescription.- See Also:
-
DELEGATE_DESTROY
protected static final int DELEGATE_DESTROYWhether to delegatedestroy.- See Also:
-
DELEGATE_GET_ACTIONS
protected static final int DELEGATE_GET_ACTIONSWhether to delegategetActions.- See Also:
-
DELEGATE_GET_CONTEXT_ACTIONS
protected static final int DELEGATE_GET_CONTEXT_ACTIONSWhether to delegategetContextActions.- See Also:
-
DELEGATE_SET_VALUE
protected static final int DELEGATE_SET_VALUEWhether to delegatesetValue.- Since:
- 4.25
- See Also:
-
DELEGATE_GET_VALUE
protected static final int DELEGATE_GET_VALUEWhether to delegategetValue.- Since:
- 4.25
- See Also:
-
-
Constructor Details
-
FilterNode
-
FilterNode
-
FilterNode
Constructs new filter node with a provided children and lookup. The lookup is used to implementgetCookie(Class)calls that just calllookup.lookup(clazz). If this constructor is used, the code shall not overridegetCookie(Class)method, but do all its state manipulation in the lookup. Look atNode(Children, Lookup)constructor for best practices usage of this constructor.- Parameters:
original- the node we delegate tochildren- the children to use for the filter node ornullif default children should be providedlookup- lookup to use. Do not passorginal.getLookup()into this parameter. In such case use theFilterNode(Node, Children)constructor.- Since:
- 4.4
-
-
Method Details
-
enableDelegation
protected final void enableDelegation(int mask) Enable delegation of a set of methods. These will be delegated to the original node. Since all available methods are delegated by default, normally you will not need to call this.- Parameters:
mask- bitwise disjunction ofDELEGATE_XXXconstants- Throws:
IllegalArgumentException- if the mask is invalid
-
disableDelegation
protected final void disableDelegation(int mask) Disable delegation of a set of methods. The methods will retain their behavior fromNode.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 usinggetOriginal(). Other methods abstract inNodemay simply be overridden without any special handling.- Parameters:
mask- bitwise disjunction ofDELEGATE_XXXconstants- Throws:
IllegalArgumentException- if the mask is invalid
-
cloneNode
-
changeOriginal
Changes the original node for this node.- Parameters:
original- The new original node.changeChildren- If set totruechanges children of this node according to the new original node. If you pass children which are not instance of classFilterNode.Childreninto the constructor set this parameter tofalse. Be aware that this method aquires write lock on the nodes hierarchy (Children.MUTEX). Take care not to call this method under read lock.- Throws:
IllegalStateException- if children which are not instance ofFilterNode.Childrenwere passed into the constructor and the method was called with the parameterchangeChildrenset totrue.- Since:
- 1.39
-
setValue
- Overrides:
setValuein classFeatureDescriptor
-
getValue
- Overrides:
getValuein classFeatureDescriptor
-
setName
-
getName
- Overrides:
getNamein classFeatureDescriptor
-
setDisplayName
Description copied from class:NodeSet the display name. Fires a property change event.- Overrides:
setDisplayNamein classNode- Parameters:
s- the new name
-
getDisplayName
- Overrides:
getDisplayNamein classFeatureDescriptor
-
setShortDescription
Description copied from class:NodeSet the short description of the node. Fires a property change event.This description may be used for tool tips, etc.
- Overrides:
setShortDescriptionin classNode- Parameters:
s- the new description
-
getShortDescription
- Overrides:
getShortDescriptionin classFeatureDescriptor
-
getIcon
-
getOpenedIcon
Description copied from class:NodeFind an icon for this node (in the open state). This icon is used when the node may have children and is expanded.- Specified by:
getOpenedIconin classNode- Parameters:
type- constant fromBeanInfo- Returns:
- icon to use to represent the node when open
-
getHelpCtx
public org.openide.util.HelpCtx getHelpCtx()Description copied from class:NodeGet context help associated with this node.- Specified by:
getHelpCtxin interfaceorg.openide.util.HelpCtx.Provider- Specified by:
getHelpCtxin classNode- Returns:
- the context help object (could be
nullorHelpCtx.DEFAULT_HELP)
-
canRename
public boolean canRename()Description copied from class:NodeTest whether this node can be renamed. If true, one can useFeatureDescriptor.getName()to obtain the current name andNode.setName(String)to change it. -
canDestroy
public boolean canDestroy()Description copied from class:NodeTest whether this node can be deleted.- Specified by:
canDestroyin classNode- Returns:
trueif can
-
destroy
Description copied from class:NodeCalled when a node is deleted. Generally you would never call this method yourself (only override it); perform modifications on the underlying model itself.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.- Overrides:
destroyin classNode- Throws:
IOException- if something fails
-
getPropertySets
Description copied from class:NodeGet the list of property sets for this node. E.g. typically there may be one for normal Bean properties, one for expert properties, and one for hidden properties.- Specified by:
getPropertySetsin classNode- Returns:
- the property sets
-
clipboardCopy
Description copied from class:NodeCalled when a node is to be copied to the clipboard.- Specified by:
clipboardCopyin classNode- Returns:
- the transferable object representing the content of the clipboard
- Throws:
IOException- when the copy cannot be performed
-
clipboardCut
Description copied from class:NodeCalled when a node is to be cut to the clipboard.- Specified by:
clipboardCutin classNode- Returns:
- the transferable object representing the content of the clipboard
- Throws:
IOException- when the cut cannot be performed
-
canCopy
-
canCut
-
drag
Description copied from class:NodeCalled when a drag is started with this node. The node can attach a transfer listener to ExTransferable and will be then notified about progress of the drag (accept/reject).- Specified by:
dragin classNode- Returns:
- transferable to represent this node during a drag
- Throws:
IOException- if a drag cannot be started
-
getDropType
Description copied from class:NodeDetermine if there is a paste operation that can be performed on provided transferable. Used by drag'n'drop code to check whether the drop is possible.- Specified by:
getDropTypein classNode- Parameters:
t- 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 specified- Returns:
- null if the transferable cannot be accepted or the paste type to execute when the drop occurs
-
getPasteTypes
Description copied from class:NodeDetermine which paste operations are allowed when a given transferable is in the clipboard. For example, a node representing a Java package will permit classes to be pasted into it.- Specified by:
getPasteTypesin classNode- Parameters:
t- the transferable in the clipboard- Returns:
- array of operations that are allowed
-
getNewTypes
public org.openide.util.datatransfer.NewType[] getNewTypes()Description copied from class:NodeGet the new types that can be created in this node. For example, a node representing a Java package will permit classes to be added.- Specified by:
getNewTypesin classNode- Returns:
- array of new type operations that are allowed
-
getActions
Deprecated.Description copied from class:NodeGet the set of actions associated with this node. This may be used e.g. in constructing acontext menu.By default returns the actions in
NodeOp.getDefaultActions().- Overrides:
getActionsin classNode- Returns:
- system actions appropriate to the node
-
getContextActions
Deprecated.Description copied from class:NodeGet a special set of actions for situations when this node is displayed as a context.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., inIconView), 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.
- Overrides:
getContextActionsin classNode- Returns:
- actions for a context. In the default implementation, same as
Node.getActions(boolean).
-
getDefaultAction
Deprecated.Description copied from class:NodeGets the default action for this node.- Overrides:
getDefaultActionin classNode- Returns:
nullindicating there should be none default action
-
getActions
Description copied from class:NodeGet the set of actions that are associated with this node. This set is used to construct the context menu for the node.By 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.
- Overrides:
getActionsin classNode- Parameters:
context- whether to find actions for context meaning or for the node itself- Returns:
- a list of actions (you may include nulls for separators)
-
getPreferredAction
Description copied from class:NodeGets the preferred action for this node. This action can but need not to be one from the action array returned fromNode.getActions(boolean). In case it is, the context menu created from those actions is encouraged to highlight the preferred action. Override in subclasses accordingly.- Overrides:
getPreferredActionin classNode- Returns:
- the preferred action, or
nullif there is none
-
getHtmlDisplayName
Get a display name containing HTML markup. Note: If you subclass FilterNode and overridegetDisplayName(), 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). IfgetDisplayName()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.- Overrides:
getHtmlDisplayNamein classNode- Returns:
- An HTML display name, if available, or null if no display name is available
- See Also:
-
hasCustomizer
public boolean hasCustomizer()Description copied from class:NodeTest whether there is a customizer for this node. If true, the customizer can be obtained viaNode.getCustomizer().- Specified by:
hasCustomizerin classNode- Returns:
trueif there is a customizer
-
getCustomizer
Description copied from class:NodeGet the customizer component.- Specified by:
getCustomizerin classNode- Returns:
- the component, or
nullif there is no customizer
-
getCookie
Delegates to original, if no special lookup provided in constructor, Otherwise it delegates to the lookup. Never override this method if the lookup is provided in constructor. -
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.Subclasses must override this if they wish for their nodes to be properly serializable.
-
equals
Test equality of original nodes. Note that for subclasses ofFilterNode, or filter nodes with non-default children, the test reverts to object identity. Note: if you wish that theIndexcookie works correctly on filtered nodes and their subnodes, and you are subclassingFilterNodeor 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.Indexfor data folders. -
hashCode
-
getOriginal
Get the original node.Yes this is supposed to be protected! If you are not subclassing
FilterNodeyourself, you should not be calling it (nor casting toFilterNode). Use cookies instead.- Returns:
- the node proxied to
-
createPropertyChangeListener
Create a property change listener that allows listening on the original node properties (contained in property sets) and propagating them to the proxy.This method is called during initialization and allows subclasses to modify the default behaviour.
- Returns:
- a
FilterNode.PropertyChangeAdapterin the default implementation
-
createNodeListener
Creates a node listener that allows listening on the original node and propagating events to the proxy.Intended for overriding by subclasses, as with
createPropertyChangeListener().- Returns:
- a
FilterNode.NodeAdapterin the default implementation
-