Search in sources :

Example 1 with AutoCompletePreferences

use of org.jabref.logic.autocompleter.AutoCompletePreferences in project jabref by JabRef.

the class BasePanel method setupMainPanel.

public void setupMainPanel() {
    splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    splitPane.setDividerSize(SPLIT_PANE_DIVIDER_SIZE);
    // restore last splitting state (before mainTable is created as creation affects the stored size of the entryEditors)
    adjustSplitter();
    // check whether a mainTable already existed and a floatSearch was active
    boolean floatSearchActive = (mainTable != null) && (this.tableModel.getSearchState() == MainTableDataModel.DisplayOption.FLOAT);
    createMainTable();
    splitPane.setTopComponent(mainTable.getPane());
    // Remove borders
    splitPane.setBorder(BorderFactory.createEmptyBorder());
    setBorder(BorderFactory.createEmptyBorder());
    // otherwise set the bottom component to null.
    if (mode == BasePanelMode.SHOWING_PREVIEW) {
        mode = BasePanelMode.SHOWING_NOTHING;
        highlightEntry(selectionListener.getPreview().getEntry());
    } else if (mode == BasePanelMode.SHOWING_EDITOR) {
        mode = BasePanelMode.SHOWING_NOTHING;
    } else {
        splitPane.setBottomComponent(null);
    }
    setLayout(new BorderLayout());
    removeAll();
    add(splitPane, BorderLayout.CENTER);
    // Set up name autocompleter for search:
    instantiateSearchAutoCompleter();
    this.getDatabase().registerListener(new SearchAutoCompleteListener());
    AutoCompletePreferences autoCompletePreferences = new AutoCompletePreferences(Globals.prefs);
    // Set up AutoCompleters for this panel:
    if (Globals.prefs.getBoolean(JabRefPreferences.AUTO_COMPLETE)) {
        autoCompleters = new ContentAutoCompleters(getDatabase(), bibDatabaseContext.getMetaData(), autoCompletePreferences, Globals.journalAbbreviationLoader);
        // ensure that the autocompleters are in sync with entries
        this.getDatabase().registerListener(new AutoCompleteListener());
    } else {
        // create empty ContentAutoCompleters() if autoCompletion is deactivated
        autoCompleters = new ContentAutoCompleters();
    }
    // (needed if preferences have been changed which causes a recreation of the main table)
    if (floatSearchActive) {
        mainTable.showFloatSearch();
    }
    splitPane.revalidate();
    revalidate();
    repaint();
    // saves the divider position as soon as it changes
    splitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, event -> saveDividerLocation());
}
Also used : BorderLayout(java.awt.BorderLayout) AutoCompletePreferences(org.jabref.logic.autocompleter.AutoCompletePreferences) JSplitPane(javax.swing.JSplitPane) ContentAutoCompleters(org.jabref.logic.autocompleter.ContentAutoCompleters)

Example 2 with AutoCompletePreferences

use of org.jabref.logic.autocompleter.AutoCompletePreferences in project jabref by JabRef.

the class BasePanel method instantiateSearchAutoCompleter.

private void instantiateSearchAutoCompleter() {
    AutoCompletePreferences autoCompletePreferences = new AutoCompletePreferences(Globals.prefs);
    AutoCompleterFactory autoCompleterFactory = new AutoCompleterFactory(autoCompletePreferences, Globals.journalAbbreviationLoader);
    searchAutoCompleter = autoCompleterFactory.getPersonAutoCompleter();
    for (BibEntry entry : bibDatabaseContext.getDatabase().getEntries()) {
        searchAutoCompleter.addBibtexEntry(entry);
    }
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) AutoCompleterFactory(org.jabref.logic.autocompleter.AutoCompleterFactory) AutoCompletePreferences(org.jabref.logic.autocompleter.AutoCompletePreferences)

Aggregations

AutoCompletePreferences (org.jabref.logic.autocompleter.AutoCompletePreferences)2 BorderLayout (java.awt.BorderLayout)1 JSplitPane (javax.swing.JSplitPane)1 AutoCompleterFactory (org.jabref.logic.autocompleter.AutoCompleterFactory)1 ContentAutoCompleters (org.jabref.logic.autocompleter.ContentAutoCompleters)1 BibEntry (org.jabref.model.entry.BibEntry)1