예제 #1
0
 /**
  * Check the database to find out whether any of a set of fields are used for any of the entries.
  *
  * @param database The bib database.
  * @param fields The set of fields to look for.
  * @return true if at least one of the given fields is set in at least one entry, false otherwise.
  */
 private boolean linksFound(BibtexDatabase database, String[] fields) {
   for (BibtexEntry entry : database.getEntries()) {
     for (String field : fields) {
       if (entry.getField(field) != null) {
         return true;
       }
     }
   }
   return false;
 }
예제 #2
0
  public void init() {

    // Get entries and check if it makes sense to perform this operation
    entries = panel.getSelectedEntries();

    if (entries.length == 0) {

      database = panel.getDatabase();
      entries = database.getEntries().toArray(new BibtexEntry[] {});

      if (entries.length == 0) {

        JOptionPane.showMessageDialog(
            panel,
            Globals.lang("This operation requires at least one entry."),
            Globals.lang("Write XMP-metadata"),
            JOptionPane.ERROR_MESSAGE);
        goOn = false;
        return;

      } else {

        int response =
            JOptionPane.showConfirmDialog(
                panel,
                Globals.lang("Write XMP-metadata for all PDFs in current database?"),
                Globals.lang("Write XMP-metadata"),
                JOptionPane.YES_NO_CANCEL_OPTION,
                JOptionPane.QUESTION_MESSAGE);

        if (response != JOptionPane.YES_OPTION) {
          goOn = false;
          return;
        }
      }
    }

    errors = entriesChanged = skipped = 0;

    if (optDiag == null) {
      optDiag = new OptionsDialog(panel.frame().getFrame());
    }
    optDiag.open();

    panel.output(Globals.lang("Writing XMP metadata..."));
  }