Move external processing to worker threads
This commit is contained in:
@@ -1429,7 +1429,7 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
|
||||
Debug.trace();
|
||||
JMenuObject o = (JMenuObject)e.getSource();
|
||||
Sentence s = (Sentence)o.getObject();
|
||||
s.runExternalProcessor(Utils.s2i(o.getActionCommand()));
|
||||
queueJob(new SentenceExternalJob(s, Utils.s2i(o.getActionCommand())));
|
||||
}
|
||||
});
|
||||
ob.setActionCommand(Integer.toString(i));
|
||||
@@ -1725,7 +1725,7 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
|
||||
for (Enumeration s = c.children(); s.hasMoreElements();) {
|
||||
Sentence snt = (Sentence)s.nextElement();
|
||||
if (!snt.isLocked()) {
|
||||
snt.runExternalProcessor(Utils.s2i(o.getActionCommand()));
|
||||
queueJob(new SentenceExternalJob(snt, Utils.s2i(o.getActionCommand())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -956,8 +956,7 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
||||
public void openInExternalEditor() {
|
||||
Debug.trace();
|
||||
ExternalEditor ed = new ExternalEditor(this);
|
||||
Thread t = new Thread(ed);
|
||||
t.start();
|
||||
ed.run();
|
||||
}
|
||||
|
||||
public void backup() throws IOException {
|
||||
@@ -1051,8 +1050,7 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
||||
Debug.trace();
|
||||
if (isLocked()) return;
|
||||
ExternalProcessor ed = new ExternalProcessor(this, num);
|
||||
Thread t = new Thread(ed);
|
||||
t.start();
|
||||
ed.run();
|
||||
}
|
||||
|
||||
public void undo() {
|
||||
|
||||
17
src/uk/co/majenko/audiobookrecorder/SentenceExternalJob.java
Normal file
17
src/uk/co/majenko/audiobookrecorder/SentenceExternalJob.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package uk.co.majenko.audiobookrecorder;
|
||||
|
||||
import java.lang.Runnable;
|
||||
|
||||
public class SentenceExternalJob extends SentenceJob {
|
||||
protected int command;
|
||||
|
||||
public SentenceExternalJob(Sentence s, int c) {
|
||||
super(s);
|
||||
command = c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
sentence.runExternalProcessor(command);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user