Class GTree
- All Implemented Interfaces:
BusyListener,ImageObserver,MenuContainer,Serializable,Accessible
- Direct Known Subclasses:
DataTree
Note: when calling methods on this class to select nodes, if those nodes are threaded, or extend
from GTreeSlowLoadingNode, then you must first expand the paths you wish to select. You
can do this by calling expandAndSelectPaths(List). The various select methods of this
class will not expand nodes, but they will trigger children to be loaded. If those nodes are not
threaded, then the tree will add and expand the children by default. When using threaded nodes,
the delay in loading prevents the tree from correctly expanding the paths.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanelNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddGTModelListener(TreeModelListener listener) voidvoidaddMouseListener(MouseListener listener) voidaddSelectionPath(TreePath path) voidvoidvoidSignals that any multithreaded work should be cancelled.voidvoidvoidvoidcollapseAll(GTreeNode node) protected JTreeMouseListenerDelegatestatic voidcreateSharedActions(Tool tool, ToolActions toolActions, String owner) voiddispose()voidvoidexpandAndSelectPaths(List<TreePath> paths) Expands and then selects the given paths.voidexpandedStateRestored(TaskMonitor taskMonitor) A method that subclasses can use to be notified when tree state has been restored.voidexpandPath(GTreeNode node) voidexpandPath(TreePath path) voidexpandPaths(List<TreePath> paths) voidexpandPaths(TreePath[] paths) voidexpandTree(GTreeNode node) voidgetExpandedPaths(GTreeNode node) Returns the filter text field in this tree.protected final JTreegetJTree()getModel()Returns the model for this treegetModelNode(GTreeNode node) Gets the model node for the given node.getModelNodeForPath(TreePath path) Gets the model node for the given path.This method returns the root node that was provided to the tree by the client, whether from the constructor or fromsetRootNode(GTreeNode).getNodeForLocation(int x, int y) getPathBounds(TreePath path) getPathForLocation(int x, int y) getPathForRow(int row) Returns the key that this tree uses to store preferences.intintgetRowForPath(TreePath treePath) protected JScrollPaneTreePath[]getToolTipText(MouseEvent event) Returns a state object that allows this tree to later restore its expanded and selected state.getTreeState(GTreeNode node) getViewNode(GTreeNode node) Gets the view node for the given node.getViewNodeForPath(TreePath path) Gets the view node for the given path.Returns the current viewport position of the scrollable tree.This method returns the root node currently being displayed by theJTree.booleanprotected booleanisAddToPopup(DockingAction action) A method that subclasses can override to decide if the given action should appear in the popup menu.booleanisBusy()booleanisCollapsed(TreePath path) booleanbooleanbooleanisExpanded(TreePath treePath) booleanbooleanbooleanReturns true if the given JTree is the actual JTree used by this GTree.booleanisPathEditable(TreePath path) booleanisPathSelected(TreePath treePath) booleanbooleanstatic voidprintEvent(PrintWriter out, String name, TreeModelEvent e) This method is useful for debugging tree problems.voidCauses the tree to refilter some time latervoidrefilterLater(GTreeNode newNode) Re-filters the tree if the newNode should be included in the current filter results.voidCauses the tree to refilter immediately (before this method returns)voidremoveGTModelListener(TreeModelListener listener) voidvoidremoveMouseListener(MouseListener listener) voidvoidrestoreTreeState(GTreeState state) Restores the expanded and selected state of this tree to that contained in the given state object.voidrunBulkTask(GTreeBulkTask task) voidUsed to run tree tasks.voidrunTask(MonitoredRunnable runnableTask) Used to run simple GTree tasks that can be expressed as aMonitoredRunnable(or a lambda taking aTaskMonitor).voidscrollPathToVisible(TreePath treePath) voidsetAccessibleNamePrefix(String namePrefix) Sets an accessible name on the GTree.voidvoidsetBusy(boolean busy) voidsetCellEditor(TreeCellEditor editor) voidsetCellRenderer(GTreeRenderer renderer) voidsetDataTransformer(FilterTransformer<GTreeNode> transformer) Sets a transformer object used to perform filtering.voidsetDoubleClickExpansionEnabled(boolean b) Enable or disable using double-click to open and close tree nodes.voidsetDragNDropHandler(GTreeDragNDropHandler dragNDropHandler) voidsetEditable(boolean editable) voidsetEnabled(boolean enabled) voidsetEventsEnabled(boolean b) Turns tree event notifications on/offvoidsetFilterFieldEnabled(boolean enabled) Disabled the filter text field, but allows the tree to still filter.voidsetFilteringEnabled(boolean enabled) Disables all filtering performed by this tree.voidsetFilterProvider(GTreeFilterProvider filterProvider) protected voidsetFilterRestoreState(GTreeState state) Sets the filter restore state.voidsetFilterText(String text) voidsetFilterVisible(boolean visible) Hides the filter field.voidsetHorizontalScrollPolicy(int policy) voidsetNodeEditable(GTreeNode child) voidsetPaintHandlesForLeafNodes(boolean enable) Passing a value offalsesignals to disable theJTree's default behavior of showing handles for leaf nodes until they are opened.voidsetRootNode(GTreeNode rootNode) Sets the root node for this tree.voidsetRootNodeAllowedToCollapse(boolean allowed) voidsetRootVisible(boolean b) voidsetRowHeight(int rowHeight) voidsetScrollableUnitIncrement(int increment) Sets the size of the scroll when mouse scrolling or pressing the scroll up/down buttons.voidsetSelectedNode(GTreeNode node) voidsetSelectedNodeByNamePath(String[] namePath) A convenience method to select a node by a path, starting with the tree root name, down each level until the desired node name.voidsetSelectedNodeByPathName(TreePath treePath) Selects the node that matches the each name in the given tree path.voidsetSelectedNodes(GTreeNode... nodes) voidsetSelectedNodes(Collection<GTreeNode> nodes) voidsetSelectionModel(GTreeSelectionModel selectionModel) voidsetSelectionPath(TreePath path) voidsetSelectionPaths(List<TreePath> pathsList) voidsetSelectionPaths(List<TreePath> paths, boolean expandPaths, GTreeSelectionEvent.EventOrigin origin) Selects the given paths, expanding them first if requested.voidsetSelectionPaths(TreePath[] paths) voidsetSelectionPaths(TreePath[] paths, GTreeSelectionEvent.EventOrigin origin) voidsetSeletedNodeByName(GTreeNode parentNode, String childName) A convenience method that allows clients that have created a new child node to select that node in the tree, without having to lookup the actual GTreeNode implementation.voidsetShowsRootHandles(boolean b) voidsetTransferHandler(TransferHandler handler) voidvoidstartEditing(GTreeNode node) Requests that the node be edited.voidstartEditing(GTreeNode parent, String childName) Requests that the node with the given name, in the given parent, be edited.voidtoString()protected voidvoidwhenNodeIsReady(GTreeNode parent, String childName, Consumer<GTreeNode> consumer) A specialized method that will get the child node from the given parent node when it becomes available to the model.voidA specialized method that will get the child node from the given parent node when it becomes available to the model.Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeMethods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Constructor Details
-
GTree
Creates a GTree with the given root node. The created GTree will use a threaded model for performing tasks, which allows the GUI to be responsive for reaaaaaaaaly big trees.- Parameters:
root- The root node of the tree.
-
-
Method Details
-
setEnabled
public void setEnabled(boolean enabled) - Overrides:
setEnabledin classJComponent
-
setEventsEnabled
public void setEventsEnabled(boolean b) Turns tree event notifications on/off- Parameters:
b- true to enable events, false to disable events
-
setDragNDropHandler
-
setTransferHandler
- Overrides:
setTransferHandlerin classJComponent
-
getDragNDropHandler
-
setAccessibleNamePrefix
Sets an accessible name on the GTree. This prefix will be used to assign meaningful accessible names to the tree, filter text field and the filter options button such that screen readers will properly describe them.This prefix should be the base name that describes the type of items in the tree. This method will then append the necessary information to name the text field and the button.
- Parameters:
namePrefix- the accessible name prefix to assign to the filter component. For example if the tree contains fruits, then "Fruits" would be an appropriate prefix name.
-
setCellRenderer
-
getCellRenderer
-
dispose
public void dispose() -
isDisposed
public boolean isDisposed() -
cancelWork
public void cancelWork()Signals that any multithreaded work should be cancelled. -
filterChanged
public void filterChanged() -
updateModelFilter
protected void updateModelFilter() -
createMouseListenerDelegate
-
getTreeState
Returns a state object that allows this tree to later restore its expanded and selected state.Note: See the usage note at the header of this class concerning how tree state is used relative to the
equals()method.- Returns:
- the saved state
-
getTreeState
-
restoreTreeState
Restores the expanded and selected state of this tree to that contained in the given state object.Note: See the usage note at the header of this class concerning how tree state is used relative to the
equals()method.- Parameters:
state- the state to restore- See Also:
-
setFilterRestoreState
Sets the filter restore state. This method is a way to override the tree's filtering behavior, which is usually set by a call tosaveFilterRestoreState(). Most clients will never need to call this method.- Parameters:
state- the state to set
-
getPreferenceKey
Returns the key that this tree uses to store preferences.- Returns:
- the key that this tree uses to store preferences.
-
expandedStateRestored
A method that subclasses can use to be notified when tree state has been restored. This method is called after a major structural tree change has happened and the paths that should be opened have been opened. Thus any other nodes are closed and can be disposed, if desired.- Parameters:
taskMonitor- the TaskMonitor
-
getExpandedPaths
-
getExpandedPaths
-
expandTree
-
expandAll
public void expandAll() -
collapseAll
-
expandPath
-
expandPath
-
expandPaths
-
expandPaths
-
clearSelectionPaths
public void clearSelectionPaths() -
expandAndSelectPaths
Expands and then selects the given paths. You must use this method if your tree is usingGTreeSlowLoadingNodes. Otherwise, if the given paths are not expanded, then the select will not work. More info at the class javadoc.- Parameters:
paths- the paths
-
setSelectedNode
-
setSelectedNodes
-
setSelectedNodes
-
setSelectionPaths
-
setSelectionPaths
-
setSelectionPath
-
setSelectedNodeByNamePath
A convenience method to select a node by a path, starting with the tree root name, down each level until the desired node name.- Parameters:
namePath- The path to select
-
setSeletedNodeByName
A convenience method that allows clients that have created a new child node to select that node in the tree, without having to lookup the actual GTreeNode implementation.- Parameters:
parentNode- The parent containing a child by the given namechildName- The name of the child to select
-
setSelectedNodeByPathName
Selects the node that matches the each name in the given tree path. It is worth noting that the items in the tree path themselves are not used to identify nodes, but thetoString()of those items will be used.- Parameters:
treePath- The path containing the names of the path of the node to select
-
setSelectionPaths
-
setSelectionPaths
public void setSelectionPaths(List<TreePath> paths, boolean expandPaths, GTreeSelectionEvent.EventOrigin origin) Selects the given paths, expanding them first if requested.- Parameters:
paths- the paths to selectexpandPaths- true to expand the paths first; this is only needed for multi-threaded nodes. Non-threaded nodes should use false, as it increase performance.origin- the event type; useGTreeSelectionEvent.EventOrigin.API_GENERATEDif unsure
-
isCollapsed
-
setHorizontalScrollPolicy
public void setHorizontalScrollPolicy(int policy) -
getScrollPane
-
setScrollableUnitIncrement
public void setScrollableUnitIncrement(int increment) Sets the size of the scroll when mouse scrolling or pressing the scroll up/down buttons. Most clients will not need this method, as the default behavior of the tree is correct, which is to scroll based upon the size of the nodes (which is usually uniform and a single row in size). However, some clients that have variable row height, with potentially large rows, may wish to change the scrolling behavior so that it is not too fast.- Parameters:
increment- the new (uniform) scroll increment.
-
getModel
Returns the model for this tree- Returns:
- the model for this tree
-
getJTree
-
getViewPosition
Returns the current viewport position of the scrollable tree.- Returns:
- the current viewport position of the scrollable tree.
-
setViewPosition
-
getViewRect
-
getNodeForLocation
-
getModelNode
Gets the model node for the given node. This is useful if the node that is in the path has been replaced by a new node that is equal, but a different instance. One way this happens is if the tree is filtered and therefor the displayed nodes are clones of the model nodes. This can also happen if the tree nodes are rebuilt for some reason.- Parameters:
node- the node- Returns:
- the corresponding model node in the tree. If the tree is filtered the viewed node will be a clone of the corresponding model node.
-
getModelNodeForPath
Gets the model node for the given path. This is useful if the node that is in the path has been replaced by a new node that is equal, but a different instance. One way this happens is if the tree is filtered and therefor the displayed nodes are clones of the model nodes. This can also happen if the tree nodes are rebuilt for some reason.- Parameters:
path- the path of the node- Returns:
- the corresponding model node in the tree. If the tree is filtered the viewed node will be a clone of the corresponding model node.
-
getViewNode
Gets the view node for the given node. This is useful to translate to a tree path that is valid for the currently displayed tree. (Remember that if the tree is filtered, then the displayed nodes are clones of the model nodes.)- Parameters:
node- the node- Returns:
- the current node in the displayed (possibly filtered) tree
-
getViewNodeForPath
Gets the view node for the given path. This is useful to translate to a tree path that is valid for the currently displayed tree. (Remember that if the tree is filtered, then the displayed nodes are clones of the model nodes.)- Parameters:
path- the path of the node- Returns:
- the current node in the displayed (possibly filtered) tree
-
setActiveDropTargetNode
-
setFilterText
-
getFilterProvider
-
setFilterProvider
-
setFilterFieldEnabled
public void setFilterFieldEnabled(boolean enabled) Disabled the filter text field, but allows the tree to still filter. This is useful if you want to allow programmatic filtering, but to not allow the user to filter.- Parameters:
enabled- True makes the filter field editable; false makes it uneditable- See Also:
-
setFilteringEnabled
public void setFilteringEnabled(boolean enabled) Disables all filtering performed by this tree. Also, the filter field of the tree will be disabled.Use this method to temporarily disable filtering.
- Parameters:
enabled- True to allow normal filtering; false to disable all filtering- See Also:
-
setFilterVisible
public void setFilterVisible(boolean visible) Hides the filter field. Filtering will still take place, as defined by theGTreeFilterProvider.- Parameters:
visible- true to show the filter; false to hide it.- See Also:
-
isFilteringEnabled
public boolean isFilteringEnabled() -
setDataTransformer
Sets a transformer object used to perform filtering. This object is responsible for turning the tree's nodes into a list of strings that can be searched when filtering.- Parameters:
transformer- the transformer to set
-
getFilterField
Returns the filter text field in this tree.- Returns:
- the filter text field in this tree.
-
isMyJTree
Returns true if the given JTree is the actual JTree used by this GTree.- Parameters:
jTree- the tree to test- Returns:
- true if the given JTree is the actual JTree used by this GTree.
-
setRootNode
Sets the root node for this tree.NOTE: if this method is not called from the Swing thread, then the root node will be set later on the Swing thread. That is, this method will return before the work has been done.
- Parameters:
rootNode- The node to set as the new root.
-
getModelRoot
This method returns the root node that was provided to the tree by the client, whether from the constructor or fromsetRootNode(GTreeNode). This node represents the data model and always contains all the nodes regardless of any filter being applied. If a filter is applied to the tree, then this is not the actual root node being displayed by theJTree.- Returns:
- the root node as provided by the client.
-
getViewRoot
This method returns the root node currently being displayed by theJTree. If there are no filters applied, then this will be the same as the model root (SeegetModelRoot()). If a filter is applied, then this will be a clone of the model root that contains clones of all nodes matching the filter.- Returns:
- the root node currently being display by the
JTree
-
printEvent
This method is useful for debugging tree problems. Don't know where else to put it.- Parameters:
out- the output writername- use this to indicate what tree event occurred ("node inserted" "node removed", etc.)e- the TreeModelEvent;
-
getSelectionModel
-
getGTSelectionModel
-
setSelectionModel
-
getRowCount
public int getRowCount() -
getRowForPath
-
getPathForRow
-
getSelectionPath
-
getSelectionPaths
-
getSelectedNodes
-
isExpanded
-
isPathSelected
-
isRootVisible
public boolean isRootVisible() -
setRootVisible
public void setRootVisible(boolean b) -
setShowsRootHandles
public void setShowsRootHandles(boolean b) -
scrollPathToVisible
-
getCellEditor
-
getPathForLocation
-
getPathBounds
-
setRowHeight
public void setRowHeight(int rowHeight) -
addSelectionPath
-
addTreeExpansionListener
-
removeTreeExpansionListener
-
addGTreeSelectionListener
-
removeGTreeSelectionListener
-
addGTModelListener
-
removeGTModelListener
-
setEditable
public void setEditable(boolean editable) -
whenNodeIsReady
public void whenNodeIsReady(GTreeNode parent, Predicate<GTreeNode> matches, Consumer<GTreeNode> consumer) A specialized method that will get the child node from the given parent node when it becomes available to the model. This method will ensure that the matching child passes any current filter in order for the child to appear in the tree. This effect is temporary and will be undone when next the filter changes.This method is intended to be used by clients using an asynchronous node model, where new nodes will get created by application-level events. Such clients may wish to perform work when newly created nodes become available. This method simplifies the concurrent nature of the GTree, asynchronous nodes and the processing of asynchronous application-level events by providing a callback mechanism for clients. This method is non-blocking.
Note: this method assumes that the given parent node is in the view and not filtered out of the view. This method makes no attempt to ensure the given parent node passes any existing filter.
Note: this method will not wait forever for the given node to appear. It will eventually give up if the node never arrives.
- Parameters:
parent- the model's parent node. If the view's parent node is passed, it will be translated to the model node.matches- the predicate that returns true when the given node is the desired nodeconsumer- the consumer callback to which the child node will be given when available
-
whenNodeIsReady
A specialized method that will get the child node from the given parent node when it becomes available to the model. This method will ensure that the named child passes any current filter in order for the child to appear in the tree. This effect is temporary and will be undone when next the filter changes.This method is intended to be used by clients using an asynchronous node model, where new nodes will get created by application-level events. Such clients may wish to perform work when newly created nodes become available. This method simplifies the concurrent nature of the GTree, asynchronous nodes and the processing of asynchronous application-level events by providing a callback mechanism for clients. This method is non-blocking.
Note: this method assumes that the given parent node is in the view and not filtered out of the view. This method makes no attempt to ensure the given parent node passes any existing filter.
Note: this method will not wait forever for the given node to appear. It will eventually give up if the node never arrives.
Note: if your parent node allows duplicate nodes then this method may not match the correct node. If that is the case, then use
whenNodeIsReady(GTreeNode, Predicate, Consumer).- Parameters:
parent- the model's parent node. If the view's parent node is passed, it will be translated to the model node.childName- the name of the desired childconsumer- the consumer callback to which the child node will be given when available
-
startEditing
Requests that the node with the given name, in the given parent, be edited. This operation is asynchronous. This request will be buffered as needed to wait for the given node to be added to the parent, up to a timeout period.Note: if there are multiple nodes by the given name under the given parent, then no editing will take place. In that case, you can instead use
startEditing(GTreeNode), if you have the node. If you have duplicates and do not yet have the node, then you will need to create your own mechanism for waiting for the desired node and then starting the edit.- Parameters:
parent- the parent nodechildName- the name of the child to edit
-
startEditing
Requests that the node be edited. This operation is asynchronous.- Parameters:
node- the node to edit
-
addMouseListener
- Overrides:
addMouseListenerin classComponent
-
removeMouseListener
- Overrides:
removeMouseListenerin classComponent
-
getMouseListeners
- Overrides:
getMouseListenersin classComponent
-
setCellEditor
-
isPathEditable
-
setPaintHandlesForLeafNodes
public void setPaintHandlesForLeafNodes(boolean enable) Passing a value offalsesignals to disable theJTree's default behavior of showing handles for leaf nodes until they are opened.- Parameters:
enable- False to disable the default JTree behavior
-
isRootAllowedToCollapse
public boolean isRootAllowedToCollapse() -
setRootNodeAllowedToCollapse
public void setRootNodeAllowedToCollapse(boolean allowed) -
isBusy
public boolean isBusy() -
setBusy
public void setBusy(boolean busy) - Specified by:
setBusyin interfaceBusyListener
-
refilterNow
public void refilterNow()Causes the tree to refilter immediately (before this method returns) -
refilterLater
public void refilterLater()Causes the tree to refilter some time later -
refilterLater
Re-filters the tree if the newNode should be included in the current filter results. If the new node doesn't match the filter, there is no need to refilter the tree.- Parameters:
newNode- the node that may cause the tree to refilter.
-
getFilter
-
isFiltered
public boolean isFiltered() -
hasFilterText
public boolean hasFilterText() -
getFilterText
-
clearFilter
public void clearFilter() -
runTask
Used to run tree tasks. This method is not meant for general clients of this tree, but rather for tasks to tell the tree to perform subtasks.- Parameters:
task- the task to run
-
runTask
Used to run simple GTree tasks that can be expressed as aMonitoredRunnable(or a lambda taking aTaskMonitor).- Parameters:
runnableTask-TaskMonitorto watch and update with progress.
-
runBulkTask
-
isEditing
public boolean isEditing() -
stopEditing
public void stopEditing() -
cancelEditing
public void cancelEditing() -
setNodeEditable
-
toString
-
getToolTipText
- Overrides:
getToolTipTextin classJComponent
-
clearSizeCache
public void clearSizeCache() -
isAddToPopup
A method that subclasses can override to decide if the given action should appear in the popup menu. Most subclasses will not need to override this method. An example for overriding this method is one of the subclasses that have their own version of one of the built-in actions, such as Expand All. Some clients have a custom expand action. In that case, the client wants their action in the menu and not the built-in version.- Parameters:
action- the action- Returns:
- true to have the action appear in the popup; the default is true
-
setDoubleClickExpansionEnabled
public void setDoubleClickExpansionEnabled(boolean b) Enable or disable using double-click to open and close tree nodes. The default is true.- Parameters:
b- true to enable
-