Class GTree

  • All Implemented Interfaces:
    BusyListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible
    Direct Known Subclasses:
    DataTree

    public class GTree
    extends javax.swing.JPanel
    implements BusyListener
    Class for creating a JTree that supports filtering, threading, and a progress bar.
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class javax.swing.JPanel

        javax.swing.JPanel.AccessibleJPanel
      • Nested classes/interfaces inherited from class javax.swing.JComponent

        javax.swing.JComponent.AccessibleJComponent
      • Nested classes/interfaces inherited from class java.awt.Container

        java.awt.Container.AccessibleAWTContainer
      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.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_WINDOW
      • Fields inherited from class java.awt.Component

        accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
      • Fields inherited from interface java.awt.image.ImageObserver

        ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
    • Constructor Summary

      Constructors 
      Constructor Description
      GTree​(GTreeNode root)
      Creates a GTree with the given root node.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addGTModelListener​(javax.swing.event.TreeModelListener listener)  
      void addGTreeSelectionListener​(GTreeSelectionListener listener)  
      void addMouseListener​(java.awt.event.MouseListener listener)  
      void addSelectionPath​(javax.swing.tree.TreePath path)  
      void addTreeExpansionListener​(javax.swing.event.TreeExpansionListener listener)  
      void cancelWork()
      Signals that any multithreaded work should be cancelled.
      void clearFilter()  
      void clearSelectionPaths()  
      void clearSizeCache()  
      void collapseAll​(GTreeNode node)  
      protected JTreeMouseListenerDelegate createMouseListenerDelegate()  
      void dispose()  
      void expandAll()  
      void expandedStateRestored​(TaskMonitor taskMonitor)
      A method that subclasses can use to be notified when tree state has been restored.
      void expandPath​(GTreeNode node)  
      void expandPath​(javax.swing.tree.TreePath path)  
      void expandPaths​(java.util.List<javax.swing.tree.TreePath> pathsList)  
      void expandPaths​(javax.swing.tree.TreePath[] paths)  
      void expandTree​(GTreeNode node)  
      void filterChanged()  
      javax.swing.CellEditor getCellEditor()  
      GTreeRenderer getCellRenderer()  
      GTreeDragNDropHandler getDragNDropHandler()  
      java.util.List<javax.swing.tree.TreePath> getExpandedPaths()  
      java.util.List<javax.swing.tree.TreePath> getExpandedPaths​(GTreeNode node)  
      GTreeFilter getFilter()  
      java.awt.Component getFilterField()
      Returns the filter text field in this tree.
      GTreeFilterProvider getFilterProvider()  
      java.lang.String getFilterText()  
      GTreeSelectionModel getGTSelectionModel()  
      protected javax.swing.JTree getJTree()  
      GTreeModel getModel()
      Returns the model for this tree
      GTreeNode getModelNodeForPath​(javax.swing.tree.TreePath path)
      Gets the model node for the given path.
      GTreeNode getModelRoot()
      This method returns the root node that was provided to the tree by the client, whether from the constructor or from setRootNode(GTreeNode).
      java.awt.event.MouseListener[] getMouseListeners()  
      GTreeNode getNodeForLocation​(int x, int y)  
      java.awt.Rectangle getPathBounds​(javax.swing.tree.TreePath path)  
      javax.swing.tree.TreePath getPathForLocation​(int x, int y)  
      javax.swing.tree.TreePath getPathForRow​(int row)  
      int getRowCount()  
      int getRowForPath​(javax.swing.tree.TreePath treePath)  
      protected javax.swing.JScrollPane getScrollPane()  
      javax.swing.tree.TreeSelectionModel getSelectionModel()  
      javax.swing.tree.TreePath getSelectionPath()  
      javax.swing.tree.TreePath[] getSelectionPaths()  
      java.lang.String getToolTipText​(java.awt.event.MouseEvent event)  
      GTreeState getTreeState()
      Returns a state object that allows this tree to later restore its expanded and selected state.
      GTreeState getTreeState​(GTreeNode node)  
      GTreeNode getViewNodeForPath​(javax.swing.tree.TreePath path)
      Gets the view node for the given path.
      java.awt.Point getViewPosition()
      Returns the current viewport position of the scrollable tree.
      java.awt.Rectangle getViewRect()  
      GTreeNode getViewRoot()
      This method returns the root node currently being displayed by the JTree.
      boolean hasFilterText()  
      boolean isBusy()  
      boolean isCollapsed​(javax.swing.tree.TreePath path)  
      boolean isDisposed()  
      boolean isEditing()  
      boolean isExpanded​(javax.swing.tree.TreePath treePath)  
      boolean isFiltered()  
      boolean isFilteringEnabled()  
      boolean isMyJTree​(javax.swing.JTree jTree)
      Returns true if the given JTree is the actual JTree used by this GTree.
      boolean isPathEditable​(javax.swing.tree.TreePath path)  
      boolean isPathSelected​(javax.swing.tree.TreePath treePath)  
      boolean isRootAllowedToCollapse()  
      boolean isRootVisible()  
      static void printEvent​(java.io.PrintWriter out, java.lang.String name, javax.swing.event.TreeModelEvent e)
      This method is useful for debugging tree problems.
      void refilterLater()
      Causes the tree to refilter some time later
      void refilterLater​(GTreeNode newNode)
      Re-filters the tree if the newNode should be included in the current filter results.
      void refilterNow()
      Causes the tree to refilter immediately (before this method returns)
      void removeGTModelListener​(javax.swing.event.TreeModelListener listener)  
      void removeGTreeSelectionListener​(GTreeSelectionListener listener)  
      void removeMouseListener​(java.awt.event.MouseListener listener)  
      void removeTreeExpansionListener​(javax.swing.event.TreeExpansionListener listener)  
      void restoreTreeState​(GTreeState state)
      Restores the expanded and selected state of this tree to that contained in the given state object.
      void runBulkTask​(GTreeBulkTask task)  
      void runTask​(GTreeTask task)
      Used to run tree tasks.
      void runTask​(MonitoredRunnable runnableTask)
      Used to run simple GTree tasks that can be expressed as a MonitoredRunnable (or a lambda taking a TaskMonitor).
      void scrollPathToVisible​(javax.swing.tree.TreePath treePath)  
      void setActiveDropTargetNode​(GTreeNode node)  
      void setBusy​(boolean busy)  
      void setCellEditor​(javax.swing.tree.TreeCellEditor editor)  
      void setCellRenderer​(GTreeRenderer renderer)  
      void setDataTransformer​(FilterTransformer<GTreeNode> transformer)
      Sets a transformer object used to perform filtering.
      void setDragNDropHandler​(GTreeDragNDropHandler dragNDropHandler)  
      void setEditable​(boolean editable)  
      void setEnabled​(boolean enabled)  
      void setEventsEnabled​(boolean b)
      Turns tree event notifications on/off
      void setFilterFieldEnabled​(boolean enabled)
      Disabled the filter text field, but allows the tree to still filter.
      void setFilteringEnabled​(boolean enabled)
      Disables all filtering performed by this tree.
      void setFilterProvider​(GTreeFilterProvider filterProvider)  
      void setFilterText​(java.lang.String text)  
      void setFilterVisible​(boolean visible)
      Hides the filter field.
      void setHorizontalScrollPolicy​(int policy)  
      void setNodeEditable​(GTreeNode child)  
      void setPaintHandlesForLeafNodes​(boolean enable)
      Passing a value of false signals to disable the JTree's default behavior of showing handles for leaf nodes until they are opened.
      void setRootNode​(GTreeNode rootNode)
      Sets the root node for this tree.
      void setRootNodeAllowedToCollapse​(boolean allowed)  
      void setRootVisible​(boolean b)  
      void setRowHeight​(int rowHeight)  
      void setScrollableUnitIncrement​(int increment)
      Sets the size of the scroll when mouse scrolling or pressing the scroll up/down buttons.
      void setSelectedNode​(GTreeNode node)  
      void setSelectedNodeByNamePath​(java.lang.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.
      void setSelectedNodeByPathName​(javax.swing.tree.TreePath treePath)
      Selects the node that matches the each name in the given tree path.
      void setSelectedNodes​(GTreeNode... nodes)  
      void setSelectedNodes​(java.util.Collection<GTreeNode> nodes)  
      void setSelectionModel​(GTreeSelectionModel selectionModel)  
      void setSelectionPath​(javax.swing.tree.TreePath path)  
      void setSelectionPaths​(java.util.List<javax.swing.tree.TreePath> pathsList)  
      void setSelectionPaths​(javax.swing.tree.TreePath[] paths)  
      void setSelectionPaths​(javax.swing.tree.TreePath[] path, GTreeSelectionEvent.EventOrigin origin)  
      void setSeletedNodeByName​(GTreeNode parentNode, java.lang.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.
      void setShowsRootHandles​(boolean b)  
      void setTransferHandler​(javax.swing.TransferHandler handler)  
      void setViewPosition​(java.awt.Point p)  
      void startEditing​(GTreeNode child)
      Requests that the node be edited.
      void startEditing​(GTreeNode parent, java.lang.String childName)
      Requests that the node with the given name, in the given parent, be edited.
      void stopEditing()  
      java.lang.String toString()  
      protected void updateModelFilter()  
      • Methods inherited from class javax.swing.JPanel

        getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
      • Methods 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, update
      • Methods 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, validateTree
      • Methods 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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • GTree

        public GTree​(GTreeNode root)
        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 Detail

      • setEnabled

        public void setEnabled​(boolean enabled)
        Overrides:
        setEnabled in class javax.swing.JComponent
      • setEventsEnabled

        public void setEventsEnabled​(boolean b)
        Turns tree event notifications on/off
        Parameters:
        b - true to enable events, false to disable events
      • setTransferHandler

        public void setTransferHandler​(javax.swing.TransferHandler handler)
        Overrides:
        setTransferHandler in class javax.swing.JComponent
      • setCellRenderer

        public void setCellRenderer​(GTreeRenderer renderer)
      • 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()
      • getTreeState

        public GTreeState 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
      • restoreTreeState

        public void restoreTreeState​(GTreeState state)
        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:
        getTreeState(), getTreeState(GTreeNode)
      • expandedStateRestored

        public void expandedStateRestored​(TaskMonitor taskMonitor)
        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

        public java.util.List<javax.swing.tree.TreePath> getExpandedPaths()
      • getExpandedPaths

        public java.util.List<javax.swing.tree.TreePath> getExpandedPaths​(GTreeNode node)
      • expandTree

        public void expandTree​(GTreeNode node)
      • expandAll

        public void expandAll()
      • collapseAll

        public void collapseAll​(GTreeNode node)
      • expandPath

        public void expandPath​(GTreeNode node)
      • expandPath

        public void expandPath​(javax.swing.tree.TreePath path)
      • expandPaths

        public void expandPaths​(javax.swing.tree.TreePath[] paths)
      • expandPaths

        public void expandPaths​(java.util.List<javax.swing.tree.TreePath> pathsList)
      • clearSelectionPaths

        public void clearSelectionPaths()
      • setSelectedNode

        public void setSelectedNode​(GTreeNode node)
      • setSelectedNodes

        public void setSelectedNodes​(GTreeNode... nodes)
      • setSelectedNodes

        public void setSelectedNodes​(java.util.Collection<GTreeNode> nodes)
      • setSelectionPaths

        public void setSelectionPaths​(javax.swing.tree.TreePath[] paths)
      • setSelectionPaths

        public void setSelectionPaths​(java.util.List<javax.swing.tree.TreePath> pathsList)
      • setSelectionPath

        public void setSelectionPath​(javax.swing.tree.TreePath path)
      • setSelectedNodeByNamePath

        public void setSelectedNodeByNamePath​(java.lang.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.
        Parameters:
        namePath - The path to select
      • setSeletedNodeByName

        public void setSeletedNodeByName​(GTreeNode parentNode,
                                         java.lang.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.
        Parameters:
        parentNode - The parent containing a child by the given name
        childName - The name of the child to select
      • setSelectedNodeByPathName

        public void setSelectedNodeByPathName​(javax.swing.tree.TreePath treePath)
        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 the toString() of those items will be used.
        Parameters:
        treePath - The path containing the names of the path of the node to select
      • isCollapsed

        public boolean isCollapsed​(javax.swing.tree.TreePath path)
      • setHorizontalScrollPolicy

        public void setHorizontalScrollPolicy​(int policy)
      • getScrollPane

        protected javax.swing.JScrollPane 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

        public GTreeModel getModel()
        Returns the model for this tree
        Returns:
        the model for this tree
      • getJTree

        protected final javax.swing.JTree getJTree()
      • getViewPosition

        public java.awt.Point getViewPosition()
        Returns the current viewport position of the scrollable tree.
        Returns:
        the current viewport position of the scrollable tree.
      • setViewPosition

        public void setViewPosition​(java.awt.Point p)
      • getViewRect

        public java.awt.Rectangle getViewRect()
      • getNodeForLocation

        public GTreeNode getNodeForLocation​(int x,
                                            int y)
      • getModelNodeForPath

        public GTreeNode getModelNodeForPath​(javax.swing.tree.TreePath path)
        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.
      • getViewNodeForPath

        public GTreeNode getViewNodeForPath​(javax.swing.tree.TreePath path)
        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

        public void setActiveDropTargetNode​(GTreeNode node)
      • setFilterText

        public void setFilterText​(java.lang.String text)
      • 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(boolean)
      • 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:
        setFilterFieldEnabled(boolean)
      • setFilterVisible

        public void setFilterVisible​(boolean visible)
        Hides the filter field. Filtering will still take place, as defined by the GTreeFilterProvider.
        Parameters:
        visible - true to show the filter; false to hide it.
        See Also:
        setFilteringEnabled(boolean)
      • isFilteringEnabled

        public boolean isFilteringEnabled()
      • setDataTransformer

        public void setDataTransformer​(FilterTransformer<GTreeNode> transformer)
        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

        public java.awt.Component getFilterField()
        Returns the filter text field in this tree.
        Returns:
        the filter text field in this tree.
      • isMyJTree

        public boolean isMyJTree​(javax.swing.JTree jTree)
        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

        public void setRootNode​(GTreeNode rootNode)
        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

        public GTreeNode getModelRoot()
        This method returns the root node that was provided to the tree by the client, whether from the constructor or from setRootNode(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 the JTree.
        Returns:
        the root node as provided by the client.
      • getViewRoot

        public GTreeNode getViewRoot()
        This method returns the root node currently being displayed by the JTree. If there are no filters applied, then this will be the same as the model root (See getModelRoot()). 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

        public static void printEvent​(java.io.PrintWriter out,
                                      java.lang.String name,
                                      javax.swing.event.TreeModelEvent e)
        This method is useful for debugging tree problems. Don't know where else to put it.
        Parameters:
        out - the output writer
        name - use this to indicate what tree event occurred ("node inserted" "node removed", etc.)
        e - the TreeModelEvent;
      • getSelectionModel

        public javax.swing.tree.TreeSelectionModel getSelectionModel()
      • getRowCount

        public int getRowCount()
      • getRowForPath

        public int getRowForPath​(javax.swing.tree.TreePath treePath)
      • getPathForRow

        public javax.swing.tree.TreePath getPathForRow​(int row)
      • getSelectionPath

        public javax.swing.tree.TreePath getSelectionPath()
      • getSelectionPaths

        public javax.swing.tree.TreePath[] getSelectionPaths()
      • isExpanded

        public boolean isExpanded​(javax.swing.tree.TreePath treePath)
      • isPathSelected

        public boolean isPathSelected​(javax.swing.tree.TreePath treePath)
      • isRootVisible

        public boolean isRootVisible()
      • setRootVisible

        public void setRootVisible​(boolean b)
      • setShowsRootHandles

        public void setShowsRootHandles​(boolean b)
      • scrollPathToVisible

        public void scrollPathToVisible​(javax.swing.tree.TreePath treePath)
      • getCellEditor

        public javax.swing.CellEditor getCellEditor()
      • getPathForLocation

        public javax.swing.tree.TreePath getPathForLocation​(int x,
                                                            int y)
      • getPathBounds

        public java.awt.Rectangle getPathBounds​(javax.swing.tree.TreePath path)
      • setRowHeight

        public void setRowHeight​(int rowHeight)
      • addSelectionPath

        public void addSelectionPath​(javax.swing.tree.TreePath path)
      • addTreeExpansionListener

        public void addTreeExpansionListener​(javax.swing.event.TreeExpansionListener listener)
      • removeTreeExpansionListener

        public void removeTreeExpansionListener​(javax.swing.event.TreeExpansionListener listener)
      • removeGTreeSelectionListener

        public void removeGTreeSelectionListener​(GTreeSelectionListener listener)
      • addGTModelListener

        public void addGTModelListener​(javax.swing.event.TreeModelListener listener)
      • removeGTModelListener

        public void removeGTModelListener​(javax.swing.event.TreeModelListener listener)
      • setEditable

        public void setEditable​(boolean editable)
      • startEditing

        public void startEditing​(GTreeNode parent,
                                 java.lang.String childName)
        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.
        Parameters:
        parent - the parent node
        childName - the name of the child to edit
      • startEditing

        public void startEditing​(GTreeNode child)
        Requests that the node be edited. This operation is asynchronous.
        Parameters:
        child - the node to edit
      • addMouseListener

        public void addMouseListener​(java.awt.event.MouseListener listener)
        Overrides:
        addMouseListener in class java.awt.Component
      • removeMouseListener

        public void removeMouseListener​(java.awt.event.MouseListener listener)
        Overrides:
        removeMouseListener in class java.awt.Component
      • getMouseListeners

        public java.awt.event.MouseListener[] getMouseListeners()
        Overrides:
        getMouseListeners in class java.awt.Component
      • setCellEditor

        public void setCellEditor​(javax.swing.tree.TreeCellEditor editor)
      • isPathEditable

        public boolean isPathEditable​(javax.swing.tree.TreePath path)
      • setPaintHandlesForLeafNodes

        public void setPaintHandlesForLeafNodes​(boolean enable)
        Passing a value of false signals to disable the JTree'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:
        setBusy in interface BusyListener
      • 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

        public void refilterLater​(GTreeNode newNode)
        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.
      • isFiltered

        public boolean isFiltered()
      • hasFilterText

        public boolean hasFilterText()
      • getFilterText

        public java.lang.String getFilterText()
      • clearFilter

        public void clearFilter()
      • runTask

        public void runTask​(GTreeTask task)
        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
      • isEditing

        public boolean isEditing()
      • stopEditing

        public void stopEditing()
      • setNodeEditable

        public void setNodeEditable​(GTreeNode child)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.awt.Component
      • getToolTipText

        public java.lang.String getToolTipText​(java.awt.event.MouseEvent event)
        Overrides:
        getToolTipText in class javax.swing.JComponent
      • clearSizeCache

        public void clearSizeCache()