@Override public void update() { if (cancelled) { frame.unblock(); return; } if (unsuccessfulRenames > 0) { // Rename failed for at least one entry JOptionPane.showMessageDialog( frame, Localization.lang( "File rename failed for %0 entries.", Integer.toString(unsuccessfulRenames)), Localization.lang("Autogenerate PDF Names"), JOptionPane.INFORMATION_MESSAGE); } if (modifiedEntriesCount > 0) { panel.updateEntryEditorIfShowing(); panel.markBaseChanged(); } String message; switch (modifiedEntriesCount) { case 0: message = Localization.lang("No entry needed a clean up"); break; case 1: message = Localization.lang("One entry needed a clean up"); break; default: message = Localization.lang( "%0 entries needed a clean up", Integer.toString(modifiedEntriesCount)); break; } panel.output(message); frame.unblock(); }
@Override public void actionPerformed(ActionEvent evt) { final List<BibEntry> entries = panel.getSelectedEntries(); // if an editor is showing, its fields must be updated after the assignment, // and before that, the current edit has to be stored: panel.storeCurrentEdit(); NamedCompound undoAll = new NamedCompound(Localization.lang("change assignment of entries")); if (move) { moveToGroup(entries, undoAll); } else { addToGroup(entries, undoAll); } undoAll.end(); panel.getUndoManager().addEdit(undoAll); panel.markBaseChanged(); panel.updateEntryEditorIfShowing(); panel.getGroupSelector().valueChanged(null); }
@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); } } }