@Override public void action() { try { NamedCompound ce = new NamedCompound(undoText); BibtexEntry[] bes = frame.basePanel().getSelectedEntries(); if (bes == null) { return; } for (BibtexEntry be : bes) { // if (value==null) and then call nullField has been ommited as updatefield also handles // value==null SpecialFieldsUtils.updateField(c, value, be, ce, nullFieldIfValueIsTheSame); } ce.end(); if (ce.hasEdits()) { frame.basePanel().undoManager.addEdit(ce); frame.basePanel().markBaseChanged(); frame.basePanel().updateEntryEditorIfShowing(); String outText; if (nullFieldIfValueIsTheSame) { outText = Localization.lang(doneTextPattern, Integer.toString(bes.length)); } else { outText = Localization.lang(doneTextPattern, value, Integer.toString(bes.length)); } frame.output(outText); } else { // if user does not change anything with his action, we do not do anything either // even no output message } } catch (Throwable ex) { ex.printStackTrace(); } }
@Override public void run() { if (cancelled) { return; } int choice = showDialog(); if (choice != JOptionPane.OK_OPTION) { cancelled = true; return; } CleanupPreset cleanupPreset = presetPanel.getCleanupPreset(); cleanupPreset.storeInPreferences(preferences); if (cleanupPreset.isRenamePDF() && Globals.prefs.getBoolean(JabRefPreferences.AKS_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.AKS_AUTO_NAMING_PDFS_AGAIN, false); } if (answer == JOptionPane.NO_OPTION) { cancelled = 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.undoManager.addEdit(ce); } } }
@Override public void run() { if (cancelled) { return; } int choice = showCleanUpDialog(); if (choice != JOptionPane.OK_OPTION) { cancelled = true; return; } storeSettings(); boolean choiceCleanUpSuperscripts = cleanUpSuperscripts.isSelected(); boolean choiceCleanUpDOI = cleanUpDOI.isSelected(); boolean choiceCleanUpMonth = cleanUpMonth.isSelected(); boolean choiceCleanUpPageNumbers = cleanUpPageNumbers.isSelected(); boolean choiceCleanUpDate = cleanUpDate.isSelected(); boolean choiceCleanUpUpgradeExternalLinks = cleanUpUpgradeExternalLinks.isSelected(); boolean choiceMakePathsRelative = cleanUpMakePathsRelative.isSelected(); boolean choiceRenamePDF = cleanUpRenamePDF.isSelected(); boolean choiceConvertHTML = cleanUpHTML.isSelected(); boolean choiceConvertCase = cleanUpCase.isSelected(); boolean choiceConvertLaTeX = cleanUpLaTeX.isSelected(); boolean choiceConvertUnits = cleanUpUnits.isSelected(); boolean choiceConvertUnicode = cleanUpUnicode.isSelected(); boolean choiceConvertToBiblatex = cleanUpBibLatex.isSelected(); if (choiceRenamePDF && Globals.prefs.getBoolean(CleanUpAction.AKS_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(CleanUpAction.AKS_AUTO_NAMING_PDFS_AGAIN, false); } if (answer == JOptionPane.NO_OPTION) { cancelled = true; return; } } // first upgrade the external links // we have to use it separately as the Utils function generates a separate Named Compound if (choiceCleanUpUpgradeExternalLinks) { NamedCompound ce = Util.upgradePdfPsToFile( Arrays.asList(panel.getSelectedEntries()), new String[] {"pdf", "ps"}); if (ce.hasEdits()) { panel.undoManager.addEdit(ce); panel.markBaseChanged(); panel.updateEntryEditorIfShowing(); panel.output(Localization.lang("Upgraded links.")); } } for (BibtexEntry entry : panel.getSelectedEntries()) { // undo granularity is on entry level NamedCompound ce = new NamedCompound(Localization.lang("Cleanup entry")); if (choiceCleanUpSuperscripts) { doCleanUpSuperscripts(entry, ce); } if (choiceCleanUpDOI) { doCleanUpDOI(entry, ce); } if (choiceCleanUpMonth) { doCleanUpMonth(entry, ce); } if (choiceCleanUpPageNumbers) { doCleanUpPageNumbers(entry, ce); } if (choiceCleanUpDate) { doCleanUpDate(entry, ce); } fixWrongFileEntries(entry, ce); if (choiceMakePathsRelative) { doMakePathsRelative(entry, ce); } if (choiceRenamePDF) { doRenamePDFs(entry, ce); } if (choiceConvertHTML) { doConvertHTML(entry, ce); } if (choiceConvertUnits) { doConvertUnits(entry, ce); } if (choiceConvertCase) { doConvertCase(entry, ce); } if (choiceConvertLaTeX) { doConvertLaTeX(entry, ce); } if (choiceConvertUnicode) { doConvertUnicode(entry, ce); } if (choiceConvertToBiblatex) { convertToBiblatex(entry, ce); } ce.end(); if (ce.hasEdits()) { modifiedEntriesCount++; panel.undoManager.addEdit(ce); } } }