Skip to content

Commit

Permalink
[Fix] Add parsed serilization when save settings
Browse files Browse the repository at this point in the history
When loading from existing files or libraries, the parser will set
the serilization of the string constant to the correct value. However,
when editing via the GUI, the serilization was not set and a new
string constant list will be created without the serilization.
This result in the serilization being null and when copying with
the clipboard.

Link to DD2480-Group1#13
  • Loading branch information
JXNCTED committed Mar 1, 2024
1 parent 4dc86bb commit 765cb0e
Showing 1 changed file with 7 additions and 3 deletions.
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 765cb0e

Please sign in to comment.