/**
   * Take a set of filenames. Those with names indicating bib files are opened as such if possible.
   * All other files we will attempt to import into the current database.
   *
   * @param fileNames The names of the files to open.
   * @param dropRow success status for the operation
   */
  private void loadOrImportFiles(String[] fileNames, int dropRow) {

    OpenDatabaseAction openAction = new OpenDatabaseAction(frame, false);
    List<String> notBibFiles = new ArrayList<>();
    List<String> bibFiles = new ArrayList<>();
    for (String fileName : fileNames) {
      // Find the file's extension, if any:
      String extension = "";
      ExternalFileType fileType = null;
      int index = fileName.lastIndexOf('.');
      if ((index >= 0) && (index < fileName.length())) {
        extension = fileName.substring(index + 1).toLowerCase();
      }
      if ("bib".equals(extension)) {
        // we assume that it is a BibTeX file.
        // When a user wants to import something with file extension "bib", but which is not a
        // BibTeX file, he should use "file -> import"
        bibFiles.add(fileName);
        continue;
      }

      fileType = Globals.prefs.getExternalFileTypeByExt(extension);
      /*
       * This is a linkable file. If the user dropped it on an entry, we
       * should offer options for autolinking to this files:
       *
       * TODO we should offer an option to highlight the row the user is on too.
       */
      if ((fileType != null) && (dropRow >= 0)) {

        /*
         * TODO: need to signal if this is a local or autodownloaded
         * file
         */
        boolean local = true;

        /*
         * TODO: make this an instance variable?
         */
        DroppedFileHandler dfh = new DroppedFileHandler(frame, panel);
        dfh.handleDroppedfile(fileName, fileType, local, entryTable, dropRow);

        continue;
      }
      notBibFiles.add(fileName);
    }

    openAction.openFilesAsStringList(bibFiles, true);

    if (!notBibFiles.isEmpty()) {
      String[] toImport = new String[notBibFiles.size()];
      notBibFiles.toArray(toImport);

      // Import into new if entryTable==null, otherwise into current
      // database:
      ImportMenuItem importer = new ImportMenuItem(frame, entryTable == null);
      importer.automatedImport(toImport);
    }
  }