Search in sources :

Example 1 with SaveOrderConfig

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);
}
Also used : Charset(java.nio.charset.Charset) SaveOrderConfig(org.jabref.model.metadata.SaveOrderConfig)

Example 2 with SaveOrderConfig

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);
}
Also used : GlobalBibtexKeyPattern(org.jabref.model.bibtexkeypattern.GlobalBibtexKeyPattern) Charset(java.nio.charset.Charset) LatexFieldFormatterPreferences(org.jabref.logic.bibtex.LatexFieldFormatterPreferences) SaveOrderConfig(org.jabref.model.metadata.SaveOrderConfig)

Example 3 with SaveOrderConfig

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);
}
Also used : GlobalBibtexKeyPattern(org.jabref.model.bibtexkeypattern.GlobalBibtexKeyPattern) Charset(java.nio.charset.Charset) LatexFieldFormatterPreferences(org.jabref.logic.bibtex.LatexFieldFormatterPreferences) SaveOrderConfig(org.jabref.model.metadata.SaveOrderConfig)

Example 4 with SaveOrderConfig

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;
}
Also used : SaveOrderConfig(org.jabref.model.metadata.SaveOrderConfig)

Example 5 with 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();
    }
}
Also used : Charset(java.nio.charset.Charset) SaveOrderConfig(org.jabref.model.metadata.SaveOrderConfig)

Aggregations

SaveOrderConfig (org.jabref.model.metadata.SaveOrderConfig)11 Charset (java.nio.charset.Charset)4 Test (org.junit.Test)3 LatexFieldFormatterPreferences (org.jabref.logic.bibtex.LatexFieldFormatterPreferences)2 GlobalBibtexKeyPattern (org.jabref.model.bibtexkeypattern.GlobalBibtexKeyPattern)2 StringReader (java.io.StringReader)1 ArrayList (java.util.ArrayList)1 Comparator (java.util.Comparator)1 BibtexStringComparator (org.jabref.logic.bibtex.comparator.BibtexStringComparator)1 CrossRefEntryComparator (org.jabref.logic.bibtex.comparator.CrossRefEntryComparator)1 FieldComparator (org.jabref.logic.bibtex.comparator.FieldComparator)1 IdComparator (org.jabref.logic.bibtex.comparator.IdComparator)1 ParserResult (org.jabref.logic.importer.ParserResult)1 BibEntry (org.jabref.model.entry.BibEntry)1