Skip to content

Commit a0e4c37

Browse files
committed
Merge remote-tracking branch 'upstream/master' into fix4817
* upstream/master: Fix right clicking on any entry and selecting "Open folder" results in the NullPointer exception (#4797) Bump fontbox from 2.0.14 to 2.0.15 (#4882) Bump pdfbox from 2.0.14 to 2.0.15 (#4881) Bump xmpbox from 2.0.14 to 2.0.15 (#4883) Bump mockito-core from 2.26.0 to 2.27.0 (#4879) Bump java-string-similarity from 1.1.0 to 1.2.1 (#4878) Fix JabRef dying silently without enough inotify instances (#4875) #4795 disable menu item if database not connected (#4828)
2 parents d55afba + 3d770b8 commit a0e4c37

13 files changed

+175
-136
lines changed

.mailmap

+2-1
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,5 @@ Johannes Manner <johannes.manner@web.de>
142142
Dominik Traczyk <dominik646@gmail.com>
143143
Cerrianne Santos <cerrianne.santos@gmail.com>
144144
Stefan Scheffel <st155160@stud.uni-stuttgart.de>
145-
Stefan Gerzmann <steppery@gmx.de>
145+
Stefan Gerzmann <steppery@gmx.de>
146+
Deepak Kumar <deepakkumar24196@gmail.com>

CHANGELOG.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,12 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
6161
- We changed the title of Group Dialog to "Add subgroup" from "Edit group" when we select Add subgroup option.
6262
- We enable import button only if entries are selected. [#4755](https://github.com/JabRef/jabref/issues/4755)
6363
- We made modifications to improve contrast of UI elements. [#4583](https://github.com/JabRef/jabref/issues/4583)
64+
- We added an option in the settings to set the default action in JabRef when right clicking on any entry in any database and selecting "Open folder". [#4763](https://github.com/JabRef/jabref/issues/4763)
6465
- The Medline fetcher now normalizes the author names according to the BibTeX-Standard [#4345](https://github.com/JabRef/jabref/issues/4345)
6566

6667

6768
### Fixed
69+
- We fixed an issue where JabRef died silently for the user without enough inotify instances [#4874](https://github.com/JabRef/jabref/issues/4847)
6870
- We fixed an issue where corresponding groups are sometimes not highlighted when clicking on entries [#3112](https://github.com/JabRef/jabref/issues/3112)
6971
- We fixed an issue where custom exports could not be selected in the 'Export (selected) entries' dialog [#4013](https://github.com/JabRef/jabref/issues/4013)
7072
- Italic text is now rendered correctly. https://github.com/JabRef/jabref/issues/3356
@@ -104,13 +106,14 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
104106
- We fixed an issue where only one PDF file could be imported [#4422](https://github.com/JabRef/jabref/issues/4422)
105107
- We fixed an issue where "Move to group" would always move the first entry in the library and not the selected [#4414](https://github.com/JabRef/jabref/issues/4414)
106108
- We fixed an issue where an older dialog appears when downloading full texts from the quality menu. [#4489](https://github.com/JabRef/jabref/issues/4489)
109+
- We fixed an issue where right clicking on any entry in any database and selecting "Open folder" results in the NullPointer exception. [#4763](https://github.com/JabRef/jabref/issues/4763)
110+
- We fixed an issue where option 'open terminal here' with custom command was passing wrong argument. [#4802](https://github.com/JabRef/jabref/issues/4802)
107111
- We fixed an issue where ranking an entry would generate an IllegalArgumentException. [#4754](https://github.com/JabRef/jabref/issues/4754)
108112
- We fixed an issue where special characters where removed from non label key generation pattern parts [#4767](https://github.com/JabRef/jabref/issues/4767)
109113
- We fixed an issue where the RIS import would overwite the article date with the value of the acessed date [#4816](https://github.com/JabRef/jabref/issues/4816)
110114

111115

112116

113-
114117
### Removed
115118
- The feature to "mark entries" was removed and merged with the groups functionality. For migration, a group is created for every value of the `__markedentry` field and the entry is added to this group.
116119
- The number column was removed.

build.gradle

+5-5
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ dependencies {
9595
compile 'com.jgoodies:jgoodies-common:1.8.1'
9696
compile 'com.jgoodies:jgoodies-forms:1.9.0'
9797

98-
compile 'org.apache.pdfbox:pdfbox:2.0.14'
99-
compile 'org.apache.pdfbox:fontbox:2.0.14'
100-
compile 'org.apache.pdfbox:xmpbox:2.0.14'
98+
compile 'org.apache.pdfbox:pdfbox:2.0.15'
99+
compile 'org.apache.pdfbox:fontbox:2.0.15'
100+
compile 'org.apache.pdfbox:xmpbox:2.0.15'
101101

102102
compile group: 'org.apache.tika', name: 'tika-core', version: '1.20'
103103

@@ -112,7 +112,7 @@ dependencies {
112112
compile "org.libreoffice:unoil:6.2.2"
113113

114114
compile 'io.github.java-diff-utils:java-diff-utils:4.0'
115-
compile 'info.debatty:java-string-similarity:1.1.0'
115+
compile 'info.debatty:java-string-similarity:1.2.1'
116116

117117
antlr3 'org.antlr:antlr:3.5.2'
118118
compile 'org.antlr:antlr-runtime:3.5.2'
@@ -167,7 +167,7 @@ dependencies {
167167

168168
testRuntime 'org.apache.logging.log4j:log4j-core:2.11.1'
169169
testRuntime 'org.apache.logging.log4j:log4j-jul:2.11.2'
170-
testCompile 'org.mockito:mockito-core:2.26.0'
170+
testCompile 'org.mockito:mockito-core:2.27.0'
171171
testCompile 'com.github.tomakehurst:wiremock:2.22.0'
172172
testCompile 'org.reflections:reflections:0.9.11'
173173
testCompile 'org.xmlunit:xmlunit-core:2.6.2'

src/main/java/org/jabref/gui/JabRefFrame.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
import org.jabref.gui.metadata.BibtexStringEditorAction;
101101
import org.jabref.gui.metadata.PreambleEditor;
102102
import org.jabref.gui.protectedterms.ManageProtectedTermsAction;
103-
import org.jabref.gui.push.PushToApplicationButton;
103+
import org.jabref.gui.push.PushToApplicationAction;
104104
import org.jabref.gui.push.PushToApplications;
105105
import org.jabref.gui.search.GlobalSearchBar;
106106
import org.jabref.gui.specialfields.SpecialFieldMenuItemFactory;
@@ -559,7 +559,8 @@ private Node createToolbar() {
559559
leftSide.setMinWidth(100);
560560
leftSide.prefWidthProperty().bind(sidePane.widthProperty());
561561
leftSide.maxWidthProperty().bind(sidePane.widthProperty());
562-
PushToApplicationButton pushToExternal = new PushToApplicationButton(this, pushApplications.getApplications());
562+
563+
PushToApplicationAction pushToApplicationAction = new PushToApplicationAction(this, Globals.stateManager);
563564
HBox rightSide = new HBox(
564565
factory.createIconButton(StandardActions.NEW_ARTICLE, new NewEntryAction(this, BiblatexEntryTypes.ARTICLE, dialogService, Globals.prefs)),
565566
factory.createIconButton(StandardActions.DELETE_ENTRY, new OldDatabaseCommandWrapper(Actions.DELETE, this, Globals.stateManager)),
@@ -570,7 +571,7 @@ private Node createToolbar() {
570571
factory.createIconButton(StandardActions.COPY, new OldDatabaseCommandWrapper(Actions.COPY, this, Globals.stateManager)),
571572
factory.createIconButton(StandardActions.PASTE, new OldDatabaseCommandWrapper(Actions.PASTE, this, Globals.stateManager)),
572573
new Separator(Orientation.VERTICAL),
573-
factory.createIconButton(pushToExternal.getMenuAction(), pushToExternal),
574+
factory.createIconButton(pushToApplicationAction.getActionInformation(), pushToApplicationAction),
574575
factory.createIconButton(StandardActions.GENERATE_CITE_KEYS, new OldDatabaseCommandWrapper(Actions.MAKE_KEY, this, Globals.stateManager)),
575576
factory.createIconButton(StandardActions.CLEANUP_ENTRIES, new OldDatabaseCommandWrapper(Actions.CLEANUP, this, Globals.stateManager)),
576577
new Separator(Orientation.VERTICAL),
@@ -798,7 +799,7 @@ private MenuBar createMenu() {
798799
factory.createMenuItem(StandardActions.SET_FILE_LINKS, new AutoLinkFilesAction(this, prefs))
799800
);
800801

801-
PushToApplicationButton pushToExternal = new PushToApplicationButton(this, pushApplications.getApplications());
802+
final PushToApplicationAction pushToApplicationAction = new PushToApplicationAction(this, Globals.stateManager);
802803
tools.getItems().addAll(
803804
factory.createMenuItem(StandardActions.NEW_SUB_LIBRARY_FROM_AUX, new NewSubLibraryAction(this)),
804805
factory.createMenuItem(StandardActions.FIND_UNLINKED_FILES, new FindUnlinkedFilesAction(this)),
@@ -815,7 +816,7 @@ private MenuBar createMenu() {
815816
factory.createMenuItem(StandardActions.GENERATE_CITE_KEYS, new OldDatabaseCommandWrapper(Actions.MAKE_KEY, this, Globals.stateManager)),
816817
factory.createMenuItem(StandardActions.REPLACE_ALL, new OldDatabaseCommandWrapper(Actions.REPLACE_ALL, this, Globals.stateManager)),
817818
factory.createMenuItem(StandardActions.SEND_AS_EMAIL, new OldDatabaseCommandWrapper(Actions.SEND_AS_EMAIL, this, Globals.stateManager)),
818-
factory.createMenuItem(pushToExternal.getMenuAction(), pushToExternal),
819+
factory.createMenuItem(pushToApplicationAction.getActionInformation(), pushToApplicationAction),
819820

820821
factory.createSubMenu(StandardActions.ABBREVIATE,
821822
factory.createMenuItem(StandardActions.ABBREVIATE_ISO, new OldDatabaseCommandWrapper(Actions.ABBREVIATE_ISO, this, Globals.stateManager)),

src/main/java/org/jabref/gui/actions/OldDatabaseCommandWrapper.java

+3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414

1515
/**
1616
* A command that is only executable if a database is open.
17+
* Deprecated use instead
18+
* @see org.jabref.gui.actions.SimpleCommand
1719
*/
20+
@Deprecated
1821
public class OldDatabaseCommandWrapper extends CommandBase {
1922

2023
private static final Logger LOGGER = LoggerFactory.getLogger(OldDatabaseCommandWrapper.class);

src/main/java/org/jabref/gui/desktop/JabRefDesktop.java

+31-8
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,33 @@ private static void openExternalFilePlatformIndependent(Optional<ExternalFileTyp
166166
* @throws IOException
167167
*/
168168
public static void openFolderAndSelectFile(Path fileLink) throws IOException {
169-
NATIVE_DESKTOP.openFolderAndSelectFile(fileLink);
169+
if (fileLink == null) {
170+
return;
171+
}
172+
boolean usingDefault = Globals.prefs.getBoolean(JabRefPreferences.USE_DEFAULT_FILE_BROWSER_APPLICATION);
173+
174+
if (usingDefault) {
175+
NATIVE_DESKTOP.openFolderAndSelectFile(fileLink);
176+
} else {
177+
String absolutePath = fileLink.toAbsolutePath().getParent().toString();
178+
String command = Globals.prefs.get(JabRefPreferences.FILE_BROWSER_COMMAND);
179+
if (!command.isEmpty()) {
180+
command = command.replaceAll("\\s+", " "); // normalize white spaces
181+
182+
// replace the placeholder if used
183+
command = command.replace("%DIR", absolutePath);
184+
String[] subcommands = command.split(" ");
185+
186+
LOGGER.info("Executing command \"" + command + "\"...");
187+
188+
try {
189+
new ProcessBuilder(subcommands).start();
190+
} catch (IOException exception) {
191+
LOGGER.error("Open File Browser", exception);
192+
JabRefGUI.getMainFrame().getDialogService().notify(Localization.lang("Error occured while executing the command \"%0\".", command));
193+
}
194+
}
195+
}
170196
}
171197

172198
/**
@@ -228,22 +254,19 @@ public static void openConsole(File file) throws IOException {
228254

229255
if (!command.isEmpty()) {
230256
command = command.replaceAll("\\s+", " "); // normalize white spaces
231-
String[] subcommands = command.split(" ");
257+
command = command.replace("%DIR", absolutePath); // replace the placeholder if used
232258

233-
// replace the placeholder if used
234-
String commandLoggingText = command.replace("%DIR", absolutePath);
259+
String[] subcommands = command.split(" ");
235260

261+
LOGGER.info("Executing command \"" + command + "\"...");
236262
JabRefGUI.getMainFrame().getDialogService().notify(Localization.lang("Executing command \"%0\"...", commandLoggingText));
237-
LOGGER.info("Executing command \"" + commandLoggingText + "\"...");
238263

239264
try {
240265
new ProcessBuilder(subcommands).start();
241266
} catch (IOException exception) {
242267
LOGGER.error("Open console", exception);
243268

244-
JabRefGUI.getMainFrame().getDialogService().showErrorDialogAndWait(
245-
Localization.lang("Open console") + " - " + Localization.lang("Error",
246-
Localization.lang("Error occured while executing the command \"%0\".", commandLoggingText)));
269+
JabRefGUI.getMainFrame().getDialogService().notify(Localization.lang("Error occured while executing the command \"%0\".", command));
247270
}
248271
}
249272
}

src/main/java/org/jabref/gui/desktop/os/Linux.java

+9-10
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,18 @@ public void openFileWithApplication(String filePath, String application) throws
5151

5252
@Override
5353
public void openFolderAndSelectFile(Path filePath) throws IOException {
54-
String desktopSession = System.getenv("DESKTOP_SESSION").toLowerCase(Locale.ROOT);
54+
String desktopSession = System.getenv("DESKTOP_SESSION");
5555

56-
String cmd;
56+
String cmd = "xdg-open " + filePath.toAbsolutePath().getParent().toString(); //default command
5757

58-
if (desktopSession.contains("gnome")) {
59-
cmd = "nautilus" + filePath.toString().replace(" ", "\\ ");
60-
} else if (desktopSession.contains("kde")) {
61-
cmd = "dolphin --select " + filePath.toString().replace(" ", "\\ ");
62-
} else {
63-
cmd = "xdg-open " + filePath.toAbsolutePath().getParent().toString();
58+
if (desktopSession != null) {
59+
desktopSession = desktopSession.toLowerCase(Locale.ROOT);
60+
if (desktopSession.contains("gnome")) {
61+
cmd = "nautilus" + filePath.toString().replace(" ", "\\ ");
62+
} else if (desktopSession.contains("kde")) {
63+
cmd = "dolphin --select " + filePath.toString().replace(" ", "\\ ");
64+
}
6465
}
65-
6666
Runtime.getRuntime().exec(cmd);
6767
}
6868

@@ -73,7 +73,6 @@ public void openConsole(String absolutePath) throws IOException {
7373
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
7474

7575
String emulatorName = reader.readLine();
76-
7776
if (emulatorName != null) {
7877
emulatorName = emulatorName.substring(emulatorName.lastIndexOf(File.separator) + 1);
7978

src/main/java/org/jabref/gui/preferences/ExternalTab.java

+48
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.jabref.gui.util.FileDialogConfiguration;
2121
import org.jabref.logic.l10n.Localization;
2222
import org.jabref.logic.util.OS;
23+
import org.jabref.model.strings.StringUtil;
2324
import org.jabref.preferences.JabRefPreferences;
2425

2526
class ExternalTab implements PrefsTab {
@@ -38,6 +39,12 @@ class ExternalTab implements PrefsTab {
3839
private final RadioButton sumatraReader;
3940
private final TextField adobeAcrobatReaderPath;
4041
private final TextField sumatraReaderPath;
42+
43+
private final RadioButton defaultFileBrowser;
44+
private final RadioButton executeFileBrowser;
45+
private final TextField fileBrowserCommand;
46+
private final Button fileBrowserButton;
47+
4148
private final GridPane builder = new GridPane();
4249
private final DialogService dialogService;
4350
private final FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder().build();
@@ -59,11 +66,20 @@ public ExternalTab(JabRefFrame frame, PreferencesDialog prefsDiag, JabRefPrefere
5966
sumatraReaderPath = new TextField();
6067
Button browseSumatraReader = new Button(Localization.lang("Browse"));
6168

69+
defaultFileBrowser = new RadioButton(Localization.lang("Use default file browser"));
70+
executeFileBrowser = new RadioButton(Localization.lang("Execute Command"));
71+
fileBrowserCommand = new TextField();
72+
fileBrowserButton = new Button(Localization.lang("Browser"));
73+
6274
Label commandDescription = new Label(Localization.lang("Note: Use the placeholder %0 for the location of the opened library file.", "%DIR"));
6375
defaultConsole.setOnAction(e -> updateExecuteConsoleButtonAndFieldEnabledState());
6476
executeConsole.setOnAction(e -> updateExecuteConsoleButtonAndFieldEnabledState());
6577
browseButton.setOnAction(e -> showConsoleChooser());
6678

79+
fileBrowserButton.disableProperty().bind(executeFileBrowser.selectedProperty().not());
80+
fileBrowserCommand.disableProperty().bind(executeFileBrowser.selectedProperty().not());
81+
fileBrowserButton.setOnAction(e -> showFileBrowserCommandChooser());
82+
6783
browseAdobeAcrobatReader.setOnAction(e -> showAdobeChooser());
6884

6985
GridPane consoleOptionPanel = new GridPane();
@@ -83,6 +99,17 @@ public ExternalTab(JabRefFrame frame, PreferencesDialog prefsDiag, JabRefPrefere
8399
adobeAcrobatReader.setToggleGroup(pdfReaderGroup);
84100
pdfOptionPanel.add(browseAdobeAcrobatReader, 3, 1);
85101

102+
Label fileBrowserCommandDescription = new Label(Localization.lang("Note: Use the placeholder %0 for the location of the opened library file.", "%DIR"));
103+
GridPane fileBrowserOptionPanel = new GridPane();
104+
final ToggleGroup fileBrowserGroup = new ToggleGroup();
105+
defaultFileBrowser.setToggleGroup(fileBrowserGroup);
106+
executeFileBrowser.setToggleGroup(fileBrowserGroup);
107+
fileBrowserOptionPanel.add(defaultFileBrowser, 1, 1);
108+
fileBrowserOptionPanel.add(executeFileBrowser, 1, 2);
109+
fileBrowserOptionPanel.add(fileBrowserCommand, 2, 2);
110+
fileBrowserOptionPanel.add(fileBrowserButton, 3, 2);
111+
fileBrowserOptionPanel.add(fileBrowserCommandDescription, 2, 3);
112+
86113
if (OS.WINDOWS) {
87114
browseSumatraReader.setOnAction(e -> showSumatraChooser());
88115
pdfOptionPanel.add(sumatraReader, 1, 2);
@@ -133,6 +160,12 @@ public ExternalTab(JabRefFrame frame, PreferencesDialog prefsDiag, JabRefPrefere
133160

134161
builder.add(pdfOptionPanel, 1, 13);
135162

163+
Label openFileBrowser = new Label(Localization.lang("Open File Browser"));
164+
openFileBrowser.getStyleClass().add("sectionHeader");
165+
builder.add(openFileBrowser, 1, 14);
166+
167+
builder.add(fileBrowserOptionPanel, 1, 15);
168+
136169
}
137170

138171
@Override
@@ -165,6 +198,10 @@ public void setValues() {
165198

166199
consoleCommand.setText(Globals.prefs.get(JabRefPreferences.CONSOLE_COMMAND));
167200

201+
defaultFileBrowser.setSelected(Globals.prefs.getBoolean(JabRefPreferences.USE_DEFAULT_FILE_BROWSER_APPLICATION));
202+
executeFileBrowser.setSelected(!Globals.prefs.getBoolean(JabRefPreferences.USE_DEFAULT_FILE_BROWSER_APPLICATION));
203+
fileBrowserCommand.setText(Globals.prefs.get(JabRefPreferences.FILE_BROWSER_COMMAND));
204+
168205
adobeAcrobatReaderPath.setText(Globals.prefs.get(JabRefPreferences.ADOBE_ACROBAT_COMMAND));
169206
if (OS.WINDOWS) {
170207
sumatraReaderPath.setText(Globals.prefs.get(JabRefPreferences.SUMATRA_PDF_COMMAND));
@@ -187,6 +224,13 @@ public void storeSettings() {
187224
prefs.putBoolean(JabRefPreferences.USE_DEFAULT_CONSOLE_APPLICATION, defaultConsole.isSelected());
188225
prefs.put(JabRefPreferences.CONSOLE_COMMAND, consoleCommand.getText());
189226
prefs.put(JabRefPreferences.ADOBE_ACROBAT_COMMAND, adobeAcrobatReaderPath.getText());
227+
228+
prefs.putBoolean(JabRefPreferences.USE_DEFAULT_FILE_BROWSER_APPLICATION, defaultFileBrowser.isSelected());
229+
if (StringUtil.isNotBlank(fileBrowserCommand.getText())) {
230+
prefs.put(JabRefPreferences.FILE_BROWSER_COMMAND, fileBrowserCommand.getText());
231+
} else {
232+
prefs.putBoolean(JabRefPreferences.USE_DEFAULT_FILE_BROWSER_APPLICATION, true); //default if no command specified
233+
}
190234
if (OS.WINDOWS) {
191235
prefs.put(JabRefPreferences.SUMATRA_PDF_COMMAND, sumatraReaderPath.getText());
192236
}
@@ -220,6 +264,10 @@ private void showSumatraChooser() {
220264
dialogService.showFileOpenDialog(fileDialogConfiguration).ifPresent(file -> sumatraReaderPath.setText(file.toAbsolutePath().toString()));
221265
}
222266

267+
private void showFileBrowserCommandChooser() {
268+
dialogService.showFileOpenDialog(fileDialogConfiguration).ifPresent(file -> fileBrowserCommand.setText(file.toAbsolutePath().toString()));
269+
}
270+
223271
private void readerSelected() {
224272
if (adobeAcrobatReader.isSelected()) {
225273
prefs.put(JabRefPreferences.USE_PDF_READER, adobeAcrobatReaderPath.getText());

0 commit comments

Comments
 (0)