Find and replace user interface
To build the find and replace user interface in SimplyHTML the following set of classes is used that already existed from another project:
Class |
Purpose |
FindReplaceDialog |
User interface and main functionality |
FindReplaceListener |
Listener to achieve search and replace over multiple documents |
FindReplaceEvent |
Event being thrown when a document search is finalized and another document would be needed for multi document find and replace |
Above classes are taken from package de.calcom.cclib.text and encapsulate the complete logic and user interface needed to implement find and replace in a typical dialog. FindReplaceDialog only has been extended with internationalization supprt so that it can be used language independent inside SimplyHTML.
Usage of the dialog is very simple. Once added to SimplyHTML (or any other project) it is instanciated with a JEditorPane as a parameter. The JEditorPane is expected to have the document to perform search and replace upon. FindReplaceDialog then does all find and replace operations including document manipulation, user messages, state handling and optional multi document processing.
To control the state of the dialog FindReplaceDialog uses a flag to indicate the current operation in process. It can be one of
See the following topics to learn more about how find and replace logic is implemented in these classes.