- @Override
- protected void fail (String message) {
- super.fail(message);
- // super.fail causes the UI to be created (if needed) on the next UI tick, so we
- // want to wait until that happens before we attempt to redecorate the window
- EventQueue.invokeLater(new Runnable() {
- @Override
- public void run() {
- // if the frame was set to be undecorated, make window decoration available
- // to allow the user to close the window
- if (_frame != null && _frame.isUndecorated()) {
- _frame.dispose();
- Color bg = _frame.getBackground();
- if (bg != null && bg.getAlpha() < 255) {
- // decorated windows do not allow alpha backgrounds
- _frame.setBackground(
- new Color(bg.getRed(), bg.getGreen(), bg.getBlue()));
- }
- _frame.setUndecorated(false);
- showContainer();
- }
- }
- });
+ @Override
+ protected void showContainer () {
+ if (_frame != null) {
+ _frame.pack();
+ SwingUtil.centerWindow(_frame);
+ _frame.setVisible(true);
+ }
+ _shownContainer = true;
+ }
+
+ @Override
+ protected void disposeContainer () {
+ if (_frame != null) {
+ _frame.dispose();
+ _frame = null;
+ }
+ }
+
+ @Override
+ protected void showDocument (String url) {
+ if (!StringUtil.couldBeValidUrl(url)) {
+ // command injection would be possible if we allowed e.g. spaces and double quotes
+ log.warning("Invalid document URL.", "url", url);
+ return;
+ }
+ String[] cmdarray;
+ if (LaunchUtil.isWindows()) {
+ String osName = System.getProperty("os.name", "");
+ if (osName.indexOf("9") != -1 || osName.indexOf("Me") != -1) {
+ cmdarray = new String[] {
+ "command.com", "/c", "start", "\"" + url + "\"" };
+ } else {
+ cmdarray = new String[] {
+ "cmd.exe", "/c", "start", "\"\"", "\"" + url + "\"" };
+ }
+ } else if (LaunchUtil.isMacOS()) {
+ cmdarray = new String[] { "open", url };
+ } else { // Linux, Solaris, etc.
+ cmdarray = new String[] { "firefox", url };
+ }
+ try {
+ Runtime.getRuntime().exec(cmdarray);
+ } catch (Exception e) {
+ log.warning("Failed to open browser.", "cmdarray", cmdarray, e);
+ }
+ }
+
+ @Override
+ protected void exit (int exitCode) {
+ // if we're running the app in the same JVM, don't call System.exit, but do
+ // make double sure that the download window is closed.
+ if (invokeDirect()) {
+ disposeContainer();
+ } else {
+ System.exit(exitCode);
+ }
+ }
+
+ @Override
+ protected void fail (String message) {
+ super.fail(message);
+ // super.fail causes the UI to be created (if needed) on the next UI tick, so we
+ // want to wait until that happens before we attempt to redecorate the window
+ EQinvoke(new Runnable() {
+ @Override
+ public void run() {
+ // if the frame was set to be undecorated, make window decoration available
+ // to allow the user to close the window
+ if (_frame != null && _frame.isUndecorated()) {
+ _frame.dispose();
+ Color bg = _frame.getBackground();
+ if (bg != null && bg.getAlpha() < 255) {
+ // decorated windows do not allow alpha backgrounds
+ _frame.setBackground(
+ new Color(bg.getRed(), bg.getGreen(), bg.getBlue()));
+ }
+ _frame.setUndecorated(false);
+ showContainer();