use of org.jabref.logic.cleanup.CleanupPreset 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);
}
}
}
use of org.jabref.logic.cleanup.CleanupPreset in project jabref by JabRef.
the class CleanupPresetPanel method getCleanupPreset.
public CleanupPreset getCleanupPreset() {
Set<CleanupPreset.CleanupStep> activeJobs = EnumSet.noneOf(CleanupPreset.CleanupStep.class);
if (cleanUpMovePDF.isSelected()) {
activeJobs.add(CleanupPreset.CleanupStep.MOVE_PDF);
}
if (cleanUpDOI.isSelected()) {
activeJobs.add(CleanupPreset.CleanupStep.CLEAN_UP_DOI);
}
if (cleanUpISSN.isSelected()) {
activeJobs.add(CleanupPreset.CleanupStep.CLEAN_UP_ISSN);
}
if (cleanUpMakePathsRelative.isSelected()) {
activeJobs.add(CleanupPreset.CleanupStep.MAKE_PATHS_RELATIVE);
}
if (cleanUpRenamePDF.isSelected()) {
if (cleanUpRenamePDFonlyRelativePaths.isSelected()) {
activeJobs.add(CleanupPreset.CleanupStep.RENAME_PDF_ONLY_RELATIVE_PATHS);
} else {
activeJobs.add(CleanupPreset.CleanupStep.RENAME_PDF);
}
}
if (cleanUpUpgradeExternalLinks.isSelected()) {
activeJobs.add(CleanupPreset.CleanupStep.CLEAN_UP_UPGRADE_EXTERNAL_LINKS);
}
if (cleanUpBiblatex.isSelected()) {
activeJobs.add(CleanupPreset.CleanupStep.CONVERT_TO_BIBLATEX);
}
activeJobs.add(CleanupPreset.CleanupStep.FIX_FILE_LINKS);
cleanupPreset = new CleanupPreset(activeJobs, cleanUpFormatters.getFormatterCleanups());
return cleanupPreset;
}
use of org.jabref.logic.cleanup.CleanupPreset in project jabref by JabRef.
the class JabRefPreferences method insertDefaultCleanupPreset.
private static void insertDefaultCleanupPreset(Map<String, Object> storage) {
EnumSet<CleanupPreset.CleanupStep> deactivedJobs = EnumSet.of(CleanupPreset.CleanupStep.CLEAN_UP_UPGRADE_EXTERNAL_LINKS, CleanupPreset.CleanupStep.RENAME_PDF_ONLY_RELATIVE_PATHS, CleanupPreset.CleanupStep.CONVERT_TO_BIBLATEX);
CleanupPreset preset = new CleanupPreset(EnumSet.complementOf(deactivedJobs), Cleanups.DEFAULT_SAVE_ACTIONS);
storage.put(CLEANUP_DOI, preset.isCleanUpDOI());
storage.put(CLEANUP_ISSN, preset.isCleanUpISSN());
storage.put(CLEANUP_MOVE_PDF, preset.isMovePDF());
storage.put(CLEANUP_MAKE_PATHS_RELATIVE, preset.isMakePathsRelative());
storage.put(CLEANUP_RENAME_PDF, preset.isRenamePDF());
storage.put(CLEANUP_RENAME_PDF_ONLY_RELATIVE_PATHS, preset.isRenamePdfOnlyRelativePaths());
storage.put(CLEANUP_UPGRADE_EXTERNAL_LINKS, preset.isCleanUpUpgradeExternalLinks());
storage.put(CLEANUP_CONVERT_TO_BIBLATEX, preset.isConvertToBiblatex());
storage.put(CLEANUP_FIX_FILE_LINKS, preset.isFixFileLinks());
storage.put(CLEANUP_FORMATTERS, convertListToString(preset.getFormatterCleanups().getAsStringList(OS.NEWLINE)));
}
Aggregations