Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into fixFocusCheck
Browse files Browse the repository at this point in the history
* upstream/master:
  Bump checkstyle from 8.15 to 8.16 (#4562)
  Bump xmpbox from 2.0.12 to 2.0.13 (#4561)
  Delete the deprecated BibEntry Constructor (#4560)
  Refactor BibEntry deprecated method (#4554)
  Added extra stats to be sent with MrDLib recommendations (#4452)
  improve styling of preferences side menu (#4556)
  Cleanup interfaces (#4553)
  • Loading branch information
Siedlerchr committed Jan 4, 2019
2 parents e4ba277 + a4e735b commit e92ad3a
Show file tree
Hide file tree
Showing 47 changed files with 195 additions and 123 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ dependencies {

compile 'org.apache.pdfbox:pdfbox:2.0.13'
compile 'org.apache.pdfbox:fontbox:2.0.13'
compile 'org.apache.pdfbox:xmpbox:2.0.12'
compile 'org.apache.pdfbox:xmpbox:2.0.13'

// required for reading write-protected PDFs - see https://github.com/JabRef/jabref/pull/942#issuecomment-209252635
compile 'org.bouncycastle:bcprov-jdk15on:1.60'
Expand Down Expand Up @@ -180,7 +180,7 @@ dependencies {
testCompile "org.testfx:testfx-core:4.0.+"
testCompile "org.testfx:testfx-junit5:4.0.+"

checkstyle 'com.puppycrawl.tools:checkstyle:8.15'
checkstyle 'com.puppycrawl.tools:checkstyle:8.16'
}

jacoco {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.jabref.gui.autocompleter;

public interface AutoCompletionStrategy {

public AutoCompletionInput analyze(String input);
AutoCompletionInput analyze(String input);
}
24 changes: 21 additions & 3 deletions src/main/java/org/jabref/gui/entryeditor/RelatedArticlesTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.List;

import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Hyperlink;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.control.ScrollPane;
Expand Down Expand Up @@ -125,10 +126,12 @@ private ScrollPane getPrivacyDialog(BibEntry entry) {

Button button = new Button(Localization.lang("I Agree"));
button.setDefaultButton(true);
Text line1 = new Text(Localization.lang("Mr. DLib is an external service which provides article recommendations based on the currently selected entry. Data about the selected entry must be sent to Mr. DLib in order to provide these recommendations. Do you agree that this data may be sent?"));

Text line1 = new Text(Localization.lang("JabRef requests recommendations from Mr. DLib, which is an external service. To enable Mr. DLib to calculate recommendations, some of your data must be shared with Mr. DLib. Generally, the more data is shared the better recommendations can be calculated. However, we understand that some of your data in JabRef is sensitive, and you may not want to share it. Therefore, Mr. DLib offers a choice of which data you would like to share."));
line1.setWrappingWidth(1300.0);
Text line2 = new Text(Localization.lang("This setting may be changed in preferences at any time."));
Text line2 = new Text(Localization.lang("Whatever option you choose, Mr. DLib may share its data with research partners to further improve recommendation quality as part of a 'living lab'. Mr. DLib may also release public datasets that may contain anonymized information about you and the recommendations (sensitive information such as metadata of your articles will be anonymised through e.g. hashing). Research partners are obliged to adhere to the same strict data protection policy as Mr. DLib."));
line2.setWrappingWidth(1300.0);
Text line3 = 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(event -> {
try {
Expand All @@ -138,15 +141,30 @@ private ScrollPane getPrivacyDialog(BibEntry entry) {
dialogService.showErrorDialogAndWait(e);
}
});
VBox vb = new VBox();
CheckBox cbTitle = new CheckBox(Localization.lang("Entry Title (Required to deliver recommendations.)"));
cbTitle.setSelected(true);
cbTitle.setDisable(true);
CheckBox cbVersion = new CheckBox(Localization.lang("JabRef Version (Required to ensure backwards compatibility with Mr. DLib's Web Service)"));
cbVersion.setSelected(true);
cbVersion.setDisable(true);
CheckBox cbLanguage = new CheckBox(Localization.lang("JabRef Language (Provides for better recommendations by giving an indication of user's preferred language.)"));
CheckBox cbOS = new CheckBox(Localization.lang("Operating System (Provides for better recommendations by giving an indication of user's system set-up.)"));
CheckBox cbTimezone = new CheckBox(Localization.lang("Timezone (Provides for better recommendations by indicating the time of day the request is being made.)"));
vb.getChildren().addAll(cbTitle, cbVersion, cbLanguage, cbOS, cbTimezone);
vb.setSpacing(10);

button.setOnAction(event -> {
JabRefPreferences prefs = JabRefPreferences.getInstance();
prefs.putBoolean(JabRefPreferences.ACCEPT_RECOMMENDATIONS, true);
prefs.putBoolean(JabRefPreferences.SEND_LANGUAGE_DATA, cbLanguage.isSelected());
prefs.putBoolean(JabRefPreferences.SEND_OS_DATA, cbOS.isSelected());
prefs.putBoolean(JabRefPreferences.SEND_TIMEZONE_DATA, cbTimezone.isSelected());
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);
vbox.getChildren().addAll(line1, line2, mdlLink, line3, vb, button);
root.setContent(vbox);

return root;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#sideMenu {
-fx-background-color: -jr-white;
-fx-border-color: -fx-outer-border;
-fx-border-width: 1;
}

#sideMenu > .virtual-flow > .clipped-container > .sheet > .list-cell {
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/org/jabref/gui/preferences/PreferencesDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,20 +116,21 @@ private void construct() {

VBox buttonContainer = new VBox();
buttonContainer.setAlignment(Pos.BOTTOM_LEFT);
buttonContainer.setSpacing(3.0);
Button importPreferences = new Button(Localization.lang("Import preferences"));
importPreferences.setTooltip(new Tooltip(Localization.lang("Import preferences from file")));
importPreferences.setOnAction(e -> importPreferences());
importPreferences.getStyleClass().add("text-button");
importPreferences.setMaxWidth(Double.MAX_VALUE);
Button exportPreferences = new Button(Localization.lang("Export preferences"));
exportPreferences.setTooltip(new Tooltip(Localization.lang("Export preferences to file")));
exportPreferences.setOnAction(e -> exportPreferences());
exportPreferences.getStyleClass().add("text-button");
exportPreferences.setMaxWidth(Double.MAX_VALUE);
Button showPreferences = new Button(Localization.lang("Show preferences"));
showPreferences.setOnAction(e -> new PreferencesFilterDialog(new JabRefPreferencesFilter(prefs)).setVisible(true));
showPreferences.getStyleClass().add("text-button");
showPreferences.setMaxWidth(Double.MAX_VALUE);
Button resetPreferences = new Button(Localization.lang("Reset preferences"));
resetPreferences.setOnAction(e -> resetPreferences());
resetPreferences.getStyleClass().add("text-button");
resetPreferences.setMaxWidth(Double.MAX_VALUE);
buttonContainer.getChildren().addAll(
importPreferences,
exportPreferences,
Expand All @@ -138,6 +139,7 @@ private void construct() {
);

VBox spacer = new VBox();
spacer.setPrefHeight(10.0);
VBox.setVgrow(tabsList, Priority.ALWAYS);
VBox.setVgrow(spacer, Priority.SOMETIMES);
vBox.getChildren().addAll(
Expand Down
22 changes: 18 additions & 4 deletions src/main/java/org/jabref/logic/importer/fetcher/MrDLibFetcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Optional;

Expand All @@ -16,6 +17,7 @@
import org.jabref.model.database.BibDatabase;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.FieldName;
import org.jabref.preferences.JabRefPreferences;

import org.apache.http.client.utils.URIBuilder;
import org.slf4j.Logger;
Expand All @@ -27,6 +29,7 @@
public class MrDLibFetcher implements EntryBasedFetcher {
private static final Logger LOGGER = LoggerFactory.getLogger(MrDLibFetcher.class);
private static final String NAME = "MDL_FETCHER";
private static final String MDL_JABREF_PARTNER_ID = "1";
private final String LANGUAGE;
private final Version VERSION;

Expand Down Expand Up @@ -104,11 +107,22 @@ private String constructQuery(String queryWithTitle) {
URIBuilder builder = new URIBuilder();
builder.setScheme("http");
builder.setHost(getMdlUrl());
builder.setPath("/v2/items/" + queryWithTitle + "/related_items");
builder.addParameter("partner_id", "jabref");
builder.setPath("/v2/documents/" + queryWithTitle + "/related_documents");
builder.addParameter("partner_id", MDL_JABREF_PARTNER_ID);
builder.addParameter("app_id", "jabref_desktop");
builder.addParameter("app_version", VERSION.getFullVersion());
builder.addParameter("app_lang", LANGUAGE);

JabRefPreferences prefs = JabRefPreferences.getInstance();
if (prefs.getBoolean(JabRefPreferences.SEND_LANGUAGE_DATA)) {
builder.addParameter("app_lang", LANGUAGE);
}
if (prefs.getBoolean(JabRefPreferences.SEND_OS_DATA)) {
builder.addParameter("os", System.getProperty("os.name"));
}
if (prefs.getBoolean(JabRefPreferences.SEND_TIMEZONE_DATA)) {
builder.addParameter("timezone", Calendar.getInstance().getTimeZone().getID());
}

try {
URI uri = builder.build();
LOGGER.trace("Request: " + uri.toString());
Expand All @@ -120,6 +134,6 @@ private String constructQuery(String queryWithTitle) {
}

private String getMdlUrl() {
return VERSION.isDevelopmentVersion() ? "api-dev.darwingoliath.com" : "api.darwingoliath.com";
return VERSION.isDevelopmentVersion() ? "api-dev.darwingoliath.com" : "api.mr-dlib.org";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.jabref.logic.importer.ParserResult;
import org.jabref.logic.util.StandardFileType;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.BibtexEntryTypes;
import org.jabref.model.entry.FieldName;

/**
Expand Down Expand Up @@ -255,7 +256,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {
if (!comments.isEmpty()) { // set comment if present
hm.put(FieldName.COMMENT, String.join(";", comments));
}
BibEntry b = new BibEntry(bibtexType);
BibEntry b = new BibEntry(BibtexEntryTypes.getTypeOrDefault(bibtexType));
b.setField(hm);
bibItems.add(b);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.jabref.model.database.BibDatabase;
import org.jabref.model.database.KeyCollisionException;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.BibtexEntryTypes;
import org.jabref.model.entry.BibtexString;
import org.jabref.model.entry.CustomEntryType;
import org.jabref.model.entry.EntryType;
Expand Down Expand Up @@ -504,7 +505,8 @@ private String parsePreamble() throws IOException {
}

private BibEntry parseEntry(String entryType) throws IOException {
BibEntry result = new BibEntry(entryType);
BibEntry result = new BibEntry(BibtexEntryTypes.getTypeOrDefault(entryType));

skipWhitespace();
consume('{', '(');
int character = peek();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.jabref.logic.importer.ParserResult;
import org.jabref.logic.util.StandardFileType;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.BibtexEntryTypes;
import org.jabref.model.entry.FieldName;

/**
Expand Down Expand Up @@ -98,7 +99,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {

// Copac does not contain enough information on the type of the
// document. A book is assumed.
BibEntry b = new BibEntry("book");
BibEntry b = new BibEntry(BibtexEntryTypes.BOOK);

String[] lines = entry.split("\n");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.jabref.logic.util.StandardFileType;
import org.jabref.model.entry.AuthorList;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.BibtexEntryTypes;
import org.jabref.model.entry.FieldName;

/**
Expand Down Expand Up @@ -253,7 +254,7 @@ else if ("P".equals(prefix)) {
hm.put(FieldName.PAGES, artnum);
}

BibEntry b = new BibEntry(type);
BibEntry b = new BibEntry(BibtexEntryTypes.getTypeOrDefault(type));
b.setField(hm);
if (!b.getFieldNames().isEmpty()) {
bibitems.add(b);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.jabref.logic.importer.ParseException;
import org.jabref.logic.importer.Parser;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.BibtexEntryTypes;
import org.jabref.model.entry.FieldName;

import com.google.common.base.Strings;
Expand Down Expand Up @@ -360,7 +361,7 @@ private BibEntry parseEntry(Element e) {
* dann @incollection annehmen, wenn weder ISBN noch
* ZDB-ID vorhanden sind.
*/
BibEntry result = new BibEntry(entryType);
BibEntry result = new BibEntry(BibtexEntryTypes.getTypeOrDefault(entryType));

// Zuordnung der Felder in Abhängigkeit vom Dokumenttyp
if (author != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.jabref.logic.util.StandardFileType;
import org.jabref.model.entry.AuthorList;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.BibtexEntryTypes;
import org.jabref.model.entry.FieldName;

/**
Expand Down Expand Up @@ -120,7 +121,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {
}
}
}
BibEntry b = new BibEntry(type);
BibEntry b = new BibEntry(BibtexEntryTypes.getTypeOrDefault(type));
b.setField(h);

bibitems.add(b);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.jabref.logic.importer.ParserResult;
import org.jabref.logic.util.StandardFileType;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.BibtexEntryTypes;
import org.jabref.model.entry.FieldName;
import org.jabref.model.entry.Month;

Expand Down Expand Up @@ -301,7 +302,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {
continue;
}

BibEntry b = new BibEntry(Type);
BibEntry b = new BibEntry(BibtexEntryTypes.getTypeOrDefault(Type));
// id assumes an existing database so don't

// Remove empty fields:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
import org.jabref.logic.importer.fileformat.medline.Text;
import org.jabref.logic.util.StandardFileType;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.BibtexEntryTypes;
import org.jabref.model.entry.FieldName;
import org.jabref.model.strings.StringUtil;

Expand Down Expand Up @@ -262,7 +263,7 @@ private void parseBookArticle(PubmedBookArticle currentArticle, List<BibEntry> b
putIfValueNotNull(fields, "pubstatus", bookData.getPublicationStatus());
}

BibEntry entry = new BibEntry("article");
BibEntry entry = new BibEntry(BibtexEntryTypes.ARTICLE);
entry.setField(fields);

bibItems.add(entry);
Expand Down Expand Up @@ -410,7 +411,7 @@ private void parseArticle(PubmedArticle article, List<BibEntry> bibItems) {
}
}

BibEntry entry = new BibEntry("article");
BibEntry entry = new BibEntry(BibtexEntryTypes.ARTICLE);
entry.setField(fields);

bibItems.add(entry);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.jabref.logic.util.StandardFileType;
import org.jabref.model.entry.AuthorList;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.BibtexEntryTypes;
import org.jabref.model.entry.FieldName;

/**
Expand Down Expand Up @@ -208,7 +209,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {
fields.put(FieldName.COMMENT, comment);
}

BibEntry b = new BibEntry(type);
BibEntry b = new BibEntry(BibtexEntryTypes.getTypeOrDefault(type));

// Remove empty fields:
fields.entrySet().stream().filter(n -> n.getValue().trim().isEmpty()).forEach(fields::remove);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ private RankedBibEntry populateBibEntry(JSONObject recommendation) {
// parse each of the relevant fields into variables
String authors = isRecommendationFieldPresent(recommendation, "authors") ? getAuthorsString(recommendation) : "";
String title = isRecommendationFieldPresent(recommendation, "title") ? recommendation.getString("title") : "";
String year = isRecommendationFieldPresent(recommendation, "year_published") ? Integer.toString(recommendation.getInt("year_published")) : "";
String year = isRecommendationFieldPresent(recommendation, "published_year") ? Integer.toString(recommendation.getInt("published_year")) : "";
String journal = isRecommendationFieldPresent(recommendation, "published_in") ? recommendation.getString("published_in") : "";
String url = isRecommendationFieldPresent(recommendation, "url") ? recommendation.getString("url") : "";
Integer rank = isRecommendationFieldPresent(recommendation, "url") ? recommendation.getInt("recommendation_id") : 100;
Integer rank = isRecommendationFieldPresent(recommendation, "recommendation_id") ? recommendation.getInt("recommendation_id") : 100;

// Populate bib entry with relevant data
current.setField(FieldName.AUTHOR, authors);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.jabref.logic.util.StandardFileType;
import org.jabref.model.entry.AuthorList;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.BibtexEntryTypes;
import org.jabref.model.entry.FieldName;

/**
Expand Down Expand Up @@ -207,7 +208,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {
// Move the "chaptertitle" to just "title":
h.put(FieldName.TITLE, h.remove("chaptertitle"));
}
BibEntry b = new BibEntry(entryType);
BibEntry b = new BibEntry(BibtexEntryTypes.getTypeOrDefault(entryType));
b.setField(h);

bibitems.add(b);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.jabref.logic.util.StandardFileType;
import org.jabref.model.entry.AuthorList;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.BibtexEntryTypes;
import org.jabref.model.entry.FieldName;
import org.jabref.model.entry.Month;

Expand Down Expand Up @@ -265,7 +266,7 @@ else if ("AV".equals(tag)) {

// create one here
// type is set in the loop above
BibEntry entry = new BibEntry(type);
BibEntry entry = new BibEntry(BibtexEntryTypes.getTypeOrDefault(type));
entry.setField(fields);
// month has a special treatment as we use the separate method "setMonth" of BibEntry instead of directly setting the value
month.ifPresent(entry::setMonth);
Expand Down
Loading

0 comments on commit e92ad3a

Please sign in to comment.