-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin' into all-fields
# Conflicts: # src/main/java/net/sf/jabref/gui/GenFieldsCustomizer.java # src/main/java/net/sf/jabref/gui/entryeditor/EntryEditor.java # src/main/resources/l10n/JabRef_da.properties # src/main/resources/l10n/JabRef_de.properties # src/main/resources/l10n/JabRef_en.properties # src/main/resources/l10n/JabRef_es.properties # src/main/resources/l10n/JabRef_fa.properties # src/main/resources/l10n/JabRef_fr.properties # src/main/resources/l10n/JabRef_in.properties # src/main/resources/l10n/JabRef_it.properties # src/main/resources/l10n/JabRef_ja.properties # src/main/resources/l10n/JabRef_nl.properties # src/main/resources/l10n/JabRef_no.properties # src/main/resources/l10n/JabRef_pt_BR.properties # src/main/resources/l10n/JabRef_ru.properties # src/main/resources/l10n/JabRef_tr.properties # src/main/resources/l10n/JabRef_vi.properties # src/main/resources/l10n/JabRef_zh.properties
- Loading branch information
Showing
382 changed files
with
6,105 additions
and
7,694 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
* JabRef version (available in the About box): | ||
* Operation system and version: | ||
* Steps to reproduce: | ||
1. ... | ||
2. ... | ||
3. ... | ||
* If applicable, excerpt of the bibliography file, screenshot, and excerpt of log (available in the error console) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
- [ ] Change in CHANGELOG.md described? | ||
- [ ] Changes in pull request outlined? (What, why, ...) | ||
- [ ] Tests created for changes? | ||
- [ ] Tests green? |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package net.sf.jabref; | ||
|
||
import java.util.*; | ||
import java.util.stream.Collectors; | ||
|
||
public class JabRefPreferencesFilter { | ||
|
||
private final JabRefPreferences preferences; | ||
|
||
public JabRefPreferencesFilter(JabRefPreferences preferences) { | ||
this.preferences = preferences; | ||
} | ||
|
||
public List<PreferenceOption> getPreferenceOptions() { | ||
Map<String, Object> defaults = new HashMap<>(preferences.defaults); | ||
Map<String, Object> prefs = preferences.getPreferences(); | ||
|
||
return prefs.entrySet().stream() | ||
.map(entry -> new PreferenceOption(entry.getKey(), entry.getValue(), defaults.get(entry.getKey()))) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
public List<PreferenceOption> getDeviatingPreferences() { | ||
return getPreferenceOptions().stream() | ||
.filter(PreferenceOption::isChanged) | ||
.sorted() | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
public enum PreferenceType { | ||
BOOLEAN, INTEGER, STRING | ||
} | ||
|
||
public static class PreferenceOption implements Comparable<PreferenceOption> { | ||
|
||
private final String key; | ||
private final Object value; | ||
private final Optional<Object> defaultValue; | ||
private final PreferenceType type; | ||
|
||
public PreferenceOption(String key, Object value, Object defaultValue) { | ||
this.key = Objects.requireNonNull(key); | ||
this.value = Objects.requireNonNull(value); | ||
this.defaultValue = Optional.ofNullable(defaultValue); | ||
this.type = Objects.requireNonNull(getType(value)); | ||
|
||
if ((defaultValue != null) && !Objects.equals(this.type, getType(defaultValue))) { | ||
throw new IllegalStateException("types must match between default value and value"); | ||
} | ||
} | ||
|
||
private PreferenceType getType(Object value) { | ||
if (value instanceof Boolean) { | ||
return PreferenceType.BOOLEAN; | ||
} else if (value instanceof Integer) { | ||
return PreferenceType.INTEGER; | ||
} else { | ||
return PreferenceType.STRING; | ||
} | ||
} | ||
|
||
public boolean isUnchanged() { | ||
return Objects.equals(value, defaultValue.orElse(null)); | ||
} | ||
|
||
public boolean isChanged() { | ||
return !isUnchanged(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("%s: %s=%s (%s)", type, key, value, defaultValue.orElse("NULL")); | ||
} | ||
|
||
public String getKey() { | ||
return key; | ||
} | ||
|
||
public Object getValue() { | ||
return value; | ||
} | ||
|
||
public Optional<Object> getDefaultValue() { | ||
return defaultValue; | ||
} | ||
|
||
public PreferenceType getType() { | ||
return type; | ||
} | ||
|
||
@Override | ||
public int compareTo(PreferenceOption o) { | ||
return Objects.compare(this.key, o.key, String::compareTo); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.