Skip to content

Commit

Permalink
Merge branch 'ooPanel' of github.com:JabRef/jabref into ooPanel
Browse files Browse the repository at this point in the history
* 'ooPanel' of github.com:JabRef/jabref:
  Refactor BibEntry deprecated method (#4554)
  Added extra stats to be sent with MrDLib recommendations (#4452)
  checkstyle
  change mac default settings to LO path
  Add Book as preview as well
  fix style file select layout and inline variable'
  improve styling of preferences side menu (#4556)
  Cleanup interfaces (#4553)
  • Loading branch information
Siedlerchr committed Jan 3, 2019
2 parents e9e6dfa + e83078e commit 126ef78
Show file tree
Hide file tree
Showing 50 changed files with 228 additions and 126 deletions.
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
Expand Up @@ -31,7 +31,6 @@ public class DetectOpenOfficeInstallation {

private final OpenOfficePreferences preferences;
private final DialogService dialogService;
private FXDialog progressDialog;

public DetectOpenOfficeInstallation(OpenOfficePreferences preferences, DialogService dialogService) {
this.preferences = preferences;
Expand All @@ -52,8 +51,7 @@ public FXDialog initProgressDialog() {
DialogPane dialogPane = new DialogPane();
ProgressIndicator indicator = new ProgressIndicator(ProgressIndicator.INDETERMINATE_PROGRESS);
dialogPane.setContent(indicator);

progressDialog = dialogService.showCustomDialog(Localization.lang("Autodetecting paths..."), dialogPane, ButtonType.CANCEL);
FXDialog progressDialog = dialogService.showCustomDialog(Localization.lang("Autodetecting paths..."), dialogPane, ButtonType.CANCEL);
progressDialog.show();

return progressDialog;
Expand Down
15 changes: 9 additions & 6 deletions src/main/java/org/jabref/gui/openoffice/StyleSelectDialog.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.VBox?>

<DialogPane minHeight="-Infinity" minWidth="-Infinity" prefHeight="470.0" prefWidth="701.0" xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.jabref.gui.openoffice.StyleSelectDialogView">
<DialogPane minHeight="-Infinity" minWidth="-Infinity" prefHeight="470.0" prefWidth="701.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.jabref.gui.openoffice.StyleSelectDialogView">
<content>
<BorderPane>
<top>
<TableView fx:id="tvStyles" prefHeight="208.0" prefWidth="662.0" BorderPane.alignment="CENTER">
<columns>
<TableColumn fx:id="colName" prefWidth="75.0" text="%Name"/>
<TableColumn fx:id="colJournals" prefWidth="75.0" text="%Journals" />
<TableColumn fx:id="colFile" prefWidth="75.0" text="%File" />
<TableColumn fx:id="colDeleteIcon" minWidth="60.0" prefWidth="60.0" />
<TableColumn fx:id="colName" minWidth="100.0" prefWidth="-1.0" text="%Name" />
<TableColumn fx:id="colJournals" minWidth="100.0" prefWidth="75.0" text="%Journals" />
<TableColumn fx:id="colFile" minWidth="100.0" prefWidth="-1.0" text="%File" />
<TableColumn fx:id="colDeleteIcon" minWidth="100.0" prefWidth="-1.0" />
</columns>
<columnResizePolicy>
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
</columnResizePolicy>
</TableView>
</top>
<right>
Expand All @@ -31,6 +34,6 @@
</content>
<buttonTypes>
<ButtonType fx:constant="CANCEL" />
<ButtonType fx:constant="OK"/>
<ButtonType fx:constant="OK" />
</buttonTypes>
</DialogPane>
15 changes: 10 additions & 5 deletions src/main/java/org/jabref/gui/openoffice/StyleSelectDialogView.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public class StyleSelectDialogView extends BaseDialog<OOBibStyle> {
private StyleSelectDialogViewModel viewModel;
private final DialogService dialogService;
private final StyleLoader loader;
private PreviewPanel preview;
private PreviewPanel previewArticle;
private PreviewPanel previewBook;

public StyleSelectDialogView(DialogService dialogService, StyleLoader loader) {
this.dialogService = dialogService;
Expand All @@ -70,10 +71,13 @@ private void initialize() {

viewModel = new StyleSelectDialogViewModel(dialogService, loader, preferencesService);

preview = new PreviewPanel(null, new BibDatabaseContext(), preferencesService.getKeyBindingRepository(), preferencesService.getPreviewPreferences(), dialogService, ExternalFileTypes.getInstance());
preview.setEntry(TestEntry.getTestEntry());
previewArticle = new PreviewPanel(null, new BibDatabaseContext(), preferencesService.getKeyBindingRepository(), preferencesService.getPreviewPreferences(), dialogService, ExternalFileTypes.getInstance());
previewArticle.setEntry(TestEntry.getTestEntry());
vbox.getChildren().add(previewArticle);

vbox.getChildren().add(preview);
previewBook = new PreviewPanel(null, new BibDatabaseContext(), preferencesService.getKeyBindingRepository(), preferencesService.getPreviewPreferences(), dialogService, ExternalFileTypes.getInstance());
previewBook.setEntry(TestEntry.getTestEntryBook());
vbox.getChildren().add(previewBook);

colName.setCellValueFactory(cellData -> cellData.getValue().nameProperty());
colJournals.setCellValueFactory(cellData -> cellData.getValue().journalsProperty());
Expand Down Expand Up @@ -115,7 +119,8 @@ private void initialize() {

EasyBind.subscribe(viewModel.selectedItemProperty(), style -> {
tvStyles.getSelectionModel().select(style);
preview.setLayout(style.getStyle().getReferenceFormat("default"));
previewArticle.setLayout(style.getStyle().getReferenceFormat("default"));
previewBook.setLayout(style.getStyle().getReferenceFormat("default"));
});
}

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
Loading

0 comments on commit 126ef78

Please sign in to comment.