Search in sources :

Example 26 with BasePanel

use of org.jabref.gui.BasePanel in project jabref by JabRef.

the class OpenDatabaseAction method addNewDatabase.

private BasePanel addNewDatabase(ParserResult result, final Path file, boolean raisePanel) {
    BibDatabase database = result.getDatabase();
    if (result.hasWarnings()) {
        JabRefExecutorService.INSTANCE.execute(() -> ParserResultWarningDialog.showParserResultWarningDialog(result, frame));
    }
    BasePanel basePanel = new BasePanel(frame, result.getDatabaseContext());
    // file is set to null inside the EventDispatcherThread
    SwingUtilities.invokeLater(() -> frame.addTab(basePanel, raisePanel));
    if (Objects.nonNull(file)) {
        frame.output(Localization.lang("Opened library") + " '" + file.toString() + "' " + Localization.lang("with") + " " + database.getEntryCount() + " " + Localization.lang("entries") + ".");
    }
    return basePanel;
}
Also used : BasePanel(org.jabref.gui.BasePanel) BibDatabase(org.jabref.model.database.BibDatabase)

Example 27 with BasePanel

use of org.jabref.gui.BasePanel in project jabref by JabRef.

the class ConnectToSharedDatabaseDialog method openSharedDatabase.

public void openSharedDatabase() {
    if (isSharedDatabaseAlreadyPresent()) {
        JOptionPane.showMessageDialog(ConnectToSharedDatabaseDialog.this, Localization.lang("You are already connected to a database using entered connection details."), Localization.lang("Warning"), JOptionPane.WARNING_MESSAGE);
        return;
    }
    if (autosaveFile.isSelected()) {
        Path localFilePath = Paths.get(fileLocationField.getText());
        if (Files.exists(localFilePath) && !Files.isDirectory(localFilePath)) {
            int answer = JOptionPane.showConfirmDialog(this, Localization.lang("'%0' exists. Overwrite file?", localFilePath.getFileName().toString()), Localization.lang("Existing file"), JOptionPane.YES_NO_OPTION);
            if (answer == JOptionPane.NO_OPTION) {
                fileLocationField.requestFocus();
                return;
            }
        }
    }
    setLoadingConnectButtonText(true);
    try {
        BasePanel panel = new SharedDatabaseUIManager(frame).openNewSharedDatabaseTab(connectionProperties);
        setPreferences();
        dispose();
        if (!fileLocationField.getText().isEmpty()) {
            try {
                new SaveDatabaseAction(panel, Paths.get(fileLocationField.getText())).runCommand();
            } catch (Throwable e) {
                LOGGER.error("Error while saving the database", e);
            }
        }
        // setLoadingConnectButtonText(false) should not be reached regularly.
        return;
    } catch (SQLException | InvalidDBMSConnectionPropertiesException exception) {
        JOptionPane.showMessageDialog(ConnectToSharedDatabaseDialog.this, exception.getMessage(), Localization.lang("Connection error"), JOptionPane.ERROR_MESSAGE);
    } catch (DatabaseNotSupportedException exception) {
        new MigrationHelpDialog(this).setVisible(true);
    }
    setLoadingConnectButtonText(false);
}
Also used : Path(java.nio.file.Path) BasePanel(org.jabref.gui.BasePanel) SQLException(java.sql.SQLException) SaveDatabaseAction(org.jabref.gui.exporter.SaveDatabaseAction) InvalidDBMSConnectionPropertiesException(org.jabref.shared.exception.InvalidDBMSConnectionPropertiesException) DatabaseNotSupportedException(org.jabref.shared.exception.DatabaseNotSupportedException)

Example 28 with BasePanel

use of org.jabref.gui.BasePanel in project jabref by JabRef.

the class SharedDatabaseUIManager method listen.

@Subscribe
public void listen(SharedEntryNotPresentEvent event) {
    BasePanel panel = jabRefFrame.getCurrentBasePanel();
    EntryEditor entryEditor = panel.getCurrentEditor();
    panel.getUndoManager().addEdit(new UndoableRemoveEntry(panel.getDatabase(), event.getBibEntry(), panel));
    if (Objects.nonNull(entryEditor) && (entryEditor.getEntry() == event.getBibEntry())) {
        JOptionPane.showMessageDialog(jabRefFrame, Localization.lang("The BibEntry you currently work on has been deleted on the shared side.") + "\n" + Localization.lang("You can restore the entry using the \"Undo\" operation."), Localization.lang("Shared entry is no longer present"), JOptionPane.INFORMATION_MESSAGE);
        SwingUtilities.invokeLater(() -> panel.hideBottomComponent());
    }
}
Also used : EntryEditor(org.jabref.gui.entryeditor.EntryEditor) BasePanel(org.jabref.gui.BasePanel) UndoableRemoveEntry(org.jabref.gui.undo.UndoableRemoveEntry) Subscribe(com.google.common.eventbus.Subscribe)

Example 29 with BasePanel

use of org.jabref.gui.BasePanel in project jabref by JabRef.

the class GlobalSearchBar method endSearch.

public void endSearch() {
    BasePanel currentBasePanel = frame.getCurrentBasePanel();
    if (currentBasePanel != null) {
        clearSearch(currentBasePanel);
        MainTable mainTable = frame.getCurrentBasePanel().getMainTable();
        Globals.getFocusListener().setFocused(mainTable);
        mainTable.requestFocus();
        SwingUtilities.invokeLater(() -> mainTable.ensureVisible(mainTable.getSelectedRow()));
    }
}
Also used : BasePanel(org.jabref.gui.BasePanel) MainTable(org.jabref.gui.maintable.MainTable)

Example 30 with BasePanel

use of org.jabref.gui.BasePanel in project jabref by JabRef.

the class GlobalSearchBar method performSearch.

public void performSearch() {
    BasePanel currentBasePanel = frame.getCurrentBasePanel();
    if (currentBasePanel == null) {
        return;
    }
    if (searchWorker != null) {
        searchWorker.cancel(true);
    }
    // An empty search field should cause the search to be cleared.
    if (searchField.getText().isEmpty()) {
        clearSearch(currentBasePanel);
        return;
    }
    SearchQuery searchQuery = getSearchQuery();
    if (!searchQuery.isValid()) {
        informUserAboutInvalidSearchQuery();
        return;
    }
    searchWorker = new SearchWorker(currentBasePanel, searchQuery, searchDisplayMode);
    searchWorker.execute();
}
Also used : SearchQuery(org.jabref.logic.search.SearchQuery) BasePanel(org.jabref.gui.BasePanel)

Aggregations

BasePanel (org.jabref.gui.BasePanel)31 BibEntry (org.jabref.model.entry.BibEntry)14 Path (java.nio.file.Path)4 NamedCompound (org.jabref.gui.undo.NamedCompound)4 ArrayList (java.util.ArrayList)3 Collection (java.util.Collection)3 JabRefFrame (org.jabref.gui.JabRefFrame)3 IOException (java.io.IOException)2 SQLException (java.sql.SQLException)2 List (java.util.List)2 Map (java.util.Map)2 TimeUnit (java.util.concurrent.TimeUnit)2 BorderFactory (javax.swing.BorderFactory)2 JFrame (javax.swing.JFrame)2 JList (javax.swing.JList)2 JOptionPane (javax.swing.JOptionPane)2 ListSelectionModel (javax.swing.ListSelectionModel)2 ComponentFinder (org.assertj.swing.core.ComponentFinder)2 FailOnThreadViolationRepaintManager (org.assertj.swing.edt.FailOnThreadViolationRepaintManager)2 WindowFinder (org.assertj.swing.finder.WindowFinder)2