Copy files while merging books
This commit is contained in:
@@ -2884,9 +2884,17 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
|
|||||||
|
|
||||||
public void moveSentences(Chapter from, Chapter to) {
|
public void moveSentences(Chapter from, Chapter to) {
|
||||||
while (from.getChildCount() > 0) {
|
while (from.getChildCount() > 0) {
|
||||||
DefaultMutableTreeNode n = (DefaultMutableTreeNode)from.getFirstChild();
|
try {
|
||||||
from.remove(n);
|
Sentence snt = (Sentence)from.getFirstChild();
|
||||||
to.add(n);
|
File source = snt.getFile();
|
||||||
|
from.remove(snt);
|
||||||
|
to.add(snt);
|
||||||
|
snt.setParentBook(to.getBook());
|
||||||
|
File destination = snt.getFile();
|
||||||
|
Files.copy(source.toPath(), destination.toPath());
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2903,13 +2911,13 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
|
|||||||
while (from.getChildCount() > 0) {
|
while (from.getChildCount() > 0) {
|
||||||
Chapter fc = (Chapter)from.getFirstChild();
|
Chapter fc = (Chapter)from.getFirstChild();
|
||||||
Chapter tc = findChapter(to, fc.getId(), fc.getName());
|
Chapter tc = findChapter(to, fc.getId(), fc.getName());
|
||||||
if (tc != null) {
|
if (tc == null) {
|
||||||
moveSentences(fc, tc);
|
tc = new Chapter(fc.getId(), fc.getName());
|
||||||
from.remove(fc);
|
tc.setParentBook(to);
|
||||||
} else {
|
to.add(tc);
|
||||||
from.remove(fc);
|
|
||||||
to.add(fc);
|
|
||||||
}
|
}
|
||||||
|
moveSentences(fc, tc);
|
||||||
|
from.remove(fc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user