예제 #1
0
  @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);
      }
    }
  }
예제 #2
0
 public CleanupAction(BasePanel panel, JabRefPreferences preferences) {
   this.panel = panel;
   this.frame = panel.frame();
   this.preferences = Objects.requireNonNull(preferences);
   this.presetPanel = new CleanupPresetPanel(CleanupPreset.loadFromPreferences(preferences));
 }