use of org.omegat.util.Preferences in project omegat by omegat-org.
the class SearchWindowController method initActions.
final void initActions() {
// ///////////////////////////////////
// action listeners
form.m_dismissButton.addActionListener(e -> doCancel());
form.m_filterButton.addActionListener(e -> doFilter());
form.m_replaceButton.addActionListener(e -> doReplace());
form.m_replaceAllButton.addActionListener(e -> doReplaceAll());
form.m_searchButton.addActionListener(e -> doSearch());
form.m_advancedButton.addActionListener(e -> setAdvancedOptionsVisible(!form.m_advancedVisiblePane.isVisible()));
form.m_authorCB.addActionListener(e -> enableDisableAuthor());
form.m_authorField.addActionListener(e -> doSearch());
form.m_dateToCB.addActionListener(e -> enableDisableDateTo());
form.m_dateToButton.addActionListener(e -> doResetDateTo());
form.m_dateFromButton.addActionListener(e -> doResetDateFrom());
form.m_dateFromCB.addActionListener(e -> enableDisableDateFrom());
form.m_dirButton.addActionListener(e -> doBrowseDirectory());
StaticUIUtils.setEscapeAction(form, new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
doCancel();
}
});
// Set search and replace combo boxes' actions, undo, key handling
configureHistoryComboBox(form.m_searchField);
configureHistoryComboBox(form.m_replaceField);
// need to control check boxes and radio buttons manually
//
// keyword search can only be used when searching current project
// TM search only works with exact/regex search on current project
// file search only works with exact/regex search
//
// keep track of settings and only show what are valid choices
ActionListener searchFieldRequestFocus = e -> form.m_searchField.requestFocus();
form.m_searchExactSearchRB.addActionListener(searchFieldRequestFocus);
form.m_searchKeywordSearchRB.addActionListener(searchFieldRequestFocus);
form.m_searchRegexpSearchRB.addActionListener(searchFieldRequestFocus);
form.m_searchCase.addActionListener(searchFieldRequestFocus);
form.m_searchSpaceMatchNbsp.addActionListener(searchFieldRequestFocus);
form.m_searchSource.addActionListener(searchFieldRequestFocus);
form.m_searchTranslation.addActionListener(searchFieldRequestFocus);
form.m_searchTranslatedUntranslated.addActionListener(searchFieldRequestFocus);
form.m_searchTranslated.addActionListener(searchFieldRequestFocus);
form.m_searchUntranslated.addActionListener(searchFieldRequestFocus);
form.m_searchNotesCB.addActionListener(searchFieldRequestFocus);
form.m_searchCommentsCB.addActionListener(searchFieldRequestFocus);
form.m_cbSearchInGlossaries.addActionListener(searchFieldRequestFocus);
form.m_cbSearchInMemory.addActionListener(searchFieldRequestFocus);
form.m_cbSearchInTMs.addActionListener(searchFieldRequestFocus);
form.m_allResultsCB.addActionListener(searchFieldRequestFocus);
form.m_fileNamesCB.addActionListener(searchFieldRequestFocus);
form.m_autoSyncWithEditor.addActionListener(e -> {
// update auto-sync flag in EntryListPane
EntryListPane viewer = (EntryListPane) form.m_viewer;
viewer.setAutoSyncWithEditor(form.m_autoSyncWithEditor.isSelected());
});
form.m_rbDir.addActionListener(e -> {
updateOptionStatus();
// otherwise move focus to search field
if (form.m_rbDir.isSelected()) {
form.m_dirField.requestFocus();
} else {
form.m_searchField.requestFocus();
}
});
form.m_rbProject.addActionListener(e -> {
updateOptionStatus();
form.m_searchField.requestFocus();
});
form.m_numberOfResults.addChangeListener(e -> {
// move focus to search edit field
form.m_searchField.requestFocus();
});
form.addWindowListener(new WindowAdapter() {
@Override
public void windowClosed(WindowEvent e) {
// save user preferences
savePreferences();
if (thread != null) {
thread.fin();
}
// back to the initial segment
int currentEntry = Core.getEditor().getCurrentEntryNumber();
if (initialEntry > 0 && form.m_backToInitialSegment.isSelected() && initialEntry != currentEntry) {
boolean isSegDisplayed = isSegmentDisplayed(initialEntry);
if (isSegDisplayed) {
// Restore caretPosition too
((EditorController) Core.getEditor()).gotoEntry(initialEntry, initialCaret);
} else {
// The segment is not displayed (maybe filter on). Ignore caretPosition.
Core.getEditor().gotoEntry(initialEntry);
}
}
}
});
}
Aggregations