UI thread invoke fixes/improvements 2

This commit is contained in:
honfika@gmail.com
2016-12-28 12:57:06 +01:00
parent 5b0bd1f0c5
commit 9dc4752c04
7 changed files with 184 additions and 161 deletions

View File

@@ -196,7 +196,6 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.CancellationException;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
@@ -327,8 +326,6 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
private TreePanelMode treePanelMode;
private CancellableWorker setSourceWorker;
public TreeItem oldItem;
// play morph shape in 2 second(s)
@@ -3414,48 +3411,12 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
if (treeItem instanceof ScriptPack) {
final ScriptPack scriptLeaf = (ScriptPack) treeItem;
if (setSourceWorker != null) {
setSourceWorker.cancel(true);
setSourceWorker = null;
}
if (!Main.isInited() || !Main.isWorking() || Main.isDebugging()) {
ABCPanel abcPanel = getABCPanel();
abcPanel.detailPanel.methodTraitPanel.methodCodePanel.clear();
abcPanel.setAbc(scriptLeaf.abc);
CancellableWorker worker = new CancellableWorker() {
@Override
protected Void doInBackground() throws Exception {
abcPanel.decompiledTextArea.setScript(scriptLeaf, true);
abcPanel.decompiledTextArea.setNoTrait();
return null;
}
@Override
protected void onStart() {
Main.startWork(translate("work.decompiling") + "...", this);
}
@Override
protected void done() {
View.execInEventDispatch(() -> {
setSourceWorker = null;
try {
get();
} catch (CancellationException ex) {
abcPanel.decompiledTextArea.setText("// " + AppStrings.translate("work.canceled"));
} catch (Exception ex) {
logger.log(Level.SEVERE, "Error", ex);
getABCPanel().decompiledTextArea.setText("// " + AppStrings.translate("decompilationError") + ": " + ex);
}
Main.stopWork();
});
}
};
worker.execute();
setSourceWorker = worker;
abcPanel.decompiledTextArea.setScript(scriptLeaf, true);
abcPanel.decompiledTextArea.setNoTrait();
}
showDetail(DETAILCARDAS3NAVIGATOR);