Skip to content

Commit

Permalink
Merge pull request #14 from DD2480-Group1/issue-13/null-when-copying
Browse files Browse the repository at this point in the history
[Fix] Fix Null when copying
  • Loading branch information
andersblomqvist authored Mar 2, 2024
2 parents 5e98a05 + 765cb0e commit ea946c4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/main/java/org/jabref/gui/ClipBoardManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,11 @@ public void setContent(List<BibEntry> entries, BibEntryTypesManager entryTypesMa
final ClipboardContent content = new ClipboardContent();
BibEntryWriter writer = new BibEntryWriter(new FieldWriter(preferencesService.getFieldPreferences()), entryTypesManager);
StringBuilder builder = new StringBuilder();
stringConstants.forEach(strConst -> builder.append(strConst.getParsedSerialization()));
for (BibtexString strConst : stringConstants) {
if (strConst.getParsedSerialization() != null) {
builder.append(strConst.getParsedSerialization());
}
}
String serializedEntries = writer.serializeAll(entries, BibDatabaseMode.BIBTEX);
builder.append(serializedEntries);
// BibEntry is not Java serializable. Thus, we need to do the serialization manually
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jabref.gui.libraryproperties.constants;

import java.util.Comparator;
import java.util.List;
import java.util.Locale;
import java.util.Optional;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -86,9 +87,12 @@ private ConstantsItemModel convertFromBibTexString(BibtexString bibtexString) {

@Override
public void storeSettings() {
databaseContext.getDatabase().setStrings(stringsListProperty.stream()
.map(this::fromBibtexStringViewModel)
.collect(Collectors.toList()));
List<BibtexString> strings = stringsListProperty.stream()
.map(this::fromBibtexStringViewModel)
.toList();
strings.forEach(string -> string.setParsedSerialization("@String{" +
string.getName() + " = " + string.getContent() + "}\n"));
databaseContext.getDatabase().setStrings(strings);
}

private BibtexString fromBibtexStringViewModel(ConstantsItemModel viewModel) {
Expand Down

0 comments on commit ea946c4

Please sign in to comment.