Skip to content

Commit

Permalink
Extract Globals.prefs
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasdiez committed Jan 11, 2020
1 parent ddeba75 commit 5b92e4b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/collab/ChangeScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public List<DatabaseChangeViewModel> scanForChanges() {
// Start looking at changes.
BibDatabaseDiff differences = BibDatabaseDiff.compare(database, databaseOnDisk);
differences.getMetaDataDifferences().ifPresent(diff -> {
changes.add(new MetaDataChangeViewModel(diff));
changes.add(new MetaDataChangeViewModel(diff, Globals.prefs));
diff.getGroupDifferences().ifPresent(groupDiff -> changes.add(new GroupChangeViewModel(groupDiff)));
});
differences.getPreambleDifferences().ifPresent(diff -> changes.add(new PreambleChangeViewModel(diff)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@
import org.jabref.logic.bibtex.comparator.MetaDataDiff;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.preferences.JabRefPreferences;

class MetaDataChangeViewModel extends DatabaseChangeViewModel {

private final MetaDataDiff metaDataDiff;
private final JabRefPreferences preferences;

public MetaDataChangeViewModel(MetaDataDiff metaDataDiff) {
public MetaDataChangeViewModel(MetaDataDiff metaDataDiff, JabRefPreferences preferences) {
super(Localization.lang("Metadata change"));
this.metaDataDiff = metaDataDiff;
this.preferences = preferences;
}

@Override
Expand All @@ -26,7 +29,7 @@ public Node description() {
header.getStyleClass().add("sectionHeader");
container.getChildren().add(header);

for (String change : metaDataDiff.getDifferences()) {
for (String change : metaDataDiff.getDifferences(preferences)) {
container.getChildren().add(new Label(change));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import java.util.Objects;
import java.util.Optional;

import org.jabref.Globals;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.metadata.MetaData;
import org.jabref.preferences.JabRefPreferences;

public class MetaDataDiff {

Expand All @@ -32,7 +32,7 @@ public static Optional<MetaDataDiff> compare(MetaData originalMetaData, MetaData
/**
* @implNote Should be kept in sync with {@link MetaData#equals(Object)}
*/
public List<String> getDifferences() {
public List<String> getDifferences(JabRefPreferences preferences) {
List<String> changes = new ArrayList<>();

if (originalMetaData.isProtected() != newMetaData.isProtected()) {
Expand All @@ -47,7 +47,7 @@ public List<String> getDifferences() {
if (!Objects.equals(originalMetaData.getSaveOrderConfig(), newMetaData.getSaveOrderConfig())) {
changes.add(Localization.lang("Save sort order"));
}
if (!Objects.equals(originalMetaData.getCiteKeyPattern(Globals.prefs.getKeyPattern()), newMetaData.getCiteKeyPattern(Globals.prefs.getKeyPattern()))) {
if (!Objects.equals(originalMetaData.getCiteKeyPattern(preferences.getKeyPattern()), newMetaData.getCiteKeyPattern(preferences.getKeyPattern()))) {
changes.add(Localization.lang("Key patterns"));
}
if (!Objects.equals(originalMetaData.getUserFileDirectories(), newMetaData.getUserFileDirectories())) {
Expand Down

0 comments on commit 5b92e4b

Please sign in to comment.