Skip to content
Snippets Groups Projects

Transfer pane

Merged Petr Bainar requested to merge transferPane into master
All threads resolved!
12 files
+ 323
72
Compare changes
  • Side-by-side
  • Inline
Files
12
 
package cz.it4i.fiji.haas.data_transfer;
package cz.it4i.fiji.haas.data_transfer;
import java.io.BufferedReader;
import java.io.BufferedReader;
@@ -5,8 +6,8 @@ import java.io.BufferedWriter;
@@ -5,8 +6,8 @@ import java.io.BufferedWriter;
import java.io.IOException;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Path;
 
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.LinkedHashSet;
import java.util.Queue;
import java.util.Set;
import java.util.Set;
import java.util.function.Function;
import java.util.function.Function;
@@ -45,10 +46,10 @@ public class PersistentIndex<T> {
@@ -45,10 +46,10 @@ public class PersistentIndex<T> {
indexedFiles.remove(p);
indexedFiles.remove(p);
}
}
public synchronized void fillQueue(Queue<T> toUpload) {
public synchronized Set<T> getIndexedItems() {
toUpload.addAll(indexedFiles);
return Collections.unmodifiableSet(indexedFiles);
}
}
public synchronized void clear() throws IOException {
public synchronized void clear() throws IOException {
indexedFiles.clear();
indexedFiles.clear();
storeToWorkingFile();
storeToWorkingFile();
@@ -60,7 +61,7 @@ public class PersistentIndex<T> {
@@ -60,7 +61,7 @@ public class PersistentIndex<T> {
private void loadFromWorkingFile() throws IOException {
private void loadFromWorkingFile() throws IOException {
indexedFiles.clear();
indexedFiles.clear();
if(Files.exists(workingFile)) {
if (Files.exists(workingFile)) {
try (BufferedReader br = Files.newBufferedReader(workingFile)) {
try (BufferedReader br = Files.newBufferedReader(workingFile)) {
String line;
String line;
while (null != (line = br.readLine())) {
while (null != (line = br.readLine())) {
@@ -74,5 +75,4 @@ public class PersistentIndex<T> {
@@ -74,5 +75,4 @@ public class PersistentIndex<T> {
indexedFiles.add(fromStringConvertor.apply(line));
indexedFiles.add(fromStringConvertor.apply(line));
}
}
}
}
Loading