Search in sources :

Example 6 with EditorController

use of org.omegat.gui.editor.EditorController in project omegat by omegat-org.

the class ReplaceFilter method replace.

private void replace() {
    EditorController ec = (EditorController) Core.getEditor();
    // is caret inside match ?
    int pos = ec.getCurrentPositionInEntryTranslation();
    String str = ec.getCurrentTranslation();
    List<SearchMatch> found = getReplacementsForEntry(str);
    if (found != null) {
        for (SearchMatch m : found) {
            if (m.getStart() <= pos && pos <= m.getEnd()) {
                // yes - replace
                ec.replacePartOfText(m.getReplacement(), m.getStart(), m.getEnd());
                break;
            }
        }
    }
    // skip to next
    skip();
}
Also used : EditorController(org.omegat.gui.editor.EditorController) SearchMatch(org.omegat.core.search.SearchMatch)

Aggregations

EditorController (org.omegat.gui.editor.EditorController)6 SourceTextEntry (org.omegat.core.data.SourceTextEntry)3 SearchMatch (org.omegat.core.search.SearchMatch)3 CaretPosition (org.omegat.gui.editor.IEditor.CaretPosition)3 PrepareTMXEntry (org.omegat.core.data.PrepareTMXEntry)2 TMXEntry (org.omegat.core.data.TMXEntry)2 IEditor (org.omegat.gui.editor.IEditor)2 Component (java.awt.Component)1 Container (java.awt.Container)1 Toolkit (java.awt.Toolkit)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 KeyEvent (java.awt.event.KeyEvent)1 WindowAdapter (java.awt.event.WindowAdapter)1 WindowEvent (java.awt.event.WindowEvent)1 WindowListener (java.awt.event.WindowListener)1 File (java.io.File)1 MessageFormat (java.text.MessageFormat)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1