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 6 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
4 changes: 3 additions & 1 deletion src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ 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)) {
} else if (fieldProperties.contains(FieldProperty.SINGLE_ENTRY_LINK)) {
return new LinkedEntriesEditor(field, databaseContext, suggestionProvider, fieldCheckers);
} else if (fieldProperties.contains(FieldProperty.MULTIPLE_ENTRY_LINK)) {
return new LinkedEntriesEditor(field, databaseContext, suggestionProvider, fieldCheckers);
} else if (fieldProperties.contains(FieldProperty.PERSON_NAMES)) {
return new PersonsEditor(field, suggestionProvider, preferences, fieldCheckers, isSingleLine);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,23 @@
import org.jabref.model.entry.field.Field;

import com.airhacks.afterburner.views.ViewLoader;
import org.jabref.model.entry.field.FieldProperty;

public class LinkedEntriesEditor extends HBox implements FieldEditorFX {

@FXML private final LinkedEntriesEditorViewModel viewModel;
@FXML private TagBar<ParsedEntryLink> linkedEntriesBar;
@FXML
private final LinkedEntriesEditorViewModel viewModel;
@FXML
private TagBar<ParsedEntryLink> linkedEntriesBar;

public LinkedEntriesEditor(Field field, BibDatabaseContext databaseContext, AutoCompleteSuggestionProvider<?> suggestionProvider, FieldCheckers fieldCheckers) {
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();
.root(this)
.load();

linkedEntriesBar.allowsMultipleEntries(field.getProperties().contains(FieldProperty.MULTIPLE_ENTRY_LINK));
linkedEntriesBar.setStringConverter(viewModel.getStringConverter());
linkedEntriesBar.setOnTagClicked((parsedEntryLink, mouseEvent) -> viewModel.jumpToEntry(parsedEntryLink));

Expand Down
20 changes: 15 additions & 5 deletions src/main/java/org/jabref/gui/util/component/TagBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,21 @@ public class TagBar<T> extends HBox {

private final ListProperty<T> tags;
private StringConverter<T> stringConverter;
@FXML private TextField inputTextField;
@FXML private HBox tagList;
@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());
tags.addListener(this::onTagsChanged);

// Load FXML
ViewLoader.view(this)
.root(this)
.load();
.root(this)
.load();
getStylesheets().add(0, TagBar.class.getResource("TagBar.css").toExternalForm());
}

Expand Down Expand Up @@ -66,6 +69,9 @@ private void onTagsChanged(ListChangeListener.Change<? extends T> change) {
tagList.getChildren().addAll(change.getFrom(), change.getAddedSubList().stream().map(this::createTag).collect(Collectors.toList()));
}
}
if (!allowsMultiple) {
inputTextField.setDisable(!tags.isEmpty());
}
}

private Tag<T> createTag(T item) {
Expand All @@ -83,7 +89,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)) {
tags.add(newTag);
inputTextField.clear();
}
Expand All @@ -97,4 +103,8 @@ public void setStringConverter(StringConverter<T> stringConverter) {
public void setOnTagClicked(BiConsumer<T, MouseEvent> onTagClicked) {
this.onTagClicked = onTagClicked;
}

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