Search in sources :

Example 1 with ContentAutoCompleters

use of org.jabref.logic.autocompleter.ContentAutoCompleters 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)

Aggregations

BorderLayout (java.awt.BorderLayout)1 JSplitPane (javax.swing.JSplitPane)1 AutoCompletePreferences (org.jabref.logic.autocompleter.AutoCompletePreferences)1 ContentAutoCompleters (org.jabref.logic.autocompleter.ContentAutoCompleters)1