use of org.jabref.model.metadata.SaveOrderConfig in project jabref by JabRef.
the class DatabasePropertiesDialog method setValues.
private void setValues() {
Optional<Charset> charset = panel.getBibDatabaseContext().getMetaData().getEncoding();
encoding.setSelectedItem(charset.orElse(Globals.prefs.getDefaultEncoding()));
Optional<SaveOrderConfig> storedSaveOrderConfig = metaData.getSaveOrderConfig();
boolean selected;
if (!storedSaveOrderConfig.isPresent()) {
saveInOriginalOrder.setSelected(true);
oldSaveOrderConfig = SaveOrderConfig.getDefaultSaveOrder();
selected = false;
} else {
SaveOrderConfig saveOrderConfig = storedSaveOrderConfig.get();
oldSaveOrderConfig = saveOrderConfig;
if (saveOrderConfig.saveInOriginalOrder) {
saveInOriginalOrder.setSelected(true);
selected = false;
} else {
saveInSpecifiedOrder.setSelected(true);
selected = true;
}
saveOrderPanel.setSaveOrderConfig(saveOrderConfig);
}
saveOrderPanel.setEnabled(selected);
Optional<String> fileD = metaData.getDefaultFileDirectory();
if (fileD.isPresent()) {
fileDir.setText(fileD.get().trim());
} else {
fileDir.setText("");
}
// File dir setting
String fileDI = metaData.getUserFileDirectory(Globals.prefs.getUser()).orElse("");
fileDirIndv.setText(fileDI);
oldFileIndvVal = fileDirIndv.getText();
protect.setSelected(metaData.isProtected());
// Store original values to see if they get changed:
oldFileVal = fileDir.getText();
oldProtectVal = protect.isSelected();
//set save actions
fieldFormatterCleanupsPanel.setValues(metaData);
}
use of org.jabref.model.metadata.SaveOrderConfig 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.metadata.SaveOrderConfig 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);
}
use of org.jabref.model.metadata.SaveOrderConfig in project jabref by JabRef.
the class SaveOrderConfigDisplay method getSaveOrderConfig.
public SaveOrderConfig getSaveOrderConfig() {
SaveOrderConfig saveOrderConfig = new SaveOrderConfig();
saveOrderConfig.sortCriteria[0].field = getSelectedItemAsLowerCaseTrim(savePriSort);
saveOrderConfig.sortCriteria[0].descending = savePriDesc.isSelected();
saveOrderConfig.sortCriteria[1].field = getSelectedItemAsLowerCaseTrim(saveSecSort);
saveOrderConfig.sortCriteria[1].descending = saveSecDesc.isSelected();
saveOrderConfig.sortCriteria[2].field = getSelectedItemAsLowerCaseTrim(saveTerSort);
saveOrderConfig.sortCriteria[2].descending = saveTerDesc.isSelected();
return saveOrderConfig;
}
use of org.jabref.model.metadata.SaveOrderConfig in project jabref by JabRef.
the class DatabasePropertiesDialog method storeSettings.
private void storeSettings() {
Charset oldEncoding = panel.getBibDatabaseContext().getMetaData().getEncoding().orElse(Globals.prefs.getDefaultEncoding());
Charset newEncoding = (Charset) encoding.getSelectedItem();
panel.getBibDatabaseContext().getMetaData().setEncoding(newEncoding);
String text = fileDir.getText().trim();
if (text.isEmpty()) {
metaData.clearDefaultFileDirectory();
} else {
metaData.setDefaultFileDirectory(text);
}
// Repeat for individual file dir - reuse 'text' and 'dir' vars
text = fileDirIndv.getText();
if (text.isEmpty()) {
metaData.clearUserFileDirectory(Globals.prefs.getUser());
} else {
metaData.setUserFileDirectory(Globals.prefs.getUser(), text);
}
if (protect.isSelected()) {
metaData.markAsProtected();
} else {
metaData.markAsNotProtected();
}
SaveOrderConfig newSaveOrderConfig;
if (saveInOriginalOrder.isSelected()) {
newSaveOrderConfig = SaveOrderConfig.getDefaultSaveOrder();
} else {
newSaveOrderConfig = saveOrderPanel.getSaveOrderConfig();
newSaveOrderConfig.setSaveInSpecifiedOrder();
}
// See if any of the values have been modified:
boolean saveOrderConfigChanged;
if (newSaveOrderConfig.equals(oldSaveOrderConfig)) {
saveOrderConfigChanged = false;
} else {
saveOrderConfigChanged = true;
}
if (saveOrderConfigChanged) {
if (newSaveOrderConfig.equals(SaveOrderConfig.getDefaultSaveOrder())) {
metaData.clearSaveOrderConfig();
} else {
metaData.setSaveOrderConfig(newSaveOrderConfig);
}
}
boolean saveActionsChanged = fieldFormatterCleanupsPanel.hasChanged();
if (saveActionsChanged) {
if (fieldFormatterCleanupsPanel.isDefaultSaveActions()) {
metaData.clearSaveActions();
} else {
fieldFormatterCleanupsPanel.storeSettings(metaData);
}
}
boolean changed = saveOrderConfigChanged || !newEncoding.equals(oldEncoding) || !oldFileVal.equals(fileDir.getText()) || !oldFileIndvVal.equals(fileDirIndv.getText()) || (oldProtectVal != protect.isSelected()) || saveActionsChanged;
// change marking:
if (changed) {
panel.markNonUndoableBaseChanged();
}
}
Aggregations