Search in sources :

Example 1 with CleanupPresetPanel

use of org.jabref.gui.cleanup.CleanupPresetPanel in project jabref by JabRef.

the class CleanupAction method run.

@Override
public void run() {
    if (canceled) {
        return;
    }
    CleanupPresetPanel presetPanel = new CleanupPresetPanel(panel.getBibDatabaseContext(), CleanupPreset.loadFromPreferences(preferences));
    int choice = showDialog(presetPanel);
    if (choice != JOptionPane.OK_OPTION) {
        canceled = true;
        return;
    }
    CleanupPreset cleanupPreset = presetPanel.getCleanupPreset();
    cleanupPreset.storeInPreferences(preferences);
    if (cleanupPreset.isRenamePDF() && Globals.prefs.getBoolean(JabRefPreferences.ASK_AUTO_NAMING_PDFS_AGAIN)) {
        CheckBoxMessage cbm = new CheckBoxMessage(Localization.lang("Auto-generating PDF-Names does not support undo. Continue?"), Localization.lang("Disable this confirmation dialog"), false);
        int answer = JOptionPane.showConfirmDialog(frame, cbm, Localization.lang("Autogenerate PDF Names"), JOptionPane.YES_NO_OPTION);
        if (cbm.isSelected()) {
            Globals.prefs.putBoolean(JabRefPreferences.ASK_AUTO_NAMING_PDFS_AGAIN, false);
        }
        if (answer == JOptionPane.NO_OPTION) {
            canceled = true;
            return;
        }
    }
    for (BibEntry entry : panel.getSelectedEntries()) {
        // undo granularity is on entry level
        NamedCompound ce = new NamedCompound(Localization.lang("Cleanup entry"));
        doCleanup(cleanupPreset, entry, ce);
        ce.end();
        if (ce.hasEdits()) {
            modifiedEntriesCount++;
            panel.getUndoManager().addEdit(ce);
        }
    }
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) NamedCompound(org.jabref.gui.undo.NamedCompound) CheckBoxMessage(org.jabref.gui.util.component.CheckBoxMessage) CleanupPreset(org.jabref.logic.cleanup.CleanupPreset) CleanupPresetPanel(org.jabref.gui.cleanup.CleanupPresetPanel)

Aggregations

CleanupPresetPanel (org.jabref.gui.cleanup.CleanupPresetPanel)1 NamedCompound (org.jabref.gui.undo.NamedCompound)1 CheckBoxMessage (org.jabref.gui.util.component.CheckBoxMessage)1 CleanupPreset (org.jabref.logic.cleanup.CleanupPreset)1 BibEntry (org.jabref.model.entry.BibEntry)1