use of org.omegat.gui.editor.filter.ReplaceFilter in project omegat by omegat-org.
the class SearchWindowController method doReplace.
private void doReplace() {
String replaceString = form.m_replaceField.getEditor().getItem().toString();
replaceString = StringUtil.normalizeUnicode(replaceString);
HistoryManager.addReplaceItem(replaceString);
form.m_replaceField.setModel(new DefaultComboBoxModel<>(HistoryManager.getReplaceItems()));
EntryListPane viewer = (EntryListPane) form.m_viewer;
// Otherwise, the current segment being edited is lost
Core.getEditor().commitAndLeave();
Core.getEditor().setFilter(new ReplaceFilter(viewer.getEntryList(), viewer.getSearcher()));
}
use of org.omegat.gui.editor.filter.ReplaceFilter in project omegat by omegat-org.
the class SearchWindowController method doReplaceAll.
private void doReplaceAll() {
String replaceString = form.m_replaceField.getEditor().getItem().toString();
replaceString = StringUtil.normalizeUnicode(replaceString);
HistoryManager.addReplaceItem(replaceString);
form.m_replaceField.setModel(new DefaultComboBoxModel<>(HistoryManager.getReplaceItems()));
EntryListPane viewer = (EntryListPane) form.m_viewer;
// Otherwise, the current segment being edited is lost
Core.getEditor().commitAndDeactivate();
int count = viewer.getEntryList().size();
String msg = MessageFormat.format(OStrings.getString("SW_REPLACE_ALL_CONFIRM"), count);
int r = JOptionPane.showConfirmDialog(form, msg, OStrings.getString("CONFIRM_DIALOG_TITLE"), JOptionPane.YES_NO_OPTION);
if (r == JOptionPane.YES_OPTION) {
new ReplaceFilter(viewer.getEntryList(), viewer.getSearcher()).replaceAll();
}
Core.getEditor().activateEntry();
form.m_replaceButton.setEnabled(false);
form.m_replaceAllButton.setEnabled(false);
}
use of org.omegat.gui.editor.filter.ReplaceFilter in project omegat by omegat-org.
the class ReplaceMarker method getMarksForEntry.
@Override
public List<Mark> getMarksForEntry(SourceTextEntry ste, String sourceText, String translationText, boolean isActive) throws Exception {
IEditorFilter filter = Core.getEditor().getFilter();
if (filter == null || !(filter instanceof ReplaceFilter)) {
return Collections.emptyList();
}
ReplaceFilter replaceFilter = (ReplaceFilter) filter;
List<SearchMatch> matches = replaceFilter.getReplacementsForEntry(translationText);
if (matches == null) {
return Collections.emptyList();
}
List<Mark> r = new ArrayList<Mark>(matches.size());
for (SearchMatch s : matches) {
Mark m = new Mark(Mark.ENTRY_PART.TRANSLATION, s.getStart(), s.getEnd());
m.painter = PAINTER;
r.add(m);
}
return r;
}
Aggregations