Non-fatal error message with optional stack trace side dish.
(String title,
String primary, String secondary,
Throwable e)
| 77 | * Non-fatal error message with optional stack trace side dish. |
| 78 | */ |
| 79 | static public void showWarningTiered(String title, |
| 80 | String primary, String secondary, |
| 81 | Throwable e) { |
| 82 | if (title == null) title = "Warning"; |
| 83 | |
| 84 | final String message = primary + "\n" + secondary; |
| 85 | if (Base.isCommandLine()) { |
| 86 | System.out.println(title + ": " + message); |
| 87 | |
| 88 | } else { |
| 89 | // JOptionPane.showMessageDialog(new Frame(), message, |
| 90 | // title, JOptionPane.WARNING_MESSAGE); |
| 91 | if (!Platform.isMacOS()) { |
| 92 | JOptionPane.showMessageDialog(new JFrame(), |
| 93 | "<html><body>" + |
| 94 | "<b>" + primary + "</b>" + |
| 95 | "<br>" + secondary, title, |
| 96 | JOptionPane.WARNING_MESSAGE); |
| 97 | } else { |
| 98 | // Pane formatting adapted from the Quaqua guide |
| 99 | // http://www.randelshofer.ch/quaqua/guide/joptionpane.html |
| 100 | JOptionPane pane = |
| 101 | new JOptionPane("<html> " + |
| 102 | "<head> <style type=\"text/css\">"+ |
| 103 | "b { font: 13pt \"Lucida Grande\" }"+ |
| 104 | "p { font: 11pt \"Lucida Grande\"; margin-top: 8px; width: 300px }"+ |
| 105 | "</style> </head>" + |
| 106 | "<b>" + primary + "</b>" + |
| 107 | "<p>" + secondary + "</p>", |
| 108 | JOptionPane.WARNING_MESSAGE); |
| 109 | |
| 110 | // String[] options = new String[] { |
| 111 | // "Yes", "No" |
| 112 | // }; |
| 113 | // pane.setOptions(options); |
| 114 | |
| 115 | // highlight the safest option ala apple hig |
| 116 | // pane.setInitialValue(options[0]); |
| 117 | |
| 118 | JDialog dialog = pane.createDialog(new JFrame(), null); |
| 119 | dialog.setVisible(true); |
| 120 | |
| 121 | // Object result = pane.getValue(); |
| 122 | // if (result == options[0]) { |
| 123 | // return JOptionPane.YES_OPTION; |
| 124 | // } else if (result == options[1]) { |
| 125 | // return JOptionPane.NO_OPTION; |
| 126 | // } else { |
| 127 | // return JOptionPane.CLOSED_OPTION; |
| 128 | // } |
| 129 | } |
| 130 | } |
| 131 | if (e != null) e.printStackTrace(); |
| 132 | } |
| 133 | |
| 134 | |
| 135 | /** |
no test coverage detected