@FXML public void cancel() { if (fileCountCrawler != null) { if (fileCountCrawler.cancel()) { wizard.gotoWelcomeScreen(); } else { // TODO use log instead of sout } } }
/** * Count the number of files to hash in both file systems and compute the sum of each file size in * bytes */ public void countFiles() { List<HashProject> hashProjectList = wizard.getHashProjectList(); List<FileSystemInput> inputList = new ArrayList<>(); hashProjectList .stream() .forEach(hashProject -> inputList.add(hashProject.getFileSystemInput())); fileCountCrawler = new FileCountCrawler(inputList); // Bind file count fileCountPreparationLabel .textProperty() .bind(Bindings.convert(fileCountCrawler.fileCountProperty())); // Bind byte count fileCountCrawler .getByteCountProperty() .addListener((observable, oldValue, newValue) -> updateByteCount(newValue)); // When this is done, hash the files fileCountCrawler.setOnSucceeded( (WorkerStateEvent event) -> { wizard.setByteCount(fileCountCrawler.getByteCount()); wizard.setFileCount(fileCountCrawler.getFileCount()); wizard.gotoHashGeneration(); }); fileCountCrawler.start(); }