Fix reload tree on split and cut operations
This commit is contained in:
@@ -3718,8 +3718,12 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
|
|||||||
|
|
||||||
public void doSplit(int at) {
|
public void doSplit(int at) {
|
||||||
try {
|
try {
|
||||||
Sentence newSentence = selectedSentence.cloneSentence();
|
if (selectedSentence == null) {
|
||||||
|
System.err.println("Selected sentence is NULL in split. That CANNOT happen!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
Chapter c = (Chapter)selectedSentence.getParent();
|
Chapter c = (Chapter)selectedSentence.getParent();
|
||||||
|
Sentence newSentence = selectedSentence.cloneSentence();
|
||||||
int idx = bookTreeModel.getIndexOfChild(c, selectedSentence);
|
int idx = bookTreeModel.getIndexOfChild(c, selectedSentence);
|
||||||
bookTreeModel.insertNodeInto(newSentence, c, idx);
|
bookTreeModel.insertNodeInto(newSentence, c, idx);
|
||||||
|
|
||||||
|
|||||||
@@ -561,6 +561,14 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setStartCrossing(int o) {
|
||||||
|
crossStartOffset = o;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndCrossing(int o) {
|
||||||
|
crossEndOffset = o;
|
||||||
|
}
|
||||||
|
|
||||||
public int getSampleSize() {
|
public int getSampleSize() {
|
||||||
if (sampleSize == -1) {
|
if (sampleSize == -1) {
|
||||||
loadFile();
|
loadFile();
|
||||||
@@ -714,6 +722,10 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
|||||||
/* Get the length of the sample in seconds */
|
/* Get the length of the sample in seconds */
|
||||||
public double getLength() {
|
public double getLength() {
|
||||||
if (runtime > 0.01d) return runtime;
|
if (runtime > 0.01d) return runtime;
|
||||||
|
File f = getFile();
|
||||||
|
if (!f.exists()) { // Not recorded yet!
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
AudioFormat format = getAudioFormat();
|
AudioFormat format = getAudioFormat();
|
||||||
float sampleFrequency = format.getFrameRate();
|
float sampleFrequency = format.getFrameRate();
|
||||||
int length = crossEndOffset - crossStartOffset;
|
int length = crossEndOffset - crossStartOffset;
|
||||||
@@ -729,12 +741,14 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
|||||||
}
|
}
|
||||||
sentence.setStartOffset(getStartOffset());
|
sentence.setStartOffset(getStartOffset());
|
||||||
sentence.setEndOffset(getEndOffset());
|
sentence.setEndOffset(getEndOffset());
|
||||||
|
sentence.setStartCrossing(getStartCrossing());
|
||||||
|
sentence.setEndCrossing(getEndCrossing());
|
||||||
|
|
||||||
File from = getFile();
|
File from = getFile();
|
||||||
File to = sentence.getFile();
|
File to = sentence.getFile();
|
||||||
Files.copy(from.toPath(), to.toPath());
|
Files.copy(from.toPath(), to.toPath());
|
||||||
|
|
||||||
sentence.updateCrossings();
|
// sentence.updateCrossings();
|
||||||
return sentence;
|
return sentence;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1482,6 +1496,7 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
|||||||
|
|
||||||
void reloadTree() {
|
void reloadTree() {
|
||||||
if (id.equals("room-noise")) return;
|
if (id.equals("room-noise")) return;
|
||||||
|
if (getParent() == null) return;
|
||||||
AudiobookRecorder.window.bookTreeModel.reload(this);
|
AudiobookRecorder.window.bookTreeModel.reload(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user