Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into fix4817
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
Siedlerchr committed Apr 13, 2019
2 parents d55afba + 3d770b8 commit a0e4c37
Show file tree
Hide file tree
Showing 13 changed files with 175 additions and 136 deletions.
3 changes: 2 additions & 1 deletion .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,5 @@ Johannes Manner <johannes.manner@web.de>
Dominik Traczyk <dominik646@gmail.com>
Cerrianne Santos <cerrianne.santos@gmail.com>
Stefan Scheffel <st155160@stud.uni-stuttgart.de>
Stefan Gerzmann <steppery@gmx.de>
Stefan Gerzmann <steppery@gmx.de>
Deepak Kumar <deepakkumar24196@gmail.com>
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We changed the title of Group Dialog to "Add subgroup" from "Edit group" when we select Add subgroup option.
- We enable import button only if entries are selected. [#4755](https://github.com/JabRef/jabref/issues/4755)
- We made modifications to improve contrast of UI elements. [#4583](https://github.com/JabRef/jabref/issues/4583)
- 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)
- The Medline fetcher now normalizes the author names according to the BibTeX-Standard [#4345](https://github.com/JabRef/jabref/issues/4345)


### Fixed
- We fixed an issue where JabRef died silently for the user without enough inotify instances [#4874](https://github.com/JabRef/jabref/issues/4847)
- We fixed an issue where corresponding groups are sometimes not highlighted when clicking on entries [#3112](https://github.com/JabRef/jabref/issues/3112)
- 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)
- Italic text is now rendered correctly. https://github.com/JabRef/jabref/issues/3356
Expand Down Expand Up @@ -104,13 +106,14 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We fixed an issue where only one PDF file could be imported [#4422](https://github.com/JabRef/jabref/issues/4422)
- 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)
- 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)
- 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)
- We fixed an issue where option 'open terminal here' with custom command was passing wrong argument. [#4802](https://github.com/JabRef/jabref/issues/4802)
- We fixed an issue where ranking an entry would generate an IllegalArgumentException. [#4754](https://github.com/JabRef/jabref/issues/4754)
- We fixed an issue where special characters where removed from non label key generation pattern parts [#4767](https://github.com/JabRef/jabref/issues/4767)
- 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)




### Removed
- 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.
- The number column was removed.
Expand Down
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ dependencies {
compile 'com.jgoodies:jgoodies-common:1.8.1'
compile 'com.jgoodies:jgoodies-forms:1.9.0'

compile 'org.apache.pdfbox:pdfbox:2.0.14'
compile 'org.apache.pdfbox:fontbox:2.0.14'
compile 'org.apache.pdfbox:xmpbox:2.0.14'
compile 'org.apache.pdfbox:pdfbox:2.0.15'
compile 'org.apache.pdfbox:fontbox:2.0.15'
compile 'org.apache.pdfbox:xmpbox:2.0.15'

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

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

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

antlr3 'org.antlr:antlr:3.5.2'
compile 'org.antlr:antlr-runtime:3.5.2'
Expand Down Expand Up @@ -167,7 +167,7 @@ dependencies {

testRuntime 'org.apache.logging.log4j:log4j-core:2.11.1'
testRuntime 'org.apache.logging.log4j:log4j-jul:2.11.2'
testCompile 'org.mockito:mockito-core:2.26.0'
testCompile 'org.mockito:mockito-core:2.27.0'
testCompile 'com.github.tomakehurst:wiremock:2.22.0'
testCompile 'org.reflections:reflections:0.9.11'
testCompile 'org.xmlunit:xmlunit-core:2.6.2'
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
import org.jabref.gui.metadata.BibtexStringEditorAction;
import org.jabref.gui.metadata.PreambleEditor;
import org.jabref.gui.protectedterms.ManageProtectedTermsAction;
import org.jabref.gui.push.PushToApplicationButton;
import org.jabref.gui.push.PushToApplicationAction;
import org.jabref.gui.push.PushToApplications;
import org.jabref.gui.search.GlobalSearchBar;
import org.jabref.gui.specialfields.SpecialFieldMenuItemFactory;
Expand Down Expand Up @@ -559,7 +559,8 @@ private Node createToolbar() {
leftSide.setMinWidth(100);
leftSide.prefWidthProperty().bind(sidePane.widthProperty());
leftSide.maxWidthProperty().bind(sidePane.widthProperty());
PushToApplicationButton pushToExternal = new PushToApplicationButton(this, pushApplications.getApplications());

PushToApplicationAction pushToApplicationAction = new PushToApplicationAction(this, Globals.stateManager);
HBox rightSide = new HBox(
factory.createIconButton(StandardActions.NEW_ARTICLE, new NewEntryAction(this, BiblatexEntryTypes.ARTICLE, dialogService, Globals.prefs)),
factory.createIconButton(StandardActions.DELETE_ENTRY, new OldDatabaseCommandWrapper(Actions.DELETE, this, Globals.stateManager)),
Expand All @@ -570,7 +571,7 @@ private Node createToolbar() {
factory.createIconButton(StandardActions.COPY, new OldDatabaseCommandWrapper(Actions.COPY, this, Globals.stateManager)),
factory.createIconButton(StandardActions.PASTE, new OldDatabaseCommandWrapper(Actions.PASTE, this, Globals.stateManager)),
new Separator(Orientation.VERTICAL),
factory.createIconButton(pushToExternal.getMenuAction(), pushToExternal),
factory.createIconButton(pushToApplicationAction.getActionInformation(), pushToApplicationAction),
factory.createIconButton(StandardActions.GENERATE_CITE_KEYS, new OldDatabaseCommandWrapper(Actions.MAKE_KEY, this, Globals.stateManager)),
factory.createIconButton(StandardActions.CLEANUP_ENTRIES, new OldDatabaseCommandWrapper(Actions.CLEANUP, this, Globals.stateManager)),
new Separator(Orientation.VERTICAL),
Expand Down Expand Up @@ -798,7 +799,7 @@ private MenuBar createMenu() {
factory.createMenuItem(StandardActions.SET_FILE_LINKS, new AutoLinkFilesAction(this, prefs))
);

PushToApplicationButton pushToExternal = new PushToApplicationButton(this, pushApplications.getApplications());
final PushToApplicationAction pushToApplicationAction = new PushToApplicationAction(this, Globals.stateManager);
tools.getItems().addAll(
factory.createMenuItem(StandardActions.NEW_SUB_LIBRARY_FROM_AUX, new NewSubLibraryAction(this)),
factory.createMenuItem(StandardActions.FIND_UNLINKED_FILES, new FindUnlinkedFilesAction(this)),
Expand All @@ -815,7 +816,7 @@ private MenuBar createMenu() {
factory.createMenuItem(StandardActions.GENERATE_CITE_KEYS, new OldDatabaseCommandWrapper(Actions.MAKE_KEY, this, Globals.stateManager)),
factory.createMenuItem(StandardActions.REPLACE_ALL, new OldDatabaseCommandWrapper(Actions.REPLACE_ALL, this, Globals.stateManager)),
factory.createMenuItem(StandardActions.SEND_AS_EMAIL, new OldDatabaseCommandWrapper(Actions.SEND_AS_EMAIL, this, Globals.stateManager)),
factory.createMenuItem(pushToExternal.getMenuAction(), pushToExternal),
factory.createMenuItem(pushToApplicationAction.getActionInformation(), pushToApplicationAction),

factory.createSubMenu(StandardActions.ABBREVIATE,
factory.createMenuItem(StandardActions.ABBREVIATE_ISO, new OldDatabaseCommandWrapper(Actions.ABBREVIATE_ISO, this, Globals.stateManager)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@

/**
* A command that is only executable if a database is open.
* Deprecated use instead
* @see org.jabref.gui.actions.SimpleCommand
*/
@Deprecated
public class OldDatabaseCommandWrapper extends CommandBase {

private static final Logger LOGGER = LoggerFactory.getLogger(OldDatabaseCommandWrapper.class);
Expand Down
39 changes: 31 additions & 8 deletions src/main/java/org/jabref/gui/desktop/JabRefDesktop.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,33 @@ private static void openExternalFilePlatformIndependent(Optional<ExternalFileTyp
* @throws IOException
*/
public static void openFolderAndSelectFile(Path fileLink) throws IOException {
NATIVE_DESKTOP.openFolderAndSelectFile(fileLink);
if (fileLink == null) {
return;
}
boolean usingDefault = Globals.prefs.getBoolean(JabRefPreferences.USE_DEFAULT_FILE_BROWSER_APPLICATION);

if (usingDefault) {
NATIVE_DESKTOP.openFolderAndSelectFile(fileLink);
} else {
String absolutePath = fileLink.toAbsolutePath().getParent().toString();
String command = Globals.prefs.get(JabRefPreferences.FILE_BROWSER_COMMAND);
if (!command.isEmpty()) {
command = command.replaceAll("\\s+", " "); // normalize white spaces

// replace the placeholder if used
command = command.replace("%DIR", absolutePath);
String[] subcommands = command.split(" ");

LOGGER.info("Executing command \"" + command + "\"...");

try {
new ProcessBuilder(subcommands).start();
} catch (IOException exception) {
LOGGER.error("Open File Browser", exception);
JabRefGUI.getMainFrame().getDialogService().notify(Localization.lang("Error occured while executing the command \"%0\".", command));
}
}
}
}

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

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

// replace the placeholder if used
String commandLoggingText = command.replace("%DIR", absolutePath);
String[] subcommands = command.split(" ");

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

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

JabRefGUI.getMainFrame().getDialogService().showErrorDialogAndWait(
Localization.lang("Open console") + " - " + Localization.lang("Error",
Localization.lang("Error occured while executing the command \"%0\".", commandLoggingText)));
JabRefGUI.getMainFrame().getDialogService().notify(Localization.lang("Error occured while executing the command \"%0\".", command));
}
}
}
Expand Down
19 changes: 9 additions & 10 deletions src/main/java/org/jabref/gui/desktop/os/Linux.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,18 @@ public void openFileWithApplication(String filePath, String application) throws

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

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

if (desktopSession.contains("gnome")) {
cmd = "nautilus" + filePath.toString().replace(" ", "\\ ");
} else if (desktopSession.contains("kde")) {
cmd = "dolphin --select " + filePath.toString().replace(" ", "\\ ");
} else {
cmd = "xdg-open " + filePath.toAbsolutePath().getParent().toString();
if (desktopSession != null) {
desktopSession = desktopSession.toLowerCase(Locale.ROOT);
if (desktopSession.contains("gnome")) {
cmd = "nautilus" + filePath.toString().replace(" ", "\\ ");
} else if (desktopSession.contains("kde")) {
cmd = "dolphin --select " + filePath.toString().replace(" ", "\\ ");
}
}

Runtime.getRuntime().exec(cmd);
}

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

String emulatorName = reader.readLine();

if (emulatorName != null) {
emulatorName = emulatorName.substring(emulatorName.lastIndexOf(File.separator) + 1);

Expand Down
48 changes: 48 additions & 0 deletions src/main/java/org/jabref/gui/preferences/ExternalTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.jabref.gui.util.FileDialogConfiguration;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.util.OS;
import org.jabref.model.strings.StringUtil;
import org.jabref.preferences.JabRefPreferences;

class ExternalTab implements PrefsTab {
Expand All @@ -38,6 +39,12 @@ class ExternalTab implements PrefsTab {
private final RadioButton sumatraReader;
private final TextField adobeAcrobatReaderPath;
private final TextField sumatraReaderPath;

private final RadioButton defaultFileBrowser;
private final RadioButton executeFileBrowser;
private final TextField fileBrowserCommand;
private final Button fileBrowserButton;

private final GridPane builder = new GridPane();
private final DialogService dialogService;
private final FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder().build();
Expand All @@ -59,11 +66,20 @@ public ExternalTab(JabRefFrame frame, PreferencesDialog prefsDiag, JabRefPrefere
sumatraReaderPath = new TextField();
Button browseSumatraReader = new Button(Localization.lang("Browse"));

defaultFileBrowser = new RadioButton(Localization.lang("Use default file browser"));
executeFileBrowser = new RadioButton(Localization.lang("Execute Command"));
fileBrowserCommand = new TextField();
fileBrowserButton = new Button(Localization.lang("Browser"));

Label commandDescription = new Label(Localization.lang("Note: Use the placeholder %0 for the location of the opened library file.", "%DIR"));
defaultConsole.setOnAction(e -> updateExecuteConsoleButtonAndFieldEnabledState());
executeConsole.setOnAction(e -> updateExecuteConsoleButtonAndFieldEnabledState());
browseButton.setOnAction(e -> showConsoleChooser());

fileBrowserButton.disableProperty().bind(executeFileBrowser.selectedProperty().not());
fileBrowserCommand.disableProperty().bind(executeFileBrowser.selectedProperty().not());
fileBrowserButton.setOnAction(e -> showFileBrowserCommandChooser());

browseAdobeAcrobatReader.setOnAction(e -> showAdobeChooser());

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

Label fileBrowserCommandDescription = new Label(Localization.lang("Note: Use the placeholder %0 for the location of the opened library file.", "%DIR"));
GridPane fileBrowserOptionPanel = new GridPane();
final ToggleGroup fileBrowserGroup = new ToggleGroup();
defaultFileBrowser.setToggleGroup(fileBrowserGroup);
executeFileBrowser.setToggleGroup(fileBrowserGroup);
fileBrowserOptionPanel.add(defaultFileBrowser, 1, 1);
fileBrowserOptionPanel.add(executeFileBrowser, 1, 2);
fileBrowserOptionPanel.add(fileBrowserCommand, 2, 2);
fileBrowserOptionPanel.add(fileBrowserButton, 3, 2);
fileBrowserOptionPanel.add(fileBrowserCommandDescription, 2, 3);

if (OS.WINDOWS) {
browseSumatraReader.setOnAction(e -> showSumatraChooser());
pdfOptionPanel.add(sumatraReader, 1, 2);
Expand Down Expand Up @@ -133,6 +160,12 @@ public ExternalTab(JabRefFrame frame, PreferencesDialog prefsDiag, JabRefPrefere

builder.add(pdfOptionPanel, 1, 13);

Label openFileBrowser = new Label(Localization.lang("Open File Browser"));
openFileBrowser.getStyleClass().add("sectionHeader");
builder.add(openFileBrowser, 1, 14);

builder.add(fileBrowserOptionPanel, 1, 15);

}

@Override
Expand Down Expand Up @@ -165,6 +198,10 @@ public void setValues() {

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

defaultFileBrowser.setSelected(Globals.prefs.getBoolean(JabRefPreferences.USE_DEFAULT_FILE_BROWSER_APPLICATION));
executeFileBrowser.setSelected(!Globals.prefs.getBoolean(JabRefPreferences.USE_DEFAULT_FILE_BROWSER_APPLICATION));
fileBrowserCommand.setText(Globals.prefs.get(JabRefPreferences.FILE_BROWSER_COMMAND));

adobeAcrobatReaderPath.setText(Globals.prefs.get(JabRefPreferences.ADOBE_ACROBAT_COMMAND));
if (OS.WINDOWS) {
sumatraReaderPath.setText(Globals.prefs.get(JabRefPreferences.SUMATRA_PDF_COMMAND));
Expand All @@ -187,6 +224,13 @@ public void storeSettings() {
prefs.putBoolean(JabRefPreferences.USE_DEFAULT_CONSOLE_APPLICATION, defaultConsole.isSelected());
prefs.put(JabRefPreferences.CONSOLE_COMMAND, consoleCommand.getText());
prefs.put(JabRefPreferences.ADOBE_ACROBAT_COMMAND, adobeAcrobatReaderPath.getText());

prefs.putBoolean(JabRefPreferences.USE_DEFAULT_FILE_BROWSER_APPLICATION, defaultFileBrowser.isSelected());
if (StringUtil.isNotBlank(fileBrowserCommand.getText())) {
prefs.put(JabRefPreferences.FILE_BROWSER_COMMAND, fileBrowserCommand.getText());
} else {
prefs.putBoolean(JabRefPreferences.USE_DEFAULT_FILE_BROWSER_APPLICATION, true); //default if no command specified
}
if (OS.WINDOWS) {
prefs.put(JabRefPreferences.SUMATRA_PDF_COMMAND, sumatraReaderPath.getText());
}
Expand Down Expand Up @@ -220,6 +264,10 @@ private void showSumatraChooser() {
dialogService.showFileOpenDialog(fileDialogConfiguration).ifPresent(file -> sumatraReaderPath.setText(file.toAbsolutePath().toString()));
}

private void showFileBrowserCommandChooser() {
dialogService.showFileOpenDialog(fileDialogConfiguration).ifPresent(file -> fileBrowserCommand.setText(file.toAbsolutePath().toString()));
}

private void readerSelected() {
if (adobeAcrobatReader.isSelected()) {
prefs.put(JabRefPreferences.USE_PDF_READER, adobeAcrobatReaderPath.getText());
Expand Down
Loading

0 comments on commit a0e4c37

Please sign in to comment.