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

update 2021.3.11 #5

Merged
merged 8 commits into from
Mar 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -59,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

Expand Down Expand Up @@ -95,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)
Expand Down
7 changes: 4 additions & 3 deletions docs/adr.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

4 changes: 4 additions & 0 deletions src/main/java/org/jabref/gui/Base.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -68,6 +69,9 @@ public void initialize() {
private void initFieldNameComponents() {
initListView(fieldsListView, viewModel::getFieldNamesBackingList);
viewModel.selectedFieldProperty().bind(fieldsListView.getSelectionModel().selectedItemProperty());
new ViewModelListCellFactory<Field>()
.withText(Field::getDisplayName)
.install(fieldsListView);
removeFieldNameButton.disableProperty().bind(viewModel.isNoFieldNameSelected());
EasyBind.subscribe(viewModel.selectedFieldProperty(), viewModel::populateKeywords);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {

Expand Down Expand Up @@ -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");
Expand All @@ -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");

Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/icon/IconTheme.java
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
15 changes: 14 additions & 1 deletion src/main/java/org/jabref/gui/maintable/columns/FieldColumn.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -26,7 +30,16 @@ public FieldColumn(MainTableColumnModel model) {
new ValueTableCellFactory<BibEntryTableViewModel, String>()
.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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -10,51 +12,54 @@ public class NumericFieldComparator implements Comparator<String> {

@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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
}