Package com.cosylab.vdct.find
Class FindPanel
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- com.cosylab.vdct.find.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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
-
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
-
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
-
Field Summary
Fields Modifier and Type Field Description static String
ACCESSORY_NAME
Label for this accessory.static String
ACTION_CLOSE
Close action namestatic String
ACTION_START
Find start action namestatic String
ACTION_STOP
Find stop action nameprotected com.cosylab.vdct.find.FindPanel.FindAction
actionClose
protected com.cosylab.vdct.find.FindPanel.FindAction
actionStart
protected com.cosylab.vdct.find.FindPanel.FindAction
actionStop
protected com.cosylab.vdct.find.FindPanel.FindControls
controlPanel
Find controls with progress displaystatic int
DEFAULT_MAX_SEARCH_HITS
Default max number of found items.protected boolean
killFind
Set to true to stop current searchprotected int
matches
Number of items found by current/last searchprotected int
maxMatches
Max number of found items to prevent overloading the results list.protected Dialog
owner
protected com.cosylab.vdct.find.FindPanel.FindTitle
pathPanel
Displays full path of search baseprotected com.cosylab.vdct.find.FindPanel.FindTabs
searchTabs
Find options with results listprotected Thread
searchThread
This version of FindAccesory supports only one active search threadprotected int
total
Number of items inspected by current/last search-
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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
accept(Object candidate, com.cosylab.vdct.find.FindFilter[] filters)
Match check.void
action(String command)
Invoked by FindAction objects to start and stop searches.int
getMaxFindHits()
Returns maximum capacity of results list.void
goTo(Object selectedObject)
Show selected (in result panel) object.boolean
isRunning()
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.void
quit()
Stop the current search and unregister in preparation for parent shutdown.boolean
reportProgress(com.cosylab.vdct.find.FindFilter filter, Object searchee, long current, long total)
Called by FindFilter to report progress of a search.void
run()
Find threadprotected void
runFind(Group base, com.cosylab.vdct.find.FindFilter[] filters)
Recursive search beginning for objects matching each filter in the filters array.void
setMaxFindHits(int max)
Sets maximum capacity of the results list.void
start()
Start a search.void
stop()
Stop the active search.protected void
updateProgress()
Display progress of running search.-
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, 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, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, 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, addMouseListener, 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, getMouseListeners, 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, removeMouseListener, 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, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
ACCESSORY_NAME
public static final String ACCESSORY_NAME
Label for this accessory.- See Also:
- Constant Field Values
-
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
-
ACTION_START
public static final String ACTION_START
Find start action name- See Also:
- Constant Field Values
-
ACTION_STOP
public static final String ACTION_STOP
Find stop action name- See Also:
- Constant Field Values
-
ACTION_CLOSE
public static final String ACTION_CLOSE
Close action name- 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
-
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 searchfilters
- 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 methodfilters
- 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 progresssearchee
- searchee object being searchedcurrent
- current current "location" of searchtotal
- 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
-
-