public String createNewDiff() {
    // TODO(cblichmann): Remove code duplication with DirectoryDiffImplementation.

    setDescription("Creating destination directory...");
    if (!destinationDirectory.isDirectory() && !destinationDirectory.mkdirs()) {
      logger.atSevere().log("Could not create destination directory");
      CMessageBox.showError(parentWindow, "Could not create destination directory.");
      return null;
    }

    String primaryTargetName = createUniqueExportFileName(ESide.PRIMARY);
    String secondaryTargetName = createUniqueExportFileName(ESide.SECONDARY);

    // Export or copy primary side
    if (primaryIdbFile != null) {
      logger.atInfo().log(
          "- Exporting primary IDB '%s' to '%s'",
          primaryIdbFile.getPath(), destinationDirectory.getPath());

      setDescription("Exporting primary IDB...");
      if (!exportSingleIdb(primaryIdbFile, destinationDirectory, primaryTargetName)) {
        return null;
      }
    } else if (primaryBinExportFile != null) {
      setDescription("Copying primary BinExport binary...");
      primaryBinExportFile =
          copyBinExport(primaryBinExportFile, destinationDirectory, primaryTargetName);
      if (primaryBinExportFile == null) {
        return null;
      }
    }

    // Export or copy secondary side
    if (secondaryIdbFile != null) {
      logger.atInfo().log(
          "- Exporting secondary IDB '%s' to '%s'",
          secondaryIdbFile.getPath(), destinationDirectory.getPath());

      setDescription("Exporting secondary IDB...");
      if (!exportSingleIdb(secondaryIdbFile, destinationDirectory, secondaryTargetName)) {
        return null;
      }
    } else if (secondaryBinExportFile != null) {
      setDescription("Copying secondary BinExport binary...");
      secondaryBinExportFile =
          copyBinExport(secondaryBinExportFile, destinationDirectory, secondaryTargetName);
      if (secondaryBinExportFile == null) {
        return null;
      }
    }

    // Perform the actual diff
    try {
      // Use the original file base names instead of createUniqueExportFileName().
      String primaryBinExportPath =
          primaryIdbFile != null
              ? ExportProcess.getExportFilename(primaryTargetName, destinationDirectory)
              : primaryBinExportFile.getPath();
      String secondaryBinExportPath =
          secondaryIdbFile != null
              ? ExportProcess.getExportFilename(secondaryTargetName, destinationDirectory)
              : secondaryBinExportFile.getPath();

      setDescription("Diffing...");
      logger.atInfo().log("- Diffing '%s'", destinationDirectory.getName());

      DiffProcess.getBinDiffFilename(primaryBinExportPath, secondaryBinExportPath);
      DiffProcess.startDiffProcess(
          ExternalAppUtils.getBinDiffEngine(),
          primaryBinExportPath,
          secondaryBinExportPath,
          destinationDirectory);
      String diffBinaryPath =
          DiffProcess.getBinDiffFilename(primaryBinExportPath, secondaryBinExportPath);

      logger.atInfo().log("- Diffing done successfully");
      return diffBinaryPath;
    } catch (DifferException | FileNotFoundException | RuntimeException e) {
      logger.atSevere().withCause(e).log("%s", e.getMessage());
      CMessageBox.showError(parentWindow, e.getMessage());
    }
    return null;
  }
Class NewDiffImplementation implements the UI flow for adding new .BinDiff results to the
workspace.
java/ui/src/main/java/com/google/security/zynamics/bindiff/gui/tabpanels/projecttabpanel/implementations/NewDiffImplementation.java