UI thread invoke fixes/improvements 3

This commit is contained in:
2016-12-28 13:25:19 +01:00
parent 9dc4752c04
commit f7e5479bdd
7 changed files with 41 additions and 38 deletions
@@ -493,8 +493,7 @@ public class DebuggerHandler implements DebugConnectionListener {
@Override
public void failedListen(IOException ex) {
View.execInEventDispatchLater(new Runnable() {
View.execInEventDispatch(new Runnable() {
@Override
public void run() {
disconnect();
@@ -629,7 +628,7 @@ public class DebuggerHandler implements DebugConnectionListener {
public void message(InSwfInfo t) {
for (InSwfInfo.SwfInfo s : t.swfInfos) {
swfs.add(s);
View.execInEventDispatchLater(new Runnable() {
View.execInEventDispatch(new Runnable() {
@Override
public void run() {
try {
@@ -643,7 +642,6 @@ public class DebuggerHandler implements DebugConnectionListener {
}
con.dropMessage(t);
}
});
InSetBreakpoint isb = con.getMessage(InSetBreakpoint.class);
@@ -668,7 +666,6 @@ public class DebuggerHandler implements DebugConnectionListener {
connected = true;
}
con.addMessageListener(new DebugMessageListener<InAskBreakpoints>() {
@Override
public void message(InAskBreakpoints message) {
@@ -687,7 +684,6 @@ public class DebuggerHandler implements DebugConnectionListener {
}
});
con.addMessageListener(new DebugMessageListener<InBreakAt>() {
@Override
public void message(InBreakAt message) {
synchronized (DebuggerHandler.this) {
@@ -752,7 +748,6 @@ public class DebuggerHandler implements DebugConnectionListener {
}
con.addMessageListener(new DebugMessageListener<InTrace>() {
@Override
public void message(InTrace tr) {
for (TraceListener l : traceListeners) {
@@ -1073,7 +1073,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
}
int fmulCount = mulCount;
View.execInEventDispatchLater(() -> {
View.execInEventDispatch(() -> {
View.showMessageDialog(null, translate("rename.finished.multiname").replace("%count%", Integer.toString(fmulCount)));
if (abcPanel != null) {
abcPanel.reload();
@@ -2378,7 +2378,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
long timeAfter = System.currentTimeMillis();
final long timeMs = timeAfter - timeBefore;
View.execInEventDispatchLater(() -> {
View.execInEventDispatch(() -> {
setStatus(translate("export.finishedin").replace("%time%", Helper.formatTimeSec(timeMs)));
});
}
@@ -1255,15 +1255,14 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<ABC
View.checkAccess();
TagTreeModel ttm = (TagTreeModel) mainPanel.tagTree.getModel();
TreePath tp0 = ttm.getTreePath(pack);
if (tp0 == null) {
TreePath tp = ttm.getTreePath(pack);
if (tp == null) {
mainPanel.closeTagTreeSearch();
tp0 = ttm.getTreePath(pack);
tp = ttm.getTreePath(pack);
}
final TreePath tp = tp0;
mainPanel.tagTree.setSelectionPath(tp);
mainPanel.tagTree.scrollPathToVisible(tp);
}
@Override
@@ -1272,22 +1271,34 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<ABC
ScriptPack pack = item.getScriptPack();
setAbc(pack.abc);
Runnable setScriptComplete = new Runnable() {
@Override
public void run() {
decompiledTextArea.removeScriptListener(this);
hilightScript(pack);
boolean pcode = item.isPcode();
if (pcode) {
decompiledTextArea.setClassIndex(item.getClassIndex());
decompiledTextArea.gotoTrait(item.getTraitId());
} else {
decompiledTextArea.setCaretPosition(0);
}
decompiledTextArea.caretUpdate(null);
if (pcode) {
searchPanel.showQuickFindDialog(detailPanel.methodTraitPanel.methodCodePanel.getSourceTextArea());
} else {
searchPanel.showQuickFindDialog(decompiledTextArea);
}
}
};
decompiledTextArea.addScriptListener(setScriptComplete);
decompiledTextArea.setScript(pack, false);
hilightScript(pack);
boolean pcode = item.isPcode();
if (pcode) {
decompiledTextArea.setClassIndex(item.getClassIndex());
decompiledTextArea.gotoTrait(item.getTraitId());
}
decompiledTextArea.setCaretPosition(0);
if (pcode) {
searchPanel.showQuickFindDialog(detailPanel.methodTraitPanel.methodCodePanel.getSourceTextArea());
} else {
searchPanel.showQuickFindDialog(decompiledTextArea);
}
}
public boolean isDirectEditing() {
@@ -666,8 +666,10 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL
}
if (!force && this.script == scriptLeaf) {
fireScript();
return;
}
String sn = scriptLeaf.getClassPath().toString();
setScriptName(sn);
abcPanel.scriptNameLabel.setText(sn);
@@ -305,7 +305,6 @@ public class DetailPanel extends JPanel implements TagEditorPanel {
if (((TraitDetail) cardMap.get(selectedCard)).save()) {
DecompiledEditorPane decompiledTextArea = abcPanel.decompiledTextArea;
int lastTrait = decompiledTextArea.lastTraitIndex;
decompiledTextArea.reloadClass();
Runnable reloadComplete = new Runnable() {
@Override
@@ -318,6 +317,7 @@ public class DetailPanel extends JPanel implements TagEditorPanel {
};
decompiledTextArea.addScriptListener(reloadComplete);
decompiledTextArea.reloadClass();
}
}
}
@@ -83,7 +83,7 @@ public class FirstInstance {
fileNames[i] = ois.readUTF();
}
View.execInEventDispatchLater(() -> {
View.execInEventDispatch(() -> {
for (int i = 0; i < cnt; i++) {
Main.openFile(fileNames[i], null);
}
@@ -91,7 +91,7 @@ public class FirstInstance {
//no break - focus too
case "focus":
View.execInEventDispatchLater(new Runnable() {
View.execInEventDispatch(new Runnable() {
@Override
public void run() {
Window wnd = Main.getMainFrame().getWindow();
@@ -181,12 +181,10 @@ public class PlayerControls extends JPanel implements MediaDisplayListener {
frameLabel = new JLabel("0", SwingConstants.CENTER);
frameLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
frameLabel.addMouseMotionListener(new MouseMotionAdapter() {
@Override
public void mouseMoved(MouseEvent e) {
}
});
frameLabel.setVisible(false);
@@ -194,7 +192,6 @@ public class PlayerControls extends JPanel implements MediaDisplayListener {
zeroCharacterWidth = frameLabel.getFontMetrics(notUnderlinedFont).stringWidth("0");
frameLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent e) {
frameLabel.setFont(underlinedFont);
@@ -212,7 +209,6 @@ public class PlayerControls extends JPanel implements MediaDisplayListener {
mainPanel.gotoFrame(gotoFrame);
}
}
});
timeLabel = new JLabel("(00:00.00)");
totalTimeLabel = new JLabel("(00:00.00)");
@@ -441,11 +437,10 @@ public class PlayerControls extends JPanel implements MediaDisplayListener {
gotoPanel.add(new JLabel(AppStrings.translate("preview.gotoframe.dialog.message").replace("%min%", "1").replace("%max%", "" + display.getTotalFrames())), BorderLayout.NORTH);
gotoPanel.add(frameField, BorderLayout.CENTER);
gotoPanel.addAncestorListener(new AncestorListener() {
@Override
public void ancestorAdded(AncestorEvent event) {
final AncestorListener al = this;
View.execInEventDispatchLater(() -> {
View.execInEventDispatch(() -> {
frameField.selectAll();
frameField.requestFocusInWindow();
gotoPanel.removeAncestorListener(al);