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

Integrate mrdlib redesign #4361

Merged
merged 25 commits into from
Oct 26, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
cfa4356
Recommendation retrieval from new Mr. DLib
conorfos Sep 5, 2018
1320270
Create GDPR dialog and update GUI
conorfos Sep 17, 2018
0416402
Privacy dialog text wrapping
conorfos Sep 18, 2018
86350c9
Created dev switch based on JabRef version
conorfos Sep 21, 2018
25e5cb8
Adjusted Hyperlink styling
conorfos Sep 26, 2018
045c15d
Removed .bib file included by mistake
conorfos Sep 26, 2018
69c6383
Simplification of Dev switch
conorfos Sep 27, 2018
3518596
Removed unnecessary setting of html_representation
conorfos Sep 27, 2018
4215e13
Removed .orig file mistakenly added
conorfos Sep 27, 2018
55ca696
Fixed Codacy issues and removed abstracts from tests
conorfos Sep 27, 2018
4ccbea6
Moved root styling to css file
conorfos Oct 11, 2018
440db51
Removed Print Stack Trace call
conorfos Oct 12, 2018
40af08c
Replaced UI strings with Localization.lang strings
conorfos Oct 12, 2018
4d5df3d
everted to EntryEditorPreferences
conorfos Oct 12, 2018
761ed98
Removed reference to Globals in MrDLibFetcher
conorfos Oct 15, 2018
b4dabe0
Fixed awkward syntax with JSONObject
conorfos Oct 15, 2018
bfe5abf
Implemented Dialogs
conorfos Oct 15, 2018
fdd1e03
Merge latest from Master
conorfos Oct 15, 2018
fb2fc79
Reverting unintended change
conorfos Oct 17, 2018
fd82562
Set Accept button as default button
conorfos Oct 17, 2018
9c769b1
Updated CHANGELOG.md
conorfos Oct 18, 2018
4357ada
Merge branch 'master' into integrate-mrdlib-redesign
conorfos Oct 18, 2018
493d5e6
Fix for broken MrDLibFetcherTest
conorfos Oct 25, 2018
571618c
Fix unused imports, refactor event listener to lambda, call static me…
halirutan Oct 26, 2018
ecf9eb5
Fix localization strings
halirutan Oct 26, 2018
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
67 changes: 25 additions & 42 deletions src/main/java/org/jabref/gui/entryeditor/RelatedArticlesTab.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
package org.jabref.gui.entryeditor;

import java.io.IOException;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.function.Consumer;

import javafx.concurrent.Task;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.print.PrinterJob;
import javafx.scene.control.*;

import javafx.scene.control.Button;
import javafx.scene.control.Hyperlink;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.Tooltip;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
Expand All @@ -21,17 +16,14 @@
import javafx.scene.text.Text;

import org.jabref.Globals;
import org.jabref.gui.Dialog;
import org.jabref.gui.DialogService;
import org.jabref.gui.desktop.JabRefDesktop;
import org.jabref.gui.util.BackgroundTask;
import org.jabref.gui.util.DirectoryDialogConfiguration;
import org.jabref.gui.util.FileDialogConfiguration;
import org.jabref.logic.importer.fetcher.MrDLibFetcher;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.FieldName;
import org.jabref.preferences.JabRefPreferences;
import org.jabref.gui.DialogService;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -102,16 +94,13 @@ private VBox getRelatedArticleInfo(List<BibEntry> list) {
journalText.setFont(Font.font(Font.getDefault().getFamily(), FontPosture.ITALIC, Font.getDefault().getSize()));
Text authorsText = new Text(authors);
Text yearText = new Text("(" + year + ")");
titleLink.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
if (entry.getField(FieldName.URL).isPresent()) {
try {
JabRefDesktop.openBrowser(entry.getField(FieldName.URL).get());
} catch (IOException e) {
LOGGER.error("Error opening the browser to: " + entry.getField(FieldName.URL).get(), e);
dialogService.showErrorDialogAndWait(e);
}
titleLink.setOnAction(event -> {
if (entry.getField(FieldName.URL).isPresent()) {
try {
JabRefDesktop.openBrowser(entry.getField(FieldName.URL).get());
} catch (IOException e) {
LOGGER.error("Error opening the browser to: " + entry.getField(FieldName.URL).get(), e);
dialogService.showErrorDialogAndWait(e);
}
}
});
Expand Down Expand Up @@ -141,26 +130,20 @@ private ScrollPane getPrivacyDialog(BibEntry entry) {
line1.setWrappingWidth(1300.0);
Text line2 = new Text(Localization.lang("This setting may be changed in preferences at any time."));
Hyperlink mdlLink = new Hyperlink(Localization.lang("Further information about Mr DLib. for JabRef users."));
mdlLink.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
try {
JabRefDesktop.openBrowser("http://mr-dlib.org/information-for-users/information-about-mr-dlib-for-jabref-users/");
} catch (IOException e) {
LOGGER.error("Error opening the browser to Mr. DLib information page.", e);
dialogService.showErrorDialogAndWait(e);
}
mdlLink.setOnAction(event -> {
try {
JabRefDesktop.openBrowser("http://mr-dlib.org/information-for-users/information-about-mr-dlib-for-jabref-users/");
} catch (IOException e) {
LOGGER.error("Error opening the browser to Mr. DLib information page.", e);
dialogService.showErrorDialogAndWait(e);
}
});

button.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
JabRefPreferences prefs = JabRefPreferences.getInstance();
prefs.putBoolean(JabRefPreferences.ACCEPT_RECOMMENDATIONS, true);
dialogService.showWarningDialogAndWait(Localization.lang("Restart"), Localization.lang("Please restart JabRef for preferences to take effect."));
setContent(getRelatedArticlesPane(entry));
}
button.setOnAction(event -> {
JabRefPreferences prefs = JabRefPreferences.getInstance();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the EntryEditorPreferences which are already passed via constructor. Apart form that lgtm

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But shouldn't this setting not go into the JabRefPreferences and not the preferences of the EntryEditor? When I see this correctly in the above screenshot, this setting was supposed to be available main preferences.

prefs.putBoolean(JabRefPreferences.ACCEPT_RECOMMENDATIONS, true);
dialogService.showWarningDialogAndWait(Localization.lang("Restart"), Localization.lang("Please restart JabRef for preferences to take effect."));
setContent(getRelatedArticlesPane(entry));
});

vbox.getChildren().addAll(line1, mdlLink, line2, button);
Expand Down
14 changes: 4 additions & 10 deletions src/main/java/org/jabref/logic/importer/fetcher/MrDLibFetcher.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
*
*/
package org.jabref.logic.importer.fetcher;

import java.io.IOException;
Expand All @@ -10,12 +7,10 @@
import java.util.List;
import java.util.Optional;

import org.jabref.Globals;
import org.jabref.logic.importer.EntryBasedFetcher;
import org.jabref.logic.importer.FetcherException;
import org.jabref.logic.importer.ParserResult;
import org.jabref.logic.importer.fileformat.MrDLibImporter;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.net.URLDownload;
import org.jabref.logic.util.Version;
import org.jabref.model.database.BibDatabase;
Expand Down Expand Up @@ -52,7 +47,7 @@ public List<BibEntry> performSearch(BibEntry entry) throws FetcherException {
if (title.isPresent()) {
String response = makeServerRequest(title.get());
MrDLibImporter importer = new MrDLibImporter();
ParserResult parserResult = new ParserResult();
ParserResult parserResult;
try {
if (importer.isRecognizedFormat(response)) {
parserResult = importer.importDatabase(response);
Expand Down Expand Up @@ -85,7 +80,7 @@ public List<BibEntry> performSearch(BibEntry entry) throws FetcherException {
private String makeServerRequest(String queryByTitle) throws FetcherException {
try {
URLDownload urlDownload = new URLDownload(constructQuery(queryByTitle));
urlDownload.bypassSSLVerification();
URLDownload.bypassSSLVerification();
String response = urlDownload.asString();

//Conversion of < and >
Expand All @@ -98,7 +93,7 @@ private String makeServerRequest(String queryByTitle) throws FetcherException {
}

/**
* Constructs the query based on title of the bibentry. Adds statistical stuff to the url.
* Constructs the query based on title of the BibEntry. Adds statistical stuff to the url.
*
* @param queryWithTitle: the title of the bib entry.
* @return the string used to make the query at mdl server
Expand All @@ -114,9 +109,8 @@ private String constructQuery(String queryWithTitle) {
builder.addParameter("app_id", "jabref_desktop");
builder.addParameter("app_version", VERSION.getFullVersion());
builder.addParameter("app_lang", LANGUAGE);
URI uri = null;
try {
uri = builder.build();
URI uri = builder.build();
LOGGER.trace("Request: " + uri.toString());
return uri.toString();
} catch (URISyntaxException e) {
Expand Down