Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open last connected shared DBs at startup preference #9843

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -1087,8 +1087,12 @@ public void addParserResult(ParserResult parserResult, boolean focusPanel) {
// Add the entries to the open tab.
LibraryTab libraryTab = getCurrentLibraryTab();
if (libraryTab == null) {
if (parserResult.getContext().getLocation() == DatabaseLocation.SHARED) {
addTab(parserResult.getContext(), focusPanel);
} else {
// There is no open tab to add to, so we create a new tab:
addTab(parserResult.getDatabaseContext(), focusPanel);
}
} else {
addImportedEntries(libraryTab, parserResult);
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/jabref/gui/LibraryTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ public void onDatabaseLoadingStarted() {
}

public void onDatabaseLoadingSucceed(ParserResult result) {
BibDatabaseContext context = result.getDatabaseContext();
// BibDatabaseContext context = result.getDatabaseContext();
BibDatabaseContext context = result.getContext();
OpenDatabaseAction.performPostOpenActions(this, result);

feedData(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.jabref.gui.preferences.network.NetworkTab;
import org.jabref.gui.preferences.preview.PreviewTab;
import org.jabref.gui.preferences.protectedterms.ProtectedTermsTab;
import org.jabref.gui.preferences.shareddatabase.SharedDatabaseTab;
import org.jabref.gui.preferences.table.TableTab;
import org.jabref.gui.preferences.xmp.XmpPrivacyTab;
import org.jabref.gui.util.FileDialogConfiguration;
Expand Down Expand Up @@ -82,7 +83,8 @@ public PreferencesDialogViewModel(DialogService dialogService, PreferencesServic
new CustomEntryTypesTab(),
new XmpPrivacyTab(),
new NetworkTab(),
new AppearanceTab()
new AppearanceTab(),
new SharedDatabaseTab()
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>

<fx:root maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" spacing="10.0" type="VBox" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.jabref.gui.preferences.shareddatabase.SharedDatabaseTab">
<Label styleClass="titleHeader" text="%Shared Database" />
<HBox alignment="CENTER_LEFT" spacing="10.0" />

<Label styleClass="sectionHeader" text="%Loading" />

<CheckBox fx:id="connectLastStartup" text="%Open last shared database connections at startup" />

<HBox alignment="CENTER_LEFT" spacing="10.0" />

<HBox alignment="CENTER_LEFT" spacing="10.0" />
</fx:root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.jabref.gui.preferences.shareddatabase;

import javafx.fxml.FXML;
import javafx.scene.control.CheckBox;

import org.jabref.gui.preferences.AbstractPreferenceTabView;
import org.jabref.gui.preferences.PreferencesTab;
import org.jabref.logic.l10n.Localization;

import com.airhacks.afterburner.views.ViewLoader;

public class SharedDatabaseTab extends AbstractPreferenceTabView<SharedDatabaseTabViewModel> implements PreferencesTab {

@FXML private CheckBox connectLastStartup;

public SharedDatabaseTab() {
ViewLoader.view(this)
.root(this)
.load();
}

public void initialize() {
this.viewModel = new SharedDatabaseTabViewModel(preferencesService.getExternalApplicationsPreferences());
this.connectLastStartup.selectedProperty().bindBidirectional(viewModel.connectLastStartupProperty());
}

@Override
public String getTabName() {
return Localization.lang("Shared Database");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.jabref.gui.preferences.shareddatabase;

import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;

import org.jabref.gui.preferences.PreferenceTabViewModel;
import org.jabref.preferences.ExternalApplicationsPreferences;

public class SharedDatabaseTabViewModel implements PreferenceTabViewModel {

private final BooleanProperty connectLastStartupProperty = new SimpleBooleanProperty();
private final ExternalApplicationsPreferences externalApplicationsPreferences;

public SharedDatabaseTabViewModel(ExternalApplicationsPreferences externalApplicationsPreferences) {
this.externalApplicationsPreferences = externalApplicationsPreferences;
}

@Override
public void setValues() {
connectLastStartupProperty.setValue(externalApplicationsPreferences.shouldAutoConnectToLastSharedDatabase());
}

@Override
public void storeSettings() {
externalApplicationsPreferences.setAutoConnectToLastSharedDatabase(connectLastStartupProperty.getValue());
}

public BooleanProperty connectLastStartupProperty() {
return connectLastStartupProperty;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ public void openSharedDatabaseFromParserResult(ParserResult parserResult)
dbmsSynchronizer = bibDatabaseContext.getDBMSSynchronizer();
dbmsSynchronizer.openSharedDatabase(new DBMSConnection(dbmsConnectionProperties));
dbmsSynchronizer.registerListener(this);
parserResult.setDatabaseContext(bibDatabaseContext);
// parserResult.setDatabaseContext(bibDatabaseContext);
parserResult.setContext(bibDatabaseContext);
jabRefFrame.getDialogService().notify(Localization.lang("Connection to %0 server established.", dbmsConnectionProperties.getType().toString()));
}
}
9 changes: 9 additions & 0 deletions src/main/java/org/jabref/logic/importer/ParserResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class ParserResult {
private boolean invalid;
private boolean toOpenTab;
private boolean changedOnMigration = false;
private BibDatabaseContext context;

public ParserResult() {
this(Collections.emptyList());
Expand Down Expand Up @@ -146,6 +147,14 @@ public void setDatabaseContext(BibDatabaseContext bibDatabaseContext) {
file = bibDatabaseContext.getDatabasePath().orElse(null);
}

public BibDatabaseContext getContext() {
return this.context;
}

public void setContext(BibDatabaseContext context) {
this.context = context;
}

public boolean isEmpty() {
return !this.getDatabase().hasEntries() &&
this.getDatabase().hasNoStrings() &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ public class ExternalApplicationsPreferences {
private final StringProperty customTerminalCommand;
private final BooleanProperty useCustomFileBrowser;
private final StringProperty customFileBrowserCommand;
private final BooleanProperty shouldConnectLastSharedDatabase;

public ExternalApplicationsPreferences(String eMailSubject,
boolean shouldAutoOpenEmailAttachmentsFolder,
String citeCommand,
boolean useCustomTerminal,
String customTerminalCommand,
boolean useCustomFileBrowser,
String customFileBrowserCommand) {
String customFileBrowserCommand,
boolean shouldConnectLastSharedDatabase) {

this.eMailSubject = new SimpleStringProperty(eMailSubject);
this.shouldAutoOpenEmailAttachmentsFolder = new SimpleBooleanProperty(shouldAutoOpenEmailAttachmentsFolder);
Expand All @@ -30,6 +32,7 @@ public ExternalApplicationsPreferences(String eMailSubject,
this.customTerminalCommand = new SimpleStringProperty(customTerminalCommand);
this.useCustomFileBrowser = new SimpleBooleanProperty(useCustomFileBrowser);
this.customFileBrowserCommand = new SimpleStringProperty(customFileBrowserCommand);
this.shouldConnectLastSharedDatabase = new SimpleBooleanProperty(shouldConnectLastSharedDatabase);
}

public String getEmailSubject() {
Expand Down Expand Up @@ -115,4 +118,16 @@ public StringProperty customFileBrowserCommandProperty() {
public void setCustomFileBrowserCommand(String customFileBrowserCommand) {
this.customFileBrowserCommand.set(customFileBrowserCommand);
}

public boolean shouldAutoConnectToLastSharedDatabase() {
return shouldConnectLastSharedDatabase.get();
}

public BooleanProperty autoConnectToLastSharedDatabase() {
return shouldConnectLastSharedDatabase;
}

public void setAutoConnectToLastSharedDatabase(boolean shouldAutoConnectToLastSharedDatabase) {
this.shouldConnectLastSharedDatabase.set(shouldAutoConnectToLastSharedDatabase);
}
}
9 changes: 8 additions & 1 deletion src/main/java/org/jabref/preferences/JabRefPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ public class JabRefPreferences implements PreferencesService {
public static final String USE_DEFAULT_FILE_BROWSER_APPLICATION = "userDefaultFileBrowserApplication";
public static final String FILE_BROWSER_COMMAND = "fileBrowserCommand";
public static final String MAIN_FILE_DIRECTORY = "fileDirectory";
public static final String CONNECT_LAST_SHARED_DB = "connectLastSharedDB";

public static final String SEARCH_DISPLAY_MODE = "searchDisplayMode";
public static final String SEARCH_CASE_SENSITIVE = "caseSensitiveSearch";
Expand Down Expand Up @@ -482,6 +483,8 @@ private JabRefPreferences() {
// like the SearchDisplayMode will never be translated.
Localization.setLanguage(getLanguage());

defaults.put(CONNECT_LAST_SHARED_DB, Boolean.FALSE);

defaults.put(SEARCH_DISPLAY_MODE, SearchDisplayMode.FILTER.toString());
defaults.put(SEARCH_CASE_SENSITIVE, Boolean.FALSE);
defaults.put(SEARCH_REG_EXP, Boolean.FALSE);
Expand Down Expand Up @@ -1776,7 +1779,9 @@ public ExternalApplicationsPreferences getExternalApplicationsPreferences() {
!getBoolean(USE_DEFAULT_CONSOLE_APPLICATION), // mind the !
get(CONSOLE_COMMAND),
!getBoolean(USE_DEFAULT_FILE_BROWSER_APPLICATION), // mind the !
get(FILE_BROWSER_COMMAND));
get(FILE_BROWSER_COMMAND),
getBoolean(CONNECT_LAST_SHARED_DB)
);

EasyBind.listen(externalApplicationsPreferences.eMailSubjectProperty(),
(obs, oldValue, newValue) -> put(EMAIL_SUBJECT, newValue));
Expand All @@ -1792,6 +1797,8 @@ public ExternalApplicationsPreferences getExternalApplicationsPreferences() {
(obs, oldValue, newValue) -> putBoolean(USE_DEFAULT_FILE_BROWSER_APPLICATION, !newValue)); // mind the !
EasyBind.listen(externalApplicationsPreferences.customFileBrowserCommandProperty(),
(obs, oldValue, newValue) -> put(FILE_BROWSER_COMMAND, newValue));
EasyBind.listen(externalApplicationsPreferences.autoConnectToLastSharedDatabase(),
(obs, oldValue, newValue) -> putBoolean(CONNECT_LAST_SHARED_DB, newValue));

return externalApplicationsPreferences;
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_ar.properties
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,8 @@ Copy\ content=نسخ المحتوى
Move\ content=نقل المحتوى
Swap\ content=مبادلة المحتوى
Copy\ or\ move\ the\ content\ of\ one\ field\ to\ another=نسخ أو نقل محتوى حقل إلى آخر
Open\ last\ shared\ database\ connections\ at\ startup=Open last shared database connections at startup
Shared\ Database=Shared Database



Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_da.properties
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,8 @@ Find\ and\ replace=Søg og erstat

Always\ add\ letter\ (a,\ b,\ ...)\ to\ generated\ keys=Tilføj altid bogstav (a, b, ...) til genererede nøgler
Default\ pattern=Standardmønster
Open\ last\ shared\ database\ connections\ at\ startup=Open last shared database connections at startup
Shared\ Database=Shared Database



Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2527,3 +2527,5 @@ Use\ the\ field\ FJournal\ to\ store\ the\ full\ journal\ name\ for\ (un)abbrevi
Library\ to\ import\ into=Bibliothek für Import

Multiline=Mehrzeilig
Open\ last\ shared\ database\ connections\ at\ startup=Open last shared database connections at startup
Shared\ Database=Shared Database
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_el.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1652,6 +1652,8 @@ plain\ text=απλό κείμενο

Do\ you\ want\ to\ recover\ the\ library\ from\ the\ backup\ file?=Θέλετε να επαναφέρετε τη βιβλιοθήκη από το αντίγραφο ασφαλείας;
This\ could\ indicate\ that\ JabRef\ did\ not\ shut\ down\ cleanly\ last\ time\ the\ file\ was\ used.=Αυτό ίσως υποδεικνύει πως το JabRef δεν τερματίστηκε σωστά την τελευταία φορά που χρησιμοποιήθηκε το αρχείο.
Open\ last\ shared\ database\ connections\ at\ startup=Open last shared database connections at startup
Shared\ Database=Shared Database



2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2542,3 +2542,5 @@ Delete\ %0\ files=Delete %0 files
Delete\ %0\ files\ permanently\ from\ disk,\ or\ just\ remove\ the\ files\ from\ the\ entry?\ Pressing\ Delete\ will\ delete\ the\ files\ permanently\ from\ disk.=Delete %0 files permanently from disk, or just remove the files from the entry? Pressing Delete will delete the files permanently from disk.
Error\ accessing\ file\ '%0'.=Error accessing file '%0'.
This\ operation\ requires\ selected\ linked\ files.=This operation requires selected linked files.
Open\ last\ shared\ database\ connections\ at\ startup=Open last shared database connections at startup
Shared\ Database=Shared Database
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2447,6 +2447,8 @@ Review\ backup=Revisar respaldo
A\ backup\ file\ for\ '%0'\ was\ found\ at\ [%1]=Se encontró un archivo de respaldo para «%0» en [%1]
Do\ you\ want\ to\ recover\ the\ library\ from\ the\ backup\ file?=¿Quiere recuperar la biblioteca desde la copia de seguridad?
This\ could\ indicate\ that\ JabRef\ did\ not\ shut\ down\ cleanly\ last\ time\ the\ file\ was\ used.=Esto puede indicar que JabRef no se cerró correctamente la última vez que se usó ese archivo.
Open\ last\ shared\ database\ connections\ at\ startup=Open last shared database connections at startup
Shared\ Database=Shared Database



2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_fa.properties
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,8 @@ String\ constants=ثابت های رشته

Auto\ complete\ disabled.=تکمیل خودکار غیرفعال شد.
Auto\ complete\ enabled.=تکمیل خودکار غیرفعال شد.
Open\ last\ shared\ database\ connections\ at\ startup=Open last shared database connections at startup
Shared\ Database=Shared Database



Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/l10n/JabRef_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,7 @@ exportFormat=Format d'exportation
Output\ file\ missing=Fichier de sortie manquant
The\ output\ option\ depends\ on\ a\ valid\ input\ option.=L'option de sortie dépend d'une option d'entrée valide.
Linked\ file\ name\ conventions=Conventions pour les noms de fichiers liés
Filename\ format\ pattern=Modèle de format de nom de fichier
Filename\ format\ pattern=Modèle de format de nom de fichier
Additional\ parameters=Paramètres additionnels
Cite\ selected\ entries\ between\ parenthesis=Citer les entrées sélectionnées entre parenthèses
Cite\ selected\ entries\ with\ in-text\ citation=Citer les entrées sélectionnées comme incluse dans le texte
Expand Down Expand Up @@ -2525,3 +2525,5 @@ Use\ the\ field\ FJournal\ to\ store\ the\ full\ journal\ name\ for\ (un)abbrevi
Library\ to\ import\ into=Fichier à importer dans

Multiline=Multiligne
Open\ last\ shared\ database\ connections\ at\ startup=Open last shared database connections at startup
Shared\ Database=Shared Database
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_id.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1596,6 +1596,8 @@ plain\ text=teks biasa

Do\ you\ want\ to\ recover\ the\ library\ from\ the\ backup\ file?=Apakah Anda ingin memulihkan perpustakaan dari file cadangan?
This\ could\ indicate\ that\ JabRef\ did\ not\ shut\ down\ cleanly\ last\ time\ the\ file\ was\ used.=Ini bisa menunjukkan bahwa JabRef tidak dimatikan secara bersih terakhir kali file tersebut digunakan.
Open\ last\ shared\ database\ connections\ at\ startup=Open last shared database connections at startup
Shared\ Database=Shared Database



2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_it.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2525,3 +2525,5 @@ Use\ the\ field\ FJournal\ to\ store\ the\ full\ journal\ name\ for\ (un)abbrevi
Library\ to\ import\ into=Libreria in cui importare

Multiline=Multilinea
Open\ last\ shared\ database\ connections\ at\ startup=Open last shared database connections at startup
Shared\ Database=Shared Database
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_ja.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2442,6 +2442,8 @@ plain\ text=平文

Do\ you\ want\ to\ recover\ the\ library\ from\ the\ backup\ file?=ライブラリをバックアップファイルから復活させますか?
This\ could\ indicate\ that\ JabRef\ did\ not\ shut\ down\ cleanly\ last\ time\ the\ file\ was\ used.=これは,このファイルが最後に使用された際にJabRefが正常に終了しなかったことを意味している可能性があります.
Open\ last\ shared\ database\ connections\ at\ startup=Open last shared database connections at startup
Shared\ Database=Shared Database



4 changes: 3 additions & 1 deletion src/main/resources/l10n/JabRef_ko.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1852,7 +1852,7 @@ Add\ new\ String=문자열 추가
Must\ not\ be\ empty\!=비워둘 수 없습니다\!
Open\ Help\ page=도움말 열기
Add\ new\ field\ name=새 필드 이름 추가
Field\ name\:=필드 이름\:
Field\ name\:=필드 이름\:
Field\ name\ "%0"\ already\ exists=필드 이름 "%0"이 이미 존재합니다
No\ field\ name\ selected\!=필드 이름을 선택하지 않았습니다
Remove\ field\ name=필드 이름 제거
Expand Down Expand Up @@ -2321,6 +2321,8 @@ plain\ text=일반 텍스트

Do\ you\ want\ to\ recover\ the\ library\ from\ the\ backup\ file?=백업 파일에서 라이브러리를 복구하시겠습니까?
This\ could\ indicate\ that\ JabRef\ did\ not\ shut\ down\ cleanly\ last\ time\ the\ file\ was\ used.=이것은 JabRef가 파일이 마지막으로 사용되었을 때 완전히 종료되지 않았음을 나타낼 수 있습니다.
Open\ last\ shared\ database\ connections\ at\ startup=Open last shared database connections at startup
Shared\ Database=Shared Database



2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_nl.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1710,6 +1710,8 @@ plain\ text=onopgemaakte tekst

Do\ you\ want\ to\ recover\ the\ library\ from\ the\ backup\ file?=Wilt u de bibliotheek herstellen van het backup bestand?
This\ could\ indicate\ that\ JabRef\ did\ not\ shut\ down\ cleanly\ last\ time\ the\ file\ was\ used.=Dit kan erop duiden dat JabRef niet netjes werd afgesloten toen het bestand voor het laatst werd gebruikt.
Open\ last\ shared\ database\ connections\ at\ startup=Open last shared database connections at startup
Shared\ Database=Shared Database



2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_no.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,8 @@ Import\ BibTeX=Importer BibTeX

Always\ add\ letter\ (a,\ b,\ ...)\ to\ generated\ keys=Legg alltid til en bokstav (a, b, ...) til genererte nøkler
Default\ pattern=Standardmønster
Open\ last\ shared\ database\ connections\ at\ startup=Open last shared database connections at startup
Shared\ Database=Shared Database



Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_pl.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,8 @@ Reset=Reset


plain\ text=czysty tekst
Open\ last\ shared\ database\ connections\ at\ startup=Open last shared database connections at startup
Shared\ Database=Shared Database



Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_pt.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1315,6 +1315,8 @@ Default\ pattern=Ppadrão predefinido


plain\ text=texto sem formatação
Open\ last\ shared\ database\ connections\ at\ startup=Open last shared database connections at startup
Shared\ Database=Shared Database



Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_pt_BR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2525,3 +2525,5 @@ Use\ the\ field\ FJournal\ to\ store\ the\ full\ journal\ name\ for\ (un)abbrevi
Library\ to\ import\ into=Biblioteca para onde importar

Multiline=Multilinha
Open\ last\ shared\ database\ connections\ at\ startup=Open last shared database connections at startup
Shared\ Database=Shared Database
Loading