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

Fix multiple entries allowed in crossref (issue #5284) #5724

Merged
merged 7 commits into from
Dec 15, 2019
Merged
Show file tree
Hide file tree
Changes from 4 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 AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ Jörg Lenhard
Jörg Wegner
Jörg Zieren
Jørgen Kvalsvik
Julien Benard
Jürgen Lange
Kai Mindermann
Kai Takac
Expand All @@ -181,6 +182,7 @@ Li Zhilin
Ling Wang
Linus Dietz
Lorenzo Genta
Lucas Beretti
Julien29121998 marked this conversation as resolved.
Show resolved Hide resolved
Luciana de Melo e Abud
Mairieli Wessel
Malik Atalla
Expand Down Expand Up @@ -317,6 +319,7 @@ Ulrik Stervbo
UltimaBGD
Uwe Kuehn
Valentin Pons
Venceslas Roullier
Victor Figueira
Victor Michelan
Vincent W. Yang
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We fixed an exception which occurred when an invalid jstyle was loaded. [#5452](https://github.com/JabRef/jabref/issues/5452)
- We fixed an issue where the command line arguments `importBibtex` and `importToOpen` did not import into the currently open library, but opened a new one. [#5537](https://github.com/JabRef/jabref/issues/5537)
- We fixed an error where the preview theme did not adapt to the "Dark" mode [#5463](https://github.com/JabRef/jabref/issues/5463)
- We fixed an issue where multiple entries were allowed in the "crossref" field [#5284](https://github.com/JabRef/jabref/issues/5284)
- We fixed an issue where the merge dialog showed the wrong text colour in "Dark" mode [#5516](https://github.com/JabRef/jabref/issues/5516)
- We fixed visibility issues with the scrollbar and group selection highlight in "Dark" mode, and enabled "Dark" mode for the OpenOffice preview in the style selection window. [#5522](https://github.com/JabRef/jabref/issues/5522)
- We fixed an issue where the author field was not correctly parsed during bibtex key-generation. [#5551](https://github.com/JabRef/jabref/issues/5551)
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ public static FieldEditorFX getForField(final Field field,
} else {
return new OptionEditor<>(new TypeEditorViewModel(field, suggestionProvider, fieldCheckers));
}
} else if (fieldProperties.contains(FieldProperty.SINGLE_ENTRY_LINK) || fieldProperties.contains(FieldProperty.MULTIPLE_ENTRY_LINK)) {
return new LinkedEntriesEditor(field, databaseContext, suggestionProvider, fieldCheckers);
} else if (fieldProperties.contains(FieldProperty.SINGLE_ENTRY_LINK)) {
return new LinkedEntriesEditor(field, databaseContext, suggestionProvider, fieldCheckers,false);
Julien29121998 marked this conversation as resolved.
Show resolved Hide resolved
} else if (fieldProperties.contains(FieldProperty.MULTIPLE_ENTRY_LINK)) {
return new LinkedEntriesEditor(field, databaseContext, suggestionProvider, fieldCheckers,true);
} else if (fieldProperties.contains(FieldProperty.PERSON_NAMES)) {
return new PersonsEditor(field, suggestionProvider, preferences, fieldCheckers, isSingleLine);
} else if (StandardField.KEYWORDS.equals(field)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ public class LinkedEntriesEditor extends HBox implements FieldEditorFX {
@FXML private final LinkedEntriesEditorViewModel viewModel;
@FXML private TagBar<ParsedEntryLink> linkedEntriesBar;

public LinkedEntriesEditor(Field field, BibDatabaseContext databaseContext, AutoCompleteSuggestionProvider<?> suggestionProvider, FieldCheckers fieldCheckers) {
public LinkedEntriesEditor(Field field, BibDatabaseContext databaseContext, AutoCompleteSuggestionProvider<?> suggestionProvider, FieldCheckers fieldCheckers, Boolean isMultiple) {
this.viewModel = new LinkedEntriesEditorViewModel(field, suggestionProvider, databaseContext, fieldCheckers);

ViewLoader.view(this)
.root(this)
Copy link
Member

Choose a reason for hiding this comment

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

I think, this indent change is an Eclipse vs. IntelliJ-thing. I won't nitpick here. Next time, please only commit code changes, not just reformat changes.

.load();

linkedEntriesBar.allowsMultipleEntries(isMultiple);
linkedEntriesBar.setStringConverter(viewModel.getStringConverter());
linkedEntriesBar.setOnTagClicked((parsedEntryLink, mouseEvent) -> viewModel.jumpToEntry(parsedEntryLink));

Expand Down
7 changes: 6 additions & 1 deletion src/main/java/org/jabref/gui/util/component/TagBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class TagBar<T> extends HBox {
@FXML private TextField inputTextField;
@FXML private HBox tagList;
private BiConsumer<T, MouseEvent> onTagClicked;
private Boolean allowsMultiple=true;
Julien29121998 marked this conversation as resolved.
Show resolved Hide resolved

public TagBar() {
tags = new SimpleListProperty<>(FXCollections.observableArrayList());
Expand Down Expand Up @@ -62,8 +63,10 @@ private void onTagsChanged(ListChangeListener.Change<? extends T> change) {
while (change.next()) {
if (change.wasRemoved()) {
tagList.getChildren().subList(change.getFrom(), change.getFrom() + change.getRemovedSize()).clear();
if(!allowsMultiple) { inputTextField.setDisable(false);}
Julien29121998 marked this conversation as resolved.
Show resolved Hide resolved
} else if (change.wasAdded()) {
tagList.getChildren().addAll(change.getFrom(), change.getAddedSubList().stream().map(this::createTag).collect(Collectors.toList()));
if(!allowsMultiple) { inputTextField.setDisable(true);}
}
}
}
Expand All @@ -83,7 +86,7 @@ private void addTextAsNewTag(ActionEvent event) {
String inputText = inputTextField.getText();
if (StringUtil.isNotBlank(inputText)) {
T newTag = stringConverter.fromString(inputText);
if ((newTag != null) && !tags.contains(newTag)) {
if ((newTag != null) && !tags.contains(newTag)&&(tags.isEmpty()||this.allowsMultiple)) {
Julien29121998 marked this conversation as resolved.
Show resolved Hide resolved
tags.add(newTag);
inputTextField.clear();
}
Expand All @@ -97,4 +100,6 @@ public void setStringConverter(StringConverter<T> stringConverter) {
public void setOnTagClicked(BiConsumer<T, MouseEvent> onTagClicked) {
this.onTagClicked = onTagClicked;
}

public void allowsMultipleEntries(Boolean isMultiple) { this.allowsMultiple=isMultiple; }
}