use of org.jabref.model.bibtexkeypattern.GlobalBibtexKeyPattern in project jabref by JabRef.
the class BibtexKeyPatternPanel method getKeyPatternAsGlobalBibtexKeyPattern.
protected GlobalBibtexKeyPattern getKeyPatternAsGlobalBibtexKeyPattern() {
GlobalBibtexKeyPattern res = GlobalBibtexKeyPattern.fromPattern(JabRefPreferences.getInstance().get(JabRefPreferences.DEFAULT_BIBTEX_KEY_PATTERN));
fillPatternUsingPanelData(res);
return res;
}
use of org.jabref.model.bibtexkeypattern.GlobalBibtexKeyPattern in project jabref by JabRef.
the class BibtexKeyPatternPrefTab method storeSettings.
/**
* Store changes to table preferences. This method is called when the user clicks Ok.
*
*/
@Override
public void storeSettings() {
// Set the default value:
Globals.prefs.put(JabRefPreferences.DEFAULT_BIBTEX_KEY_PATTERN, defaultPat.getText());
Globals.prefs.putBoolean(JabRefPreferences.WARN_BEFORE_OVERWRITING_KEY, warnBeforeOverwriting.isSelected());
Globals.prefs.putBoolean(JabRefPreferences.AVOID_OVERWRITING_KEY, dontOverwrite.isSelected());
Globals.prefs.put(JabRefPreferences.KEY_PATTERN_REGEX, keyPatternRegex.getText());
Globals.prefs.put(JabRefPreferences.KEY_PATTERN_REPLACEMENT, keyPatternReplacement.getText());
Globals.prefs.putBoolean(JabRefPreferences.GENERATE_KEYS_AFTER_INSPECTION, autoGenerateOnImport.isSelected());
Globals.prefs.putBoolean(JabRefPreferences.GENERATE_KEYS_BEFORE_SAVING, generateOnSave.isSelected());
if (alwaysAddLetter.isSelected()) {
Globals.prefs.putBoolean(JabRefPreferences.KEY_GEN_ALWAYS_ADD_LETTER, true);
} else if (letterStartA.isSelected()) {
Globals.prefs.putBoolean(JabRefPreferences.KEY_GEN_FIRST_LETTER_A, true);
Globals.prefs.putBoolean(JabRefPreferences.KEY_GEN_ALWAYS_ADD_LETTER, false);
} else {
Globals.prefs.putBoolean(JabRefPreferences.KEY_GEN_FIRST_LETTER_A, false);
Globals.prefs.putBoolean(JabRefPreferences.KEY_GEN_ALWAYS_ADD_LETTER, false);
}
// fetch entries from GUI
GlobalBibtexKeyPattern keypatterns = getKeyPatternAsGlobalBibtexKeyPattern();
// store new patterns globally
prefs.putKeyPattern(keypatterns);
}
use of org.jabref.model.bibtexkeypattern.GlobalBibtexKeyPattern in project jabref by JabRef.
the class MetaDataSerializer method getSerializedStringMap.
/**
* Writes all data in the format <key, serialized data>.
*/
public static Map<String, String> getSerializedStringMap(MetaData metaData, GlobalBibtexKeyPattern globalCiteKeyPattern) {
// First write all meta data except groups
Map<String, List<String>> stringyMetaData = new HashMap<>();
metaData.getSaveOrderConfig().ifPresent(saveOrderConfig -> stringyMetaData.put(MetaData.SAVE_ORDER_CONFIG, saveOrderConfig.getAsStringList()));
metaData.getSaveActions().ifPresent(saveActions -> stringyMetaData.put(MetaData.SAVE_ACTIONS, saveActions.getAsStringList(OS.NEWLINE)));
if (metaData.isProtected()) {
stringyMetaData.put(MetaData.PROTECTED_FLAG_META, Collections.singletonList("true"));
}
stringyMetaData.putAll(serializeCiteKeyPattern(metaData, globalCiteKeyPattern));
metaData.getMode().ifPresent(mode -> stringyMetaData.put(MetaData.DATABASE_TYPE, Collections.singletonList(mode.getAsString())));
metaData.getDefaultFileDirectory().ifPresent(path -> stringyMetaData.put(MetaData.FILE_DIRECTORY, Collections.singletonList(path.trim())));
metaData.getUserFileDirectories().forEach((user, path) -> stringyMetaData.put(MetaData.FILE_DIRECTORY + '-' + user, Collections.singletonList(path.trim())));
for (ContentSelector selector : metaData.getContentSelectorList()) {
stringyMetaData.put(MetaData.SELECTOR_META_PREFIX + selector.getFieldName(), selector.getValues());
}
Map<String, String> serializedMetaData = serializeMetaData(stringyMetaData);
// Write groups if present.
// Skip this if only the root node exists (which is always the AllEntriesGroup).
metaData.getGroups().filter(root -> root.getNumberOfChildren() > 0).ifPresent(root -> serializedMetaData.put(MetaData.GROUPSTREE, serializeGroups(root)));
// finally add all unknown meta data items to the serialization map
Map<String, List<String>> unknownMetaData = metaData.getUnknownMetaData();
for (Map.Entry<String, List<String>> entry : unknownMetaData.entrySet()) {
StringBuilder value = new StringBuilder();
value.append(OS.NEWLINE);
for (String line : entry.getValue()) {
value.append(line.replaceAll(";", "\\\\;") + MetaData.SEPARATOR_STRING + OS.NEWLINE);
}
serializedMetaData.put(entry.getKey(), value.toString());
}
return serializedMetaData;
}
use of org.jabref.model.bibtexkeypattern.GlobalBibtexKeyPattern in project jabref by JabRef.
the class SavePreferences method loadForExportFromPreferences.
public static SavePreferences loadForExportFromPreferences(JabRefPreferences preferences) {
Boolean saveInOriginalOrder = preferences.getBoolean(JabRefPreferences.EXPORT_IN_ORIGINAL_ORDER);
SaveOrderConfig saveOrder = null;
if (!saveInOriginalOrder) {
if (preferences.getBoolean(JabRefPreferences.EXPORT_IN_SPECIFIED_ORDER)) {
saveOrder = preferences.loadExportSaveOrder();
} else {
saveOrder = preferences.loadTableSaveOrder();
}
}
Charset encoding = preferences.getDefaultEncoding();
Boolean makeBackup = preferences.getBoolean(JabRefPreferences.BACKUP);
DatabaseSaveType saveType = DatabaseSaveType.ALL;
Boolean takeMetadataSaveOrderInAccount = false;
Boolean reformatFile = preferences.getBoolean(JabRefPreferences.REFORMAT_FILE_ON_SAVE_AND_EXPORT);
LatexFieldFormatterPreferences latexFieldFormatterPreferences = preferences.getLatexFieldFormatterPreferences();
GlobalBibtexKeyPattern globalCiteKeyPattern = preferences.getKeyPattern();
return new SavePreferences(saveInOriginalOrder, saveOrder, encoding, makeBackup, saveType, takeMetadataSaveOrderInAccount, reformatFile, latexFieldFormatterPreferences, globalCiteKeyPattern);
}
use of org.jabref.model.bibtexkeypattern.GlobalBibtexKeyPattern in project jabref by JabRef.
the class SavePreferences method loadForSaveFromPreferences.
public static SavePreferences loadForSaveFromPreferences(JabRefPreferences preferences) {
Boolean saveInOriginalOrder = false;
SaveOrderConfig saveOrder = null;
Charset encoding = preferences.getDefaultEncoding();
Boolean makeBackup = preferences.getBoolean(JabRefPreferences.BACKUP);
DatabaseSaveType saveType = DatabaseSaveType.ALL;
Boolean takeMetadataSaveOrderInAccount = true;
Boolean reformatFile = preferences.getBoolean(JabRefPreferences.REFORMAT_FILE_ON_SAVE_AND_EXPORT);
LatexFieldFormatterPreferences latexFieldFormatterPreferences = preferences.getLatexFieldFormatterPreferences();
GlobalBibtexKeyPattern globalCiteKeyPattern = preferences.getKeyPattern();
return new SavePreferences(saveInOriginalOrder, saveOrder, encoding, makeBackup, saveType, takeMetadataSaveOrderInAccount, reformatFile, latexFieldFormatterPreferences, globalCiteKeyPattern);
}
Aggregations