コミットメタ情報

リビジョン16ae6293ef6e59f6c91d57ff16721b316e02e5f6 (tree)
日時2014-12-01 21:38:31
作者argius <argius.net@gmai...>
コミッターargius

ログメッセージ

make it possible to call WindowOutputProcessor.showErrorDialog from non
AWT thread

変更サマリ

差分

--- a/src/net/argius/stew/ui/window/ResultSetTableModel.java
+++ b/src/net/argius/stew/ui/window/ResultSetTableModel.java
@@ -1,6 +1,5 @@
11 package net.argius.stew.ui.window;
22
3-import static java.awt.EventQueue.invokeLater;
43 import static java.sql.Types.*;
54 import static java.util.Collections.nCopies;
65 import static net.argius.stew.text.TextUtilities.join;
@@ -426,13 +425,7 @@ final class ResultSetTableModel extends DefaultTableModel {
426425 log.warn(ex);
427426 }
428427 if (!errors.isEmpty()) {
429- class ErrorNotifier implements Runnable {
430- @Override
431- public void run() {
432- WindowOutputProcessor.showErrorDialog(null, errors.get(0));
433- }
434- }
435- invokeLater(new ErrorNotifier());
428+ WindowOutputProcessor.showErrorDialog(null, errors.get(0));
436429 }
437430 }
438431 }
--- a/src/net/argius/stew/ui/window/WindowOutputProcessor.java
+++ b/src/net/argius/stew/ui/window/WindowOutputProcessor.java
@@ -440,6 +440,7 @@ final class WindowOutputProcessor extends JFrame implements OutputProcessor, Any
440440 }
441441
442442 static void showErrorDialog(final Component parent, final Throwable th) {
443+ // this method can call from non AWT thread
443444 log.atEnter("showErrorDialog");
444445 log.warn(th, "");
445446 final String s1;
@@ -454,13 +455,25 @@ final class WindowOutputProcessor extends JFrame implements OutputProcessor, Any
454455 th.printStackTrace(out);
455456 s2 = replaceEOL(buffer.toString());
456457 }
457- JPanel p = new JPanel(new BorderLayout());
458- p.add(new JScrollPane(setupReadOnlyTextArea(new JTextArea(s1, 2, 60))), BorderLayout.NORTH);
459- p.add(new JScrollPane(setupReadOnlyTextArea(new JTextArea(s2, 6, 60))), BorderLayout.CENTER);
460- JDialog d = (new JOptionPane(p, ERROR_MESSAGE)).createDialog(parent, res.get("e.error"));
461- d.setResizable(true);
462- d.setVisible(true);
463- d.dispose();
458+ final String title = res.get("e.error");
459+ class ErrorDialogTask implements Runnable {
460+ @Override
461+ public void run() {
462+ JPanel p = new JPanel(new BorderLayout());
463+ p.add(new JScrollPane(setupReadOnlyTextArea(new JTextArea(s1, 2, 60))), BorderLayout.NORTH);
464+ p.add(new JScrollPane(setupReadOnlyTextArea(new JTextArea(s2, 6, 60))), BorderLayout.CENTER);
465+ JDialog d = (new JOptionPane(p, ERROR_MESSAGE)).createDialog(parent, title);
466+ d.setResizable(true);
467+ d.setVisible(true);
468+ d.dispose();
469+ }
470+ }
471+ ErrorDialogTask task = new ErrorDialogTask();
472+ if (EventQueue.isDispatchThread()) {
473+ task.run();
474+ } else {
475+ EventQueue.invokeLater(task);
476+ }
464477 log.atExit("showErrorDialog");
465478 }
466479
旧リポジトリブラウザで表示