Search in sources :

Example 1 with Preferences

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);
                }
            }
        }
    });
}
Also used : OConsts(org.omegat.util.OConsts) SourceTextEntry(org.omegat.core.data.SourceTextEntry) EditorController(org.omegat.gui.editor.EditorController) Date(java.util.Date) Platform(org.omegat.util.Platform) StaticUIUtils(org.omegat.util.gui.StaticUIUtils) StringUtil(org.omegat.util.StringUtil) OSXIntegration(org.omegat.util.gui.OSXIntegration) WindowListener(java.awt.event.WindowListener) Core(org.omegat.core.Core) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) SearchFilter(org.omegat.gui.editor.filter.SearchFilter) ParseException(java.text.ParseException) JComboBox(javax.swing.JComboBox) JFrame(javax.swing.JFrame) KeyStroke(javax.swing.KeyStroke) SpinnerDateModel(javax.swing.SpinnerDateModel) BadLocationException(javax.swing.text.BadLocationException) KeyEvent(java.awt.event.KeyEvent) WindowAdapter(java.awt.event.WindowAdapter) Component(java.awt.Component) WindowEvent(java.awt.event.WindowEvent) AbstractAction(javax.swing.AbstractAction) Preferences(org.omegat.util.Preferences) Toolkit(java.awt.Toolkit) ActionListener(java.awt.event.ActionListener) OmegaTFileChooser(org.omegat.util.gui.OmegaTFileChooser) JTextField(javax.swing.JTextField) SpinnerNumberModel(javax.swing.SpinnerNumberModel) Log(org.omegat.util.Log) Mnemonics(org.openide.awt.Mnemonics) SimpleDateFormat(java.text.SimpleDateFormat) UndoManager(javax.swing.undo.UndoManager) CaretPosition(org.omegat.gui.editor.IEditor.CaretPosition) MessageFormat(java.text.MessageFormat) IEditor(org.omegat.gui.editor.IEditor) Calendar(java.util.Calendar) OStrings(org.omegat.util.OStrings) Container(java.awt.Container) Searcher(org.omegat.core.search.Searcher) SearchExpression(org.omegat.core.search.SearchExpression) UIThreadsUtil(org.omegat.util.gui.UIThreadsUtil) JOptionPane(javax.swing.JOptionPane) IEditorFilter(org.omegat.gui.editor.IEditorFilter) ActionEvent(java.awt.event.ActionEvent) File(java.io.File) SearchMode(org.omegat.core.search.SearchMode) ReplaceFilter(org.omegat.gui.editor.filter.ReplaceFilter) SearchThread(org.omegat.core.threads.SearchThread) InputMap(javax.swing.InputMap) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter) AbstractAction(javax.swing.AbstractAction)

Aggregations

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 Calendar (java.util.Calendar)1 Date (java.util.Date)1 AbstractAction (javax.swing.AbstractAction)1 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)1 InputMap (javax.swing.InputMap)1 JComboBox (javax.swing.JComboBox)1 JFrame (javax.swing.JFrame)1