org.fife.ui.search
Class FindInFilesDialog

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Dialog
                  extended by javax.swing.JDialog
                      extended by org.fife.rsta.ui.EscapableDialog
                          extended by org.fife.rsta.ui.search.AbstractSearchDialog
                              extended by org.fife.ui.search.FindInFilesDialog
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants
Direct Known Subclasses:
ReplaceInFilesDialog

public class FindInFilesDialog
extends org.fife.rsta.ui.search.AbstractSearchDialog

A dialog allowing the user to search for a text string in all files in a directory, so they don't have to do the files one at a time.

Version:
0.8
Author:
Robert Futrell
See Also:
Serialized Form

Nested Class Summary
protected  class FindInFilesDialog.FindInFilesFocusAdapter
          Listens for the text field gaining focus.
 
Nested classes/interfaces inherited from class javax.swing.JDialog
javax.swing.JDialog.AccessibleJDialog
 
Nested classes/interfaces inherited from class java.awt.Dialog
java.awt.Dialog.AccessibleAWTDialog, java.awt.Dialog.ModalExclusionType, java.awt.Dialog.ModalityType
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
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
protected  javax.swing.JButton findButton
           
protected  javax.swing.JComboBox inFilesComboBox
           
protected  FSATextField inFolderTextField
           
protected  javax.swing.JCheckBox subfoldersCheckBox
           
protected  javax.swing.JCheckBox verboseCheckBox
           
 
Fields inherited from class org.fife.rsta.ui.search.AbstractSearchDialog
cancelButton, caseCheckBox, context, findTextCombo, regexCheckBox, searchConditionsPanel, wholeWordCheckBox
 
Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Dialog
DEFAULT_MODALITY_TYPE
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
FindInFilesDialog(java.awt.Frame owner)
          Creates a new FindInFilesDialog.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Called whenever the user does something.
 void addFindInFilesListener(FindInFilesListener listener)
          Adds a find-in-files listener to this find in files dialog.
 void addInFilesComboBoxFilter(java.lang.String filter)
          Adds a file filter to the "In files:" combo box.
protected  SearchContext createDefaultSearchContext()
          Overridden to return the "find in files"-specific search context.
protected  javax.swing.Box createDetailsPanel()
          Creates the panel containing "Report Detail" options.
protected  javax.swing.Box createExtraOptionsPanel()
          Returns a panel containing any extra options, such as a "verbose" output option.
protected  javax.swing.JPanel createInputPanel()
          Creates and returns the panel containing input fields and their labels.
protected  org.fife.ui.search.ResultsComponent createResultsComponent()
          Creates and returns the component used to display search results.
protected  org.fife.ui.search.FindInFilesThread createWorkerThread(java.io.File directory)
          Returns the thread that will do the searching.
protected  void fireFindInFilesEvent(FindInFilesEvent e)
          Notifies all find-in-files listeners of a find-in-files event in this dialog.
protected static int getLength(javax.swing.text.JTextComponent c)
          Returns the length of the text in a text component.
protected  org.fife.ui.search.ResultsComponent getResultsComponent()
          Returns the component used to display results.
protected static javax.swing.text.JTextComponent getTextComponent(javax.swing.JComboBox combo)
          Returns the text editor component for the specified combo box.
protected  org.fife.ui.search.FindInFilesThread getWorkerThread()
          Synchronizes access to our "worker" thread.
protected  org.fife.rsta.ui.search.FindReplaceButtonsEnableResult handleToggleButtons()
          Returns whether any action-related buttons (Find Next, Replace, etc.)
protected  boolean isEverythingFilledIn()
          Returns whether everything in the UI that needs to be filled in for a search to be performed is filled in.
protected  void refreshUIFromContext()
          Overridden to initialize UI elements specific to this subclass.
 void removeFindInFilesListener(FindInFilesListener listener)
          Removes a find-in-files listener to this find in files dialog.
protected  void setSearching(boolean searching)
          Enables or disables widgets in the dialog as appropriate.
 void setStatusText(java.lang.String text)
          Sets the text in the status bar.
 void setVisible(boolean visible)
          Displays or hides the Find in Files dialog.
 void updateUI()
          Called whenever the user changes the Look and Feel, etc.
 
Methods inherited from class org.fife.rsta.ui.search.AbstractSearchDialog
createTitledBorder, escapePressed, focusFindTextField, getBundle, getCancelButtonText, getContentAssistImage, getMatchCaseCheckboxText, getRegularExpressionCheckboxText, getSearchContext, getSearchString, getString, getWholeWordCheckboxText, handleRegExCheckBoxClicked, handleSearchContextPropertyChanged, isPreJava6JRE, isWholeWord, requestFocus, setCancelButtonText, setMatchCaseCheckboxText, setRegularExpressionCheckboxText, setSearchContext, setSearchString, setWholeWordCheckboxText
 
Methods inherited from class org.fife.rsta.ui.EscapableDialog
setEscapeClosesDialog
 
Methods inherited from class javax.swing.JDialog
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
 
Methods inherited from class java.awt.Dialog
addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setModalityType, setResizable, setTitle, setUndecorated, show, toBack
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

inFilesComboBox

protected javax.swing.JComboBox inFilesComboBox

inFolderTextField

protected FSATextField inFolderTextField

subfoldersCheckBox

protected javax.swing.JCheckBox subfoldersCheckBox

findButton

protected javax.swing.JButton findButton

verboseCheckBox

protected javax.swing.JCheckBox verboseCheckBox
Constructor Detail

FindInFilesDialog

public FindInFilesDialog(java.awt.Frame owner)
Creates a new FindInFilesDialog.

Parameters:
owner - The main window that owns this dialog.
Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Called whenever the user does something.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Overrides:
actionPerformed in class org.fife.rsta.ui.search.AbstractSearchDialog

addFindInFilesListener

public void addFindInFilesListener(FindInFilesListener listener)
Adds a find-in-files listener to this find in files dialog.

Parameters:
listener - The listener to add.
See Also:
removeFindInFilesListener(org.fife.ui.search.FindInFilesListener)

addInFilesComboBoxFilter

public void addInFilesComboBoxFilter(java.lang.String filter)
Adds a file filter to the "In files:" combo box.

Parameters:
filter - The filter to add.

createDetailsPanel

protected javax.swing.Box createDetailsPanel()
Creates the panel containing "Report Detail" options.

Returns:
The panel.

createExtraOptionsPanel

protected javax.swing.Box createExtraOptionsPanel()
Returns a panel containing any extra options, such as a "verbose" output option.

Returns:
The panel, or null if there are no extra options.

createInputPanel

protected javax.swing.JPanel createInputPanel()
Creates and returns the panel containing input fields and their labels.

Returns:
The panel.

createResultsComponent

protected org.fife.ui.search.ResultsComponent createResultsComponent()
Creates and returns the component used to display search results.

Returns:
The component.

createDefaultSearchContext

protected SearchContext createDefaultSearchContext()
Overridden to return the "find in files"-specific search context.

Overrides:
createDefaultSearchContext in class org.fife.rsta.ui.search.AbstractSearchDialog
Returns:
The search context.

createWorkerThread

protected org.fife.ui.search.FindInFilesThread createWorkerThread(java.io.File directory)
Returns the thread that will do the searching.

Parameters:
directory - The directory to search in.
Returns:
The thread.

fireFindInFilesEvent

protected void fireFindInFilesEvent(FindInFilesEvent e)
Notifies all find-in-files listeners of a find-in-files event in this dialog.

Parameters:
e - The event to notify all listeners about.

getTextComponent

protected static final javax.swing.text.JTextComponent getTextComponent(javax.swing.JComboBox combo)
Returns the text editor component for the specified combo box.

Parameters:
combo - The combo box.
Returns:
The text component.

getLength

protected static final int getLength(javax.swing.text.JTextComponent c)
Returns the length of the text in a text component.

Parameters:
c - The text component.
Returns:
The number of characters in that text component.

getResultsComponent

protected org.fife.ui.search.ResultsComponent getResultsComponent()
Returns the component used to display results.

Returns:
The component.

getWorkerThread

protected org.fife.ui.search.FindInFilesThread getWorkerThread()
Synchronizes access to our "worker" thread.

Returns:
The thread that is currently searching, or null if no searching is going on.

handleToggleButtons

protected org.fife.rsta.ui.search.FindReplaceButtonsEnableResult handleToggleButtons()
Returns whether any action-related buttons (Find Next, Replace, etc.) should be enabled. Subclasses can call this method when the "Find What" or "Replace With" text fields are modified. They can then enable/disable any components as appropriate.

Overrides:
handleToggleButtons in class org.fife.rsta.ui.search.AbstractSearchDialog
Returns:
Whether the buttons should be enabled.

isEverythingFilledIn

protected boolean isEverythingFilledIn()
Returns whether everything in the UI that needs to be filled in for a search to be performed is filled in.

Returns:
Whether everything is filled in.

refreshUIFromContext

protected void refreshUIFromContext()
Overridden to initialize UI elements specific to this subclass.

Overrides:
refreshUIFromContext in class org.fife.rsta.ui.search.AbstractSearchDialog

removeFindInFilesListener

public void removeFindInFilesListener(FindInFilesListener listener)
Removes a find-in-files listener to this find in files dialog.

Parameters:
listener - The listener to remove
See Also:
addFindInFilesListener(org.fife.ui.search.FindInFilesListener)

setSearching

protected void setSearching(boolean searching)
Enables or disables widgets in the dialog as appropriate.

Parameters:
searching - Whether searching is starting.

setStatusText

public void setStatusText(java.lang.String text)
Sets the text in the status bar.

Parameters:
text - The text to display.

setVisible

public void setVisible(boolean visible)
Displays or hides the Find in Files dialog. Note that you should use this method and not show() to properly display this dialog.

Overrides:
setVisible in class java.awt.Dialog
Parameters:
visible - Whether the dialog should be displayed or hidden.

updateUI

public void updateUI()
Called whenever the user changes the Look and Feel, etc. This is overridden so we can reinstate the listeners that are evidently lost on the JTextField portion of our combo box.