Reinit our UI more cleanly.

This commit is contained in:
Michael Bayne
2014-02-11 11:32:53 -08:00
parent f706ed216a
commit b793b56a28
@@ -221,7 +221,7 @@ public abstract class Getdown extends Thread
// clear out our UI // clear out our UI
disposeContainer(); disposeContainer();
_status = null; _container = null;
// fire up a new thread // fire up a new thread
new Thread(this).start(); new Thread(this).start();
@@ -364,7 +364,7 @@ public abstract class Getdown extends Thread
try { try {
_ifc = _app.init(true); _ifc = _app.init(true);
} catch (IOException ioe) { } catch (IOException ioe) {
log.warning("Failed to parse 'getdown.txt': " + ioe); log.warning("Failed to initialize: " + ioe);
_app.attemptRecovery(this); _app.attemptRecovery(this);
// and re-initalize // and re-initalize
_ifc = _app.init(true); _ifc = _app.init(true);
@@ -801,7 +801,7 @@ public abstract class Getdown extends Thread
if (LaunchUtil.mustMonitorChildren()) { if (LaunchUtil.mustMonitorChildren()) {
// close our window if it's around // close our window if it's around
disposeContainer(); disposeContainer();
_status = null; _container = null;
copyStream(stderr, System.err); copyStream(stderr, System.err);
log.info("Process exited: " + proc.waitFor()); log.info("Process exited: " + proc.waitFor());
@@ -862,12 +862,15 @@ public abstract class Getdown extends Thread
EventQueue.invokeLater(new Runnable() { EventQueue.invokeLater(new Runnable() {
public void run () { public void run () {
if (_status == null) { if (_container == null || reinit) {
_container = createContainer(); if (_container == null) {
_container = createContainer();
} else {
_container.removeAll();
}
_layers = new JLayeredPane(); _layers = new JLayeredPane();
_container.add(_layers, BorderLayout.CENTER); _container.add(_layers, BorderLayout.CENTER);
_patchNotes = new JButton(new AbstractAction( _patchNotes = new JButton(new AbstractAction(_msgs.getString("m.patch_notes")) {
_msgs.getString("m.patch_notes")) {
@Override public void actionPerformed (ActionEvent event) { @Override public void actionPerformed (ActionEvent event) {
showDocument(_ifc.patchNotesUrl); showDocument(_ifc.patchNotesUrl);
} }
@@ -897,8 +900,6 @@ public abstract class Getdown extends Thread
_status = new StatusPanel(_msgs); _status = new StatusPanel(_msgs);
_layers.add(_status); _layers.add(_status);
initInterface(); initInterface();
} else if (reinit) {
initInterface();
} }
showContainer(); showContainer();
} }