org.fife.ui.search
Class FindInFilesDialog

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

public class FindInFilesDialog
extends AbstractSearchDialog
implements java.awt.event.ActionListener

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
 
Nested classes inherited from class org.fife.ui.search.AbstractSearchDialog
AbstractSearchDialog.EnableResult
 
Nested classes inherited from class javax.swing.JDialog
javax.swing.JDialog.AccessibleJDialog
 
Nested classes inherited from class java.awt.Dialog
java.awt.Dialog.AccessibleAWTDialog
 
Nested classes inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  javax.swing.JButton findButton
           
protected  javax.swing.JComboBox inFilesComboBox
           
protected  FSATextField inFolderTextField
           
static java.lang.String SEARCH_STRINGS_PROPERTY
          Property notification sent out when the user does a search.
protected  javax.swing.JCheckBox subfoldersCheckBox
           
protected  javax.swing.JCheckBox verboseCheckBox
           
 
Fields inherited from class org.fife.ui.search.AbstractSearchDialog
cancelButton, caseCheckBox, findTextCombo, MATCH_CASE_PROPERTY, MATCH_WHOLE_WORD_PROPERTY, regExpCheckBox, searchConditionsPanel, USE_REG_EX_PROPERTY, wholeWordCheckBox
 
Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabled
 
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.
FindInFilesDialog(java.awt.Frame owner, java.util.ResourceBundle msg)
          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  javax.swing.JPanel createDetailsPanel(java.util.ResourceBundle msg)
          Creates the panel containing "Report Detail" options.
protected  javax.swing.JPanel createExtraOptionsPanel(java.util.ResourceBundle msg)
          Returns a panel containing any extra options, such as a "verbose" output option.
protected  javax.swing.JPanel createInputPanel(java.util.ResourceBundle msg)
          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.
 java.util.Vector getSearchStrings()
          Returns a Vector containing all of the search strings in the "Find what" combo box's history.
protected  org.fife.ui.search.FindInFilesThread getWorkerThread()
          Synchronizes access to our "worker" thread.
protected  AbstractSearchDialog.EnableResult 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.
 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 setSearchParameters(java.lang.String searchString, boolean matchCase, boolean wholeWord, boolean regExp)
          This function should be called to update match case, whole word, etc.
 void setSearchParameters(java.util.Vector findComboBoxStrings, boolean matchCase, boolean wholeWord, boolean regExp)
          This function should be called to update match case, whole word, etc.
 void setSearchString(java.lang.String newSearchString)
          Sets the String to search for.
 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.ui.search.AbstractSearchDialog
createSearchComboBox, createTitledBorder, escapePressed, getCancelButtonText, getContentAssistImage, getMatchCaseCheckboxText, getRegularExpressionCheckboxText, getSearchString, getTextComponent, getWholeWordCheckboxText, handleRegExCheckBoxClicked, isPreJava6JRE, isWholeWord, setCancelButtonText, setMatchCaseCheckboxText, setRegularExpressionCheckboxText, setWholeWordCheckboxText
 
Methods inherited from class org.fife.ui.EscapableDialog
setEscapeClosesDialog
 
Methods inherited from class javax.swing.JDialog
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Dialog
addNotify, dispose, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setResizable, setTitle, setUndecorated, show
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, finalize, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, isActive, isFocusableWindow, isFocusCycleRoot, isFocused, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationRelativeTo, toBack, 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, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, removeNotify, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, 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, isOpaque, 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, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SEARCH_STRINGS_PROPERTY

public static final java.lang.String SEARCH_STRINGS_PROPERTY
Property notification sent out when the user does a search. This notifies that the list of search strings in the "Find what" combo box has changed. Note that the "old" value will always be null; the "new" value is a Vector of strings containing the new values.

See Also:
Constant Field Values

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.

FindInFilesDialog

public FindInFilesDialog(java.awt.Frame owner,
                         java.util.ResourceBundle msg)
Creates a new FindInFilesDialog.

Parameters:
owner - The owner of this dialog.
msg - The resource bundle.
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 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.JPanel createDetailsPanel(java.util.ResourceBundle msg)
Creates the panel containing "Report Detail" options.

Parameters:
msg - The resource bundle.
Returns:
The panel.

createExtraOptionsPanel

protected javax.swing.JPanel createExtraOptionsPanel(java.util.ResourceBundle msg)
Returns a panel containing any extra options, such as a "verbose" output option.

Parameters:
msg - The resource bundle.
Returns:
The panel, or null if there are no extra options.

createInputPanel

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

Parameters:
msg - The resource bundle.
Returns:
The panel.

createResultsComponent

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

Returns:
The component.

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.

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.

getSearchStrings

public java.util.Vector getSearchStrings()
Returns a Vector containing all of the search strings in the "Find what" combo box's history.

Overrides:
getSearchStrings in class AbstractSearchDialog
Returns:
The search strings in the Find combo box's history.

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 AbstractSearchDialog.EnableResult 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 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 eveything is filled in.

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)

setSearchParameters

public void setSearchParameters(java.lang.String searchString,
                                boolean matchCase,
                                boolean wholeWord,
                                boolean regExp)
This function should be called to update match case, whole word, etc.

Parameters:
searchString - The text the user wants to search for.
matchCase - Whether the "match case" checkbox should be checked.
wholeWord - Whether the "whole word" checkbox should be checked.

setSearchParameters

public void setSearchParameters(java.util.Vector findComboBoxStrings,
                                boolean matchCase,
                                boolean wholeWord,
                                boolean regExp)
This function should be called to update match case, whole word, etc.


setSearching

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

Parameters:
searching - Whether searching is starting.

setSearchString

public void setSearchString(java.lang.String newSearchString)
Sets the String to search for.

Overrides:
setSearchString in class AbstractSearchDialog
Parameters:
newSearchString - The String to put into the search field.

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 AbstractSearchDialog
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.