From 5855bcf9d28e424f30472fd00abe7cdd8abc7647 Mon Sep 17 00:00:00 2001 From: Oscar Lindgren <64270456+osclind@users.noreply.github.com> Date: Tue, 9 Mar 2021 15:19:06 +0100 Subject: [PATCH 1/8] Improve user friendliness of automatically linked files (#7484) Co-authored-by: Lukas Gutenberg Co-authored-by: martinfalke Co-authored-by: LukasGutenberg --- CHANGELOG.md | 1 + src/main/java/org/jabref/gui/Base.css | 4 ++++ .../org/jabref/gui/fieldeditors/LinkedFilesEditor.java | 10 +++++++++- src/main/java/org/jabref/gui/icon/IconTheme.java | 2 +- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 43fdf812fdf..8b0901a26fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - The export to MS Office XML now uses the month name for the field `MonthAcessed` instead of the two digit number [#7354](https://github.com/JabRef/jabref/issues/7354) - We included some standalone dialogs from the options menu in the main preference dialog and fixed some visual issues in the preferences dialog. [#7384](https://github.com/JabRef/jabref/pull/7384) - We improved the linking of the `python3` interpreter via the shebang to dynamically use the systems default Python. Related to [JabRef-Browser-Extension #177](https://github.com/JabRef/JabRef-Browser-Extension/issues/177) +- Automatically found pdf files now have the linking button to the far left and uses a link icon with a plus instead of a briefcase. The file name also has lowered opacity(70%) until added. [#3607](https://github.com/JabRef/jabref/issues/3607) - We simplified the select entry type form by splitting it into two parts ("Recommended" and "Others") based on internal usage data. [#6730](https://github.com/JabRef/jabref/issues/6730) ### Fixed diff --git a/src/main/java/org/jabref/gui/Base.css b/src/main/java/org/jabref/gui/Base.css index 9296ab3a7d8..e7f42cd8bb4 100644 --- a/src/main/java/org/jabref/gui/Base.css +++ b/src/main/java/org/jabref/gui/Base.css @@ -646,6 +646,10 @@ -fx-fill: -jr-search-text; } +.file-row-text:opacity{ + -fx-fill: derive(-jr-search-text, 70%); +} + .combo-box-base { -fx-background-color: -fx-outer-border, -fx-control-inner-background; -fx-background-insets: 0, 1; diff --git a/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java b/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java index acba658aaec..bfd49abef93 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java +++ b/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java @@ -4,6 +4,7 @@ import javafx.beans.binding.Bindings; import javafx.collections.ObservableList; +import javafx.css.PseudoClass; import javafx.fxml.FXML; import javafx.scene.Node; import javafx.scene.Parent; @@ -46,6 +47,7 @@ import org.jabref.preferences.PreferencesService; import com.airhacks.afterburner.views.ViewLoader; +import com.tobiasdiez.easybind.EasyBind; public class LinkedFilesEditor extends HBox implements FieldEditorFX { @@ -137,11 +139,16 @@ private void handleOnDragDropped(LinkedFileViewModel originalItem, DragEvent eve } private static Node createFileDisplay(LinkedFileViewModel linkedFile) { + PseudoClass opacity = PseudoClass.getPseudoClass("opacity"); + Node icon = linkedFile.getTypeIcon().getGraphicNode(); icon.setOnMouseClicked(event -> linkedFile.open()); + Text link = new Text(); link.textProperty().bind(linkedFile.linkProperty()); link.getStyleClass().setAll("file-row-text"); + EasyBind.subscribe(linkedFile.isAutomaticallyFoundProperty(), found -> link.pseudoClassStateChanged(opacity, found)); + Text desc = new Text(); desc.textProperty().bind(linkedFile.descriptionProperty()); desc.getStyleClass().setAll("file-row-text"); @@ -157,6 +164,7 @@ private static Node createFileDisplay(LinkedFileViewModel linkedFile) { Button acceptAutoLinkedFile = IconTheme.JabRefIcons.AUTO_LINKED_FILE.asButton(); acceptAutoLinkedFile.setTooltip(new Tooltip(Localization.lang("This file was found automatically. Do you want to link it to this entry?"))); acceptAutoLinkedFile.visibleProperty().bind(linkedFile.isAutomaticallyFoundProperty()); + acceptAutoLinkedFile.managedProperty().bind(linkedFile.isAutomaticallyFoundProperty()); acceptAutoLinkedFile.setOnAction(event -> linkedFile.acceptAsLinked()); acceptAutoLinkedFile.getStyleClass().setAll("icon-button"); @@ -169,7 +177,7 @@ private static Node createFileDisplay(LinkedFileViewModel linkedFile) { HBox container = new HBox(10); container.setPrefHeight(Double.NEGATIVE_INFINITY); - container.getChildren().addAll(info, acceptAutoLinkedFile, writeXMPMetadata); + container.getChildren().addAll(acceptAutoLinkedFile, info, writeXMPMetadata); return container; } diff --git a/src/main/java/org/jabref/gui/icon/IconTheme.java b/src/main/java/org/jabref/gui/icon/IconTheme.java index 07a3a346fe1..aa95617c38f 100644 --- a/src/main/java/org/jabref/gui/icon/IconTheme.java +++ b/src/main/java/org/jabref/gui/icon/IconTheme.java @@ -230,7 +230,7 @@ public enum JabRefIcons implements JabRefIcon { RENAME(MaterialDesignR.RENAME_BOX), DELETE_FILE(MaterialDesignD.DELETE_FOREVER), REMOVE_LINK(MaterialDesignL.LINK_OFF), - AUTO_LINKED_FILE(MaterialDesignB.BRIEFCASE_CHECK), + AUTO_LINKED_FILE(MaterialDesignL.LINK_PLUS), QUALITY_ASSURED(MaterialDesignC.CERTIFICATE), QUALITY(MaterialDesignC.CERTIFICATE), OPEN(MaterialDesignF.FOLDER_OUTLINE), From 29ef951df438d6439bc7caaedfd48750171fd3b6 Mon Sep 17 00:00:00 2001 From: MLEP Date: Wed, 10 Mar 2021 10:48:21 +0100 Subject: [PATCH 2/8] Keep consistent numbering in filenames of ADR (#7503) --- .../{0019-keep-study-as-a-dto.md => 0021-keep-study-as-a-dto.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/adr/{0019-keep-study-as-a-dto.md => 0021-keep-study-as-a-dto.md} (100%) diff --git a/docs/adr/0019-keep-study-as-a-dto.md b/docs/adr/0021-keep-study-as-a-dto.md similarity index 100% rename from docs/adr/0019-keep-study-as-a-dto.md rename to docs/adr/0021-keep-study-as-a-dto.md From 49315f6ad4089819c1ef351601b6ccb68cf4cac4 Mon Sep 17 00:00:00 2001 From: MLEP Date: Wed, 10 Mar 2021 10:48:51 +0100 Subject: [PATCH 3/8] Keep consistent numbering in filenames of ADR (2) (#7504) --- ...-parse-study-yml.md => 0020-use-Jackson-to-parse-study-yml.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/adr/{0018-use-Jackson-to-parse-study-yml.md => 0020-use-Jackson-to-parse-study-yml.md} (100%) diff --git a/docs/adr/0018-use-Jackson-to-parse-study-yml.md b/docs/adr/0020-use-Jackson-to-parse-study-yml.md similarity index 100% rename from docs/adr/0018-use-Jackson-to-parse-study-yml.md rename to docs/adr/0020-use-Jackson-to-parse-study-yml.md From d9a755377143f11fcfbaf81b799d99bedc674fb8 Mon Sep 17 00:00:00 2001 From: MLEP Date: Wed, 10 Mar 2021 10:48:58 +0100 Subject: [PATCH 4/8] Keep consistent numbering in filenames of ADR (3) (#7505) --- ...lds.md => 0019-implement-special-fields-as-seperate-fields.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/adr/{0018-implement-special-fields-as-seperate-fields.md => 0019-implement-special-fields-as-seperate-fields.md} (100%) diff --git a/docs/adr/0018-implement-special-fields-as-seperate-fields.md b/docs/adr/0019-implement-special-fields-as-seperate-fields.md similarity index 100% rename from docs/adr/0018-implement-special-fields-as-seperate-fields.md rename to docs/adr/0019-implement-special-fields-as-seperate-fields.md From 5c449944aae85f19daab5daaf8fd19af4196631c Mon Sep 17 00:00:00 2001 From: MLEP Date: Wed, 10 Mar 2021 10:49:04 +0100 Subject: [PATCH 5/8] Keep consistent numbering in filenames of ADR (3) (#7506) --- ...8-use-regular-expression-to-split-multiple-sentence-titles.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/adr/{0017-use-regular-expression-to-split-multiple-sentence-titles.md => 0018-use-regular-expression-to-split-multiple-sentence-titles.md} (100%) diff --git a/docs/adr/0017-use-regular-expression-to-split-multiple-sentence-titles.md b/docs/adr/0018-use-regular-expression-to-split-multiple-sentence-titles.md similarity index 100% rename from docs/adr/0017-use-regular-expression-to-split-multiple-sentence-titles.md rename to docs/adr/0018-use-regular-expression-to-split-multiple-sentence-titles.md From 1c7c8e366d586b637ec23e74f52f1bc4d123a24d Mon Sep 17 00:00:00 2001 From: MLEP Date: Wed, 10 Mar 2021 19:26:55 +0100 Subject: [PATCH 6/8] Add recent ADR to list of ADR (#7511) --- docs/adr.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/adr.md b/docs/adr.md index 61465e4cfb4..eba92a988b2 100644 --- a/docs/adr.md +++ b/docs/adr.md @@ -16,13 +16,14 @@ Architectural decisions for JabRef: * [ADR-0011](https://github.com/JabRef/jabref/tree/master/docs/adr/0011-test-external-links-in-documentation.md) - Test external links in documentation * [ADR-0012](https://github.com/JabRef/jabref/tree/master/docs/adr/0012-handle-different-bibEntry-formats-of-fetchers.md) - Handle different bibentry formats of fetchers by adding a layer * [ADR-0013](https://github.com/JabRef/jabref/tree/master/docs/adr/0013-add-native-support-biblatex-software.md) - Add Native Support for BibLatex-Software - - fix checkstyle in adr - * [ADR-0014](https://github.com/JabRef/jabref/tree/master/docs/adr/0014-separate-URL-creation-to-enable-proper-logging.md) - Separate URL creation to enable proper logging * [ADR-0015](https://github.com/JabRef/jabref/tree/master/docs/adr/0015-support-an-abstract-query-syntax-for-query-conversion.md) - Query syntax design * [ADR-0016](https://github.com/JabRef/jabref/tree/master/docs/adr/0016-mutable-preferences-objects.md) - Mutable preferences objects * [ADR-0017](https://github.com/JabRef/jabref/tree/master/docs/adr/0017-allow-model-access-logic.md) - Allow org.jabref.model to access org.jabref.logic +* [ADR-0018](https://github.com/JabRef/jabref/blob/master/docs/adr/0018-use-regular-expression-to-split-multiple-sentence-titles.md) - Use regular expression to split multiple-sentence titles +* [ADR-0019](https://github.com/JabRef/jabref/blob/master/docs/adr/0019-implement-special-fields-as-seperate-fields.md) - Implement special fields as seperate fields +* [ADR-0020](https://github.com/JabRef/jabref/blob/master/docs/adr/0020-use-Jackson-to-parse-study-yml.md) - Use Jackson to parse study.yml +* [ADR-0021](https://github.com/JabRef/jabref/blob/master/docs/adr/0021-keep-study-as-a-dto.md) - Keep study as a DTO For new ADRs, please use [template.md](https://github.com/JabRef/jabref/tree/master/docs/adr/template.md) as basis. More information on the used format is available at [https://adr.github.io/madr/](https://adr.github.io/madr/). General information about architectural decision records is available at [https://adr.github.io/](https://adr.github.io/). Then add them to the above list. From c7593c920e66c1a1262daaefeab28e3151eadb60 Mon Sep 17 00:00:00 2001 From: Peiqi Yin <60515999+yinpeiqi@users.noreply.github.com> Date: Thu, 11 Mar 2021 02:28:37 +0800 Subject: [PATCH 7/8] fix: fix content selector for custom fields (#7508) * fix: fix for issue 6819 * fix: ViewModelListCellFactory used * fix: remove useless --- CHANGELOG.md | 1 + .../jabref/gui/contentselector/ContentSelectorDialogView.java | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b0901a26fc..5ff8359f425 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,6 +60,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed an issue where a non valid value as font size results in an uncaught exception. [#7415](https://github.com/JabRef/jabref/issues/7415) - We fixed an issue where "Merge citations" in the Openoffice/Libreoffice integration panel did not have a corresponding opposite. [#7454](https://github.com/JabRef/jabref/issues/7454) - We fixed an issue where drag and drop of bib files for opening resulted in uncaught exceptions [#7464](https://github.com/JabRef/jabref/issues/7464) +- We fixed an issue where Content selector does not seem to work for custom fields. [#6819](https://github.com/JabRef/jabref/issues/6819) ### Removed diff --git a/src/main/java/org/jabref/gui/contentselector/ContentSelectorDialogView.java b/src/main/java/org/jabref/gui/contentselector/ContentSelectorDialogView.java index 62832cb51ad..bf5b243a6ea 100644 --- a/src/main/java/org/jabref/gui/contentselector/ContentSelectorDialogView.java +++ b/src/main/java/org/jabref/gui/contentselector/ContentSelectorDialogView.java @@ -16,6 +16,7 @@ import org.jabref.gui.LibraryTab; import org.jabref.gui.util.BaseDialog; import org.jabref.gui.util.ControlHelper; +import org.jabref.gui.util.ViewModelListCellFactory; import org.jabref.logic.l10n.Localization; import org.jabref.model.entry.field.Field; @@ -68,6 +69,9 @@ public void initialize() { private void initFieldNameComponents() { initListView(fieldsListView, viewModel::getFieldNamesBackingList); viewModel.selectedFieldProperty().bind(fieldsListView.getSelectionModel().selectedItemProperty()); + new ViewModelListCellFactory() + .withText(Field::getDisplayName) + .install(fieldsListView); removeFieldNameButton.disableProperty().bind(viewModel.isNoFieldNameSelected()); EasyBind.subscribe(viewModel.selectedFieldProperty(), viewModel::populateKeywords); } From 50ba021ccf53105559b29b4c9b808f35ad46d142 Mon Sep 17 00:00:00 2001 From: Ali Date: Wed, 10 Mar 2021 21:32:18 +0300 Subject: [PATCH 8/8] #6057 Improve startup time (#7486) * check with regex instead of throwing exception * fix NumericFieldComparatorTest * change number validation method * add changes in CHANGELOG.md * fix fails on empty string * add case when only '-' * add NumericFieldComparator for number column only * add case for '+' sign * fix checkstyle * add corner case with '+' * add corner case with '+' --- CHANGELOG.md | 1 + .../gui/maintable/columns/FieldColumn.java | 15 ++++- .../comparator/NumericFieldComparator.java | 67 ++++++++++--------- .../NumericFieldComparatorTest.java | 20 ++++++ 4 files changed, 71 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ff8359f425..a07c4e120d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -97,6 +97,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We changed the title of the window "Manage field names and content": to have the same title as the corresponding menu item [#6895](https://github.com/JabRef/jabref/pull/6895) - We improved the detection of "short" DOIs [6880](https://github.com/JabRef/jabref/issues/6880) - We improved the duplicate detection when identifiers like DOI or arxiv are semantiaclly the same, but just syntactically differ (e.g. with or without http(s):// prefix). [#6707](https://github.com/JabRef/jabref/issues/6707) +- We improved JabRef start up time [6057](https://github.com/JabRef/jabref/issues/6057) - We changed in the group interface "Generate groups from keywords in a BibTeX field" by "Generate groups from keywords in the following field". [#6983](https://github.com/JabRef/jabref/issues/6983) - We changed the name of a group type from "Searching for keywords" to "Searching for a keyword". [6995](https://github.com/JabRef/jabref/pull/6995) - We changed the way JabRef displays the title of a tab and of the window. [4161](https://github.com/JabRef/jabref/issues/4161) diff --git a/src/main/java/org/jabref/gui/maintable/columns/FieldColumn.java b/src/main/java/org/jabref/gui/maintable/columns/FieldColumn.java index 2822f5bce30..aee93952cd7 100644 --- a/src/main/java/org/jabref/gui/maintable/columns/FieldColumn.java +++ b/src/main/java/org/jabref/gui/maintable/columns/FieldColumn.java @@ -6,8 +6,12 @@ import org.jabref.gui.maintable.MainTableColumnModel; import org.jabref.gui.util.ValueTableCellFactory; import org.jabref.gui.util.comparator.NumericFieldComparator; +import org.jabref.model.entry.field.Field; import org.jabref.model.entry.field.FieldFactory; import org.jabref.model.entry.field.OrFields; +import org.jabref.model.entry.field.UnknownField; + +import com.google.common.collect.Iterables; /** * A column that displays the text-value of the field @@ -26,7 +30,16 @@ public FieldColumn(MainTableColumnModel model) { new ValueTableCellFactory() .withText(text -> text) .install(this); - this.setComparator(new NumericFieldComparator()); + + if (fields.size() == 1) { + // comparator can't parse more than one value + Field field = Iterables.getOnlyElement(fields); + + if (field instanceof UnknownField || field.isNumeric()) { + this.setComparator(new NumericFieldComparator()); + } + } + this.setSortable(true); } diff --git a/src/main/java/org/jabref/gui/util/comparator/NumericFieldComparator.java b/src/main/java/org/jabref/gui/util/comparator/NumericFieldComparator.java index 79601439b9c..38dd0d535ab 100644 --- a/src/main/java/org/jabref/gui/util/comparator/NumericFieldComparator.java +++ b/src/main/java/org/jabref/gui/util/comparator/NumericFieldComparator.java @@ -2,6 +2,8 @@ import java.util.Comparator; +import org.jabref.model.strings.StringUtil; + /** * Comparator for numeric cases. The purpose of this class is to add the numeric comparison, because values are sorted * as if they were strings. @@ -10,51 +12,54 @@ public class NumericFieldComparator implements Comparator { @Override public int compare(String val1, String val2) { - // We start by implementing the comparison in the edge cases (if one of the values is null). - if (val1 == null && val2 == null) { - return 0; - } + Integer valInt1 = parseInt(val1); + Integer valInt2 = parseInt(val2); - if (val1 == null) { + if (valInt1 == null && valInt2 == null) { + if (val1 != null && val2 != null) { + return val1.compareTo(val2); + } else { + return 0; + } + } else if (valInt1 == null) { // We assume that "null" is "less than" any other value. return -1; - } - - if (val2 == null) { + } else if (valInt2 == null) { return 1; } - // Now we start the conversion to integers. - Integer valInt1 = null; - Integer valInt2 = null; - try { - // Trim in case the user added an unnecessary white space (e.g. 1 1 instead of 11). - valInt1 = Integer.parseInt(val1.trim()); - } catch (NumberFormatException ignore) { - // do nothing + // If we arrive at this stage then both values are actually numeric ! + return valInt1 - valInt2; + } + + private static Integer parseInt(String number) { + if (!isNumber(number)) { + return null; } + try { - valInt2 = Integer.parseInt(val2.trim()); + return Integer.valueOf(number.trim()); } catch (NumberFormatException ignore) { - // do nothing + return null; } + } - if (valInt1 == null && valInt2 == null) { - // None of the values were parsed (i.e both are not numeric) - // so we will use the normal string comparison. - return val1.compareTo(val2); + private static boolean isNumber(String number) { + if (StringUtil.isNullOrEmpty(number)) { + return false; } - - if (valInt1 == null) { - // We assume that strings "are less" than integers - return -1; + if (number.length() == 1 && (number.charAt(0) == '-' || number.charAt(0) == '+')) { + return false; } - - if (valInt2 == null) { - return 1; + for (int i = 0; i < number.length(); i++) { + char c = number.charAt(i); + if (i == 0 && (c == '-' || c == '+')) { + continue; + } else if (!Character.isDigit(c)) { + return false; + } } - // If we arrive at this stage then both values are actually numeric ! - return valInt1 - valInt2; + return true; } } diff --git a/src/test/java/org/jabref/gui/util/comparator/NumericFieldComparatorTest.java b/src/test/java/org/jabref/gui/util/comparator/NumericFieldComparatorTest.java index 12fcde6059c..be11abf0abe 100644 --- a/src/test/java/org/jabref/gui/util/comparator/NumericFieldComparatorTest.java +++ b/src/test/java/org/jabref/gui/util/comparator/NumericFieldComparatorTest.java @@ -42,4 +42,24 @@ public void compareStringWithInteger() { public void compareIntegerWithString() { assertEquals(1, comparator.compare("4", "hi")); } + + @Test + public void compareNegativeInteger() { + assertEquals(1, comparator.compare("-4", "-5")); + } + + @Test + public void compareWithMinusString() { + assertEquals(-1, comparator.compare("-", "-5")); + } + + @Test + public void compareWithPlusString() { + assertEquals(-1, comparator.compare("+", "-5")); + } + + @Test + public void compareWordWithMinus() { + assertEquals(-1, comparator.compare("-abc", "-5")); + } }