diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java
index 9179188d593..e789ffa10c8 100644
--- a/src/main/java/org/jabref/gui/JabRefFrame.java
+++ b/src/main/java/org/jabref/gui/JabRefFrame.java
@@ -123,9 +123,9 @@ public JabRefFrame(Stage mainStage) {
this.fileUpdateMonitor = Globals.getFileUpdateMonitor();
this.entryTypesManager = Globals.entryTypesManager;
this.globalSearchBar = new GlobalSearchBar(this, stateManager, prefs, undoManager, dialogService);
- this.pushToApplicationCommand = new PushToApplicationCommand(stateManager, dialogService, prefs);
- this.fileHistory = new FileHistoryMenu(prefs.getGuiPreferences().getFileHistory(), dialogService, getOpenDatabaseAction());
this.taskExecutor = Globals.TASK_EXECUTOR;
+ this.pushToApplicationCommand = new PushToApplicationCommand(stateManager, dialogService, prefs, taskExecutor);
+ this.fileHistory = new FileHistoryMenu(prefs.getGuiPreferences().getFileHistory(), dialogService, getOpenDatabaseAction());
this.setOnKeyTyped(key -> {
if (this.fileHistory.isShowing()) {
if (this.fileHistory.openFileByKey(key)) {
diff --git a/src/main/java/org/jabref/gui/preferences/external/ExternalTab.fxml b/src/main/java/org/jabref/gui/preferences/external/ExternalTab.fxml
index baed6346b4d..e96004acdcd 100644
--- a/src/main/java/org/jabref/gui/preferences/external/ExternalTab.fxml
+++ b/src/main/java/org/jabref/gui/preferences/external/ExternalTab.fxml
@@ -55,7 +55,7 @@
+ prefWidth="300.0" GridPane.columnIndex="1" GridPane.rowIndex="2"/>
diff --git a/src/main/java/org/jabref/gui/preferences/external/ExternalTab.java b/src/main/java/org/jabref/gui/preferences/external/ExternalTab.java
index 82368139cf9..df11e6f912c 100644
--- a/src/main/java/org/jabref/gui/preferences/external/ExternalTab.java
+++ b/src/main/java/org/jabref/gui/preferences/external/ExternalTab.java
@@ -23,6 +23,7 @@ public class ExternalTab extends AbstractPreferenceTabView
@FXML private CheckBox autoOpenAttachedFolders;
@FXML private ComboBox pushToApplicationCombo;
@FXML private TextField citeCommand;
+
@FXML private CheckBox useCustomTerminal;
@FXML private TextField customTerminalCommand;
@FXML private Button customTerminalBrowse;
diff --git a/src/main/java/org/jabref/gui/preferences/external/ExternalTabViewModel.java b/src/main/java/org/jabref/gui/preferences/external/ExternalTabViewModel.java
index 3700f93b5e4..59308f47c46 100644
--- a/src/main/java/org/jabref/gui/preferences/external/ExternalTabViewModel.java
+++ b/src/main/java/org/jabref/gui/preferences/external/ExternalTabViewModel.java
@@ -210,8 +210,6 @@ public StringProperty citeCommandProperty() {
return this.citeCommandProperty;
}
- // Open console
-
public BooleanProperty useCustomTerminalProperty() {
return this.useCustomTerminalProperty;
}
diff --git a/src/main/java/org/jabref/gui/push/AbstractPushToApplication.java b/src/main/java/org/jabref/gui/push/AbstractPushToApplication.java
index 5c3ceeac981..aa84c74d3e9 100644
--- a/src/main/java/org/jabref/gui/push/AbstractPushToApplication.java
+++ b/src/main/java/org/jabref/gui/push/AbstractPushToApplication.java
@@ -26,9 +26,11 @@
public abstract class AbstractPushToApplication implements PushToApplication {
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractPushToApplication.class);
+ private static final String CITE_KEY1 = "key1";
+ private static final String CITE_KEY2 = "key2";
protected boolean couldNotCall; // Set to true in case the command could not be executed, e.g., if the file is not found
- protected boolean couldNotConnect; // Set to true in case the tunnel to the program (if one is used) does not operate
+ protected boolean couldNotPush; // Set to true in case the tunnel to the program (if one is used) does not operate
protected boolean notDefined; // Set to true if the corresponding path is not defined in the preferences
protected String commandPath;
@@ -36,11 +38,36 @@ public abstract class AbstractPushToApplication implements PushToApplication {
protected final DialogService dialogService;
protected final PreferencesService preferencesService;
+ private String cachedCiteCommand;
+ private String cachedCitePrefix;
+ private String cachedCiteSuffix;
+ private String cachedCiteDelimiter;
+
public AbstractPushToApplication(DialogService dialogService, PreferencesService preferencesService) {
this.dialogService = dialogService;
this.preferencesService = preferencesService;
}
+ private void dissectCiteCommand() {
+ String preferencesCiteCommand = preferencesService.getExternalApplicationsPreferences().getCiteCommand();
+
+ if (preferencesCiteCommand != null && preferencesCiteCommand.equals(cachedCiteCommand)) {
+ return;
+ }
+
+ cachedCiteCommand = preferencesCiteCommand;
+
+ int indexKey1 = cachedCiteCommand.indexOf(CITE_KEY1);
+ int indexKey2 = cachedCiteCommand.indexOf(CITE_KEY2);
+ if (indexKey1 < 0 || indexKey2 < 0 || indexKey2 < (indexKey1 + CITE_KEY1.length())) {
+ return;
+ }
+
+ cachedCitePrefix = preferencesCiteCommand.substring(0, indexKey1);
+ cachedCiteDelimiter = preferencesCiteCommand.substring(preferencesCiteCommand.lastIndexOf(CITE_KEY1) + CITE_KEY1.length(), indexKey2);
+ cachedCiteSuffix = preferencesCiteCommand.substring(preferencesCiteCommand.lastIndexOf(CITE_KEY2) + CITE_KEY2.length());
+ }
+
@Override
public JabRefIcon getApplicationIcon() {
return IconTheme.JabRefIcons.APPLICATION_GENERIC;
@@ -58,7 +85,7 @@ public Action getAction() {
@Override
public void pushEntries(BibDatabaseContext database, List entries, String keyString) {
- couldNotConnect = false;
+ couldNotPush = false;
couldNotCall = false;
notDefined = false;
@@ -108,7 +135,7 @@ public void onOperationCompleted() {
dialogService.showErrorDialogAndWait(
Localization.lang("Error pushing entries"),
Localization.lang("Could not call executable") + " '" + commandPath + "'.");
- } else if (couldNotConnect) {
+ } else if (couldNotPush) {
dialogService.showErrorDialogAndWait(
Localization.lang("Error pushing entries"),
Localization.lang("Could not connect to %0", getDisplayName()) + ".");
@@ -142,8 +169,19 @@ protected String getCommandName() {
return null;
}
- protected String getCiteCommand() {
- return preferencesService.getExternalApplicationsPreferences().getCiteCommand();
+ protected String getCitePrefix() {
+ dissectCiteCommand();
+ return cachedCitePrefix;
+ }
+
+ public String getDelimiter() {
+ dissectCiteCommand();
+ return cachedCiteDelimiter;
+ }
+
+ protected String getCiteSuffix() {
+ dissectCiteCommand();
+ return cachedCiteSuffix;
}
@Override
diff --git a/src/main/java/org/jabref/gui/push/PushToApplication.java b/src/main/java/org/jabref/gui/push/PushToApplication.java
index 3b409717c2c..b7d5223e83d 100644
--- a/src/main/java/org/jabref/gui/push/PushToApplication.java
+++ b/src/main/java/org/jabref/gui/push/PushToApplication.java
@@ -41,4 +41,6 @@ public interface PushToApplication {
Action getAction();
PushToApplicationSettings getSettings(PushToApplication application, PushToApplicationPreferences pushToApplicationPreferences);
+
+ String getDelimiter();
}
diff --git a/src/main/java/org/jabref/gui/push/PushToApplicationCommand.java b/src/main/java/org/jabref/gui/push/PushToApplicationCommand.java
index 1c5f1ee5e10..21be03170ec 100644
--- a/src/main/java/org/jabref/gui/push/PushToApplicationCommand.java
+++ b/src/main/java/org/jabref/gui/push/PushToApplicationCommand.java
@@ -9,13 +9,13 @@
import javafx.scene.control.MenuItem;
import org.jabref.gui.DialogService;
-import org.jabref.gui.Globals;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.Action;
import org.jabref.gui.actions.ActionFactory;
import org.jabref.gui.actions.SimpleCommand;
import org.jabref.gui.util.BackgroundTask;
import org.jabref.gui.util.BindingsHelper;
+import org.jabref.gui.util.TaskExecutor;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
@@ -41,13 +41,15 @@ public class PushToApplicationCommand extends SimpleCommand {
private final PreferencesService preferencesService;
private final List