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;
}
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);
}
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());
}
}
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()));
}
}
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();
}
Aggregations