de.calcom.cclib.text
public class FindReplaceDialog extends JDialog
Document
shown
in a JEditorPane
.
The component has a 'pluggable' interface about how to deal with the event that one document has been searched to the end. If it is constructed with a FindReplaceListener, it shows an additional checkbox 'Whole project' where the user can select, if a group of documents shall be searched instead of a single document.
If only one document is searched, the dialog searches only in the document currently shown in the editor.
By adding a FindReplaceListener listening for FindReplaceEvents, the FindReplaceDialog notifies other classes about the fact that a group of documents shall be searched instead of only the current one.
Initially FindReplaceDialog notifies the listener that the first document in the group shall be loaded into the editor.
After loading the first document and resuming the find or replace operation, the listener gets informed that the end of a document has been reached. A handling method for that event should cause the editor to load the next document in the group before it resumes the find or replace operation.
Example for an implementation of FindReplaceListener:
IMPORTANT: the methods of the FindReplaceListener need to call either resumeOperation() or terminateOperation() on the FindReplaceDialog, that fired the FindReplaceEvent. Otherwise the FindReplaceDialog could 'hang'.
FindReplaceDialog frd = new FindReplaceDialog(aFrame, myEditorPane, new MyFindReplaceListener()); protected class MyFindReplaceListener implements FindReplaceListener { public void getNextDocument(FindReplaceEvent e) { if(documentsLeft()) { // documentsLeft() is a method coded somewhere else myEditorPane.setDocument(nextDocument()); // nextDocument() is a method coded somewhere else ((FindReplaceDialog) e.getSource()).resumeOperation(); } else { ((FindReplaceDialog) e.getSource()).terminateOperation(); } } public void getFirstDocument(FindReplaceEvent e) { myEditorPane.setDocument(firstDocument()); // firstDocument() is a method coded somewhere else ((FindReplaceDialog) e.getSource()).resumeOperation(); } }
Added i18n support for application SimplyHTML in version 1.5
Version: 1.5, April 27, 2003
See Also: javax.swing.text.Document javax.swing.JEditorPane
Field Summary | |
---|---|
static int | MODE_DOCUMENT |
static int | MODE_PROJECT |
static int | OP_FIND |
static int | OP_NONE |
static int | OP_REPLACE |
static int | RO_ALL |
static int | RO_DONE |
static int | RO_NO |
static int | RO_YES |
static boolean | STATE_LOCKED |
static boolean | STATE_UNLOCKED |
Constructor Summary | |
---|---|
FindReplaceDialog()
Construct a FindReplaceDialog .
| |
FindReplaceDialog(Frame owner, JEditorPane editor)
Construct a FindReplaceDialog .
| |
FindReplaceDialog(Frame owner, JEditorPane editor, FindReplaceListener listener)
Construct a FindReplaceDialog .
|
Method Summary | |
---|---|
void | addFindReplaceListener(FindReplaceListener listener)
add an event listener to this dialog.
|
void | centerDialog(Frame owner)
Center this dialog window relative to its owning Frame .
|
void | removeFindReplaceListener(FindReplaceListener listener)
remove an event listener from this dialog.
|
void | resumeOperation()
Resume the current operation after a getFirstDocument or getNextDocument
event was fired |
void | setEditor(JEditorPane editor)
Set the JEditorPane holding the document to be searched
|
void | setMode(int mode)
Set the mode.
|
void | terminateOperation()
Terminate the current operation |
FindReplaceDialog
.
Does not show the dialog window, as fields 'editor' and 'doc' have to be set separately before the dialog is operable.
See Also: javax.swing.JEditorPane javax.swing.text.Document java.awt.Frame
FindReplaceDialog
.
Shows the dialog window modal, packed and centered over the owning
Frame
after construction.
Using this constructor implies the dialog shall be used in mode MODE_DOCUMENT
Parameters: owner the Frame
that owns this dialog editor JEditorPane
displaying the
Document
to seach in
See Also: javax.swing.JEditorPane javax.swing.text.Document java.awt.Frame
FindReplaceDialog
.
Shows the dialog window modal, packed and centered over the owning
Frame
after construction.
Using this constructor implies the dialog shall be used in mode MODE_PROJECT
Parameters: owner the Frame
that owns this dialog editor JEditorPane
displaying the
Document
to seach in listener listener for handling FindReplaceEvents
See Also: javax.swing.JEditorPane javax.swing.text.Document java.awt.Frame
Parameters: listener the event listener to add
Frame
.
Parameters: owner Frame
owning this dialog
See Also: java.awt.Frame
Parameters: listener the event listener to remove
Parameters: editor the JEditorPane holding the document to be searched
See Also: javax.swing.JEditorPane
Switches between
Parameters: mode one of MODE_DOCUMENT and MODE_PROJECT