Class FindPanel

  • All Implemented Interfaces:
    ImageObserver, MenuContainer, Serializable, Runnable, Accessible

    public class FindPanel
    extends JPanel
    implements Runnable
    A threaded search accessory.

    Presents tabbed panel interface for specifying file search criteria including search by name and search by type Search by field content and be implemented also. Finded are performed "in the background" with found files displayed dynamically as they are found. Only one search can be active at a time. FindResults are displayed in a scrolling list within a results tab panel.

    Findes are performed asynchronously. The user may stop the search at any time. Accepting or closing find window will automatically stop a search in progress.

    Changing the search options does not affect a search in progress.

    See Also:
    Serialized Form
    • Field Detail

      • DEFAULT_MAX_SEARCH_HITS

        public static final int DEFAULT_MAX_SEARCH_HITS
        Default max number of found items. Prevents overloading results list.
        See Also:
        Constant Field Values
      • owner

        protected Dialog owner
      • actionStart

        protected com.cosylab.vdct.find.FindPanel.FindAction actionStart
      • actionStop

        protected com.cosylab.vdct.find.FindPanel.FindAction actionStop
      • actionClose

        protected com.cosylab.vdct.find.FindPanel.FindAction actionClose
      • searchThread

        protected Thread searchThread
        This version of FindAccesory supports only one active search thread
      • killFind

        protected boolean killFind
        Set to true to stop current search
      • pathPanel

        protected com.cosylab.vdct.find.FindPanel.FindTitle pathPanel
        Displays full path of search base
      • searchTabs

        protected com.cosylab.vdct.find.FindPanel.FindTabs searchTabs
        Find options with results list
      • controlPanel

        protected com.cosylab.vdct.find.FindPanel.FindControls controlPanel
        Find controls with progress display
      • total

        protected int total
        Number of items inspected by current/last search
      • matches

        protected int matches
        Number of items found by current/last search
      • maxMatches

        protected int maxMatches
        Max number of found items to prevent overloading the results list.
    • Constructor Detail

      • FindPanel

        public FindPanel​(Dialog owner)
        Construct a search panel with start and stop actions, option panes and a results list pane that can display up to DEFAULT_MAX_SEARCH_HITS items.
        Parameters:
        owner - owner
    • Method Detail

      • setMaxFindHits

        public void setMaxFindHits​(int max)
        Sets maximum capacity of the results list. Find stops when max number of items found.
        Parameters:
        max - max Max capacity of results list.
      • getMaxFindHits

        public int getMaxFindHits()
        Returns maximum capacity of results list.
        Returns:
        Max capacity of results list.
      • start

        public void start()
        Start a search. The path display will show the starting folder of the search. Finds are recursive and will span the entire folder hierarchy below the base folder. The user may continue to browse with JFileChooser.
      • stop

        public void stop()
        Stop the active search.
      • isRunning

        public boolean isRunning()
        Returns:
        true if a search is currently running
      • run

        public void run()
        Find thread
        Specified by:
        run in interface Runnable
      • goTo

        public void goTo​(Object selectedObject)
        Show selected (in result panel) object.
        Parameters:
        selectedObject - object to show
      • runFind

        protected void runFind​(Group base,
                               com.cosylab.vdct.find.FindFilter[] filters)
                        throws InterruptedException
        Recursive search beginning for objects matching each filter in the filters array. To interrupt set killFind to true. Also stops when number of search hits (matches) equals maxMatches .
        Parameters:
        base - base group where to start search
        filters - filters matches must pass each filters in array
        Throws:
        InterruptedException - if thread is interrupted
      • accept

        protected boolean accept​(Object candidate,
                                 com.cosylab.vdct.find.FindFilter[] filters)
        Match check.
        Parameters:
        candidate - candidate candidate to pass to each filter's accept method
        filters - filters array of selection criteria
        Returns:
        true if specified candidate matches each filter's selection criteria
      • reportProgress

        public boolean reportProgress​(com.cosylab.vdct.find.FindFilter filter,
                                      Object searchee,
                                      long current,
                                      long total)
        Called by FindFilter to report progress of a search. Purely a voluntary report. This really should be implemented as a property change listener. Percentage completion = (current/total)*100.
        Parameters:
        filter - filter FindFilter reporting progress
        searchee - searchee object being searched
        current - current current "location" of search
        total - total expected maximum value of current
        Returns:
        true to continue search, false to abort
      • newFind

        protected com.cosylab.vdct.find.FindFilter[] newFind()
        Begins a new search by resetting the total and matches progress variables and retrieves the search filter array from the options panel. Each tab in the options panel is responsible for generating a FindFilter based on its current settings.
        Returns:
        Array of search filters from the options panel.
      • updateProgress

        protected void updateProgress()
        Display progress of running search.
      • quit

        public void quit()
        Stop the current search and unregister in preparation for parent shutdown.
      • action

        public void action​(String command)
        Invoked by FindAction objects to start and stop searches.
        Parameters:
        command - command