minor changes when dusting up quick-start

This commit is contained in:
fros4943 2007-03-24 00:42:51 +00:00
parent e753966dc0
commit 24cc50590f

View File

@ -24,7 +24,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* $Id: GUI.java,v 1.33 2007/03/23 23:34:33 fros4943 Exp $ * $Id: GUI.java,v 1.34 2007/03/24 00:42:51 fros4943 Exp $
*/ */
package se.sics.cooja; package se.sics.cooja;
@ -187,8 +187,11 @@ public class GUI {
/** /**
* Creates a new COOJA Simulator GUI. * Creates a new COOJA Simulator GUI.
*
* @param desktop Desktop pane
* @param createSimDialog If true, a create simulation dialog will be displayed at startup
*/ */
public GUI(JDesktopPane desktop) { public GUI(JDesktopPane desktop, boolean createSimDialog) {
myGUI = this; myGUI = this;
mySimulation = null; mySimulation = null;
myDesktopPane = desktop; myDesktopPane = desktop;
@ -228,7 +231,7 @@ public class GUI {
} }
} }
if (frame != null) { if (createSimDialog && frame != null) {
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
public void run() { public void run() {
myGUI.doCreateSimulation(true); myGUI.doCreateSimulation(true);
@ -535,7 +538,7 @@ public class GUI {
JDesktopPane desktop = new JDesktopPane(); JDesktopPane desktop = new JDesktopPane();
desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE); desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
GUI gui = new GUI(desktop); GUI gui = new GUI(desktop, true);
JComponent newContentPane = gui.getDesktopPane(); JComponent newContentPane = gui.getDesktopPane();
newContentPane.setOpaque(true); newContentPane.setOpaque(true);
frame.setContentPane(newContentPane); frame.setContentPane(newContentPane);
@ -614,7 +617,7 @@ public class GUI {
// Create and set up the content pane. // Create and set up the content pane.
JDesktopPane desktop = new JDesktopPane(); JDesktopPane desktop = new JDesktopPane();
desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE); desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
GUI gui = new GUI(desktop); // loads external settings and creates initial GUI gui = new GUI(desktop, false); // loads external settings and creates initial
// project config // project config
// Add menu bar // Add menu bar
@ -1794,12 +1797,12 @@ public class GUI {
try { try {
newSim = loadSimulationConfig(fileToLoad, quick); newSim = loadSimulationConfig(fileToLoad, quick);
addToFileHistory(fileToLoad); addToFileHistory(fileToLoad);
if (progressDialog != null && progressDialog.isVisible()) { if (progressDialog != null && progressDialog.isDisplayable()) {
progressDialog.dispose(); progressDialog.dispose();
} }
} catch (UnsatisfiedLinkError e) { } catch (UnsatisfiedLinkError e) {
logger.warn("Could not reopen libraries: " + e.getMessage()); logger.warn("Could not reopen libraries: " + e.getMessage());
if (progressDialog != null) if (progressDialog != null && progressDialog.isDisplayable())
progressDialog.dispose(); progressDialog.dispose();
newSim = null; newSim = null;
} }
@ -1823,7 +1826,7 @@ public class GUI {
loadThread.interrupt(); loadThread.interrupt();
doRemoveSimulation(false); doRemoveSimulation(false);
} }
if (progressDialog != null && progressDialog.isVisible()) { if (progressDialog != null && progressDialog.isDisplayable()) {
progressDialog.dispose(); progressDialog.dispose();
} }
} }
@ -1926,12 +1929,12 @@ public class GUI {
Simulation newSim = null; Simulation newSim = null;
try { try {
newSim = loadSimulationConfig(new StringReader(configXML), true); newSim = loadSimulationConfig(new StringReader(configXML), true);
if (progressDialog != null && progressDialog.isVisible()) { if (progressDialog != null && progressDialog.isDisplayable()) {
progressDialog.dispose(); progressDialog.dispose();
} }
} catch (UnsatisfiedLinkError e) { } catch (UnsatisfiedLinkError e) {
logger.fatal("Could not reopen libraries: " + e.getMessage()); logger.fatal("Could not reopen libraries: " + e.getMessage());
if (progressDialog != null && progressDialog.isVisible()) { if (progressDialog != null && progressDialog.isDisplayable()) {
progressDialog.dispose(); progressDialog.dispose();
} }
newSim = null; newSim = null;
@ -1940,7 +1943,7 @@ public class GUI {
myGUI.setSimulation(newSim); myGUI.setSimulation(newSim);
} }
if (progressDialog != null && progressDialog.isVisible()) { if (progressDialog != null && progressDialog.isDisplayable()) {
progressDialog.dispose(); progressDialog.dispose();
} }
} }
@ -1958,7 +1961,7 @@ public class GUI {
loadThread.interrupt(); loadThread.interrupt();
doRemoveSimulation(false); doRemoveSimulation(false);
} }
if (progressDialog != null && progressDialog.isVisible()) { if (progressDialog != null && progressDialog.isDisplayable()) {
progressDialog.dispose(); progressDialog.dispose();
} }
} }
@ -2572,13 +2575,12 @@ public class GUI {
if (!ok) if (!ok)
System.exit(1); System.exit(1);
// Check if simulator should be quick-started
} else if (args.length > 0 && args[0].startsWith("-nogui")) { } else if (args.length > 0 && args[0].startsWith("-nogui")) {
// No GUI start-up // No GUI start-up
javax.swing.SwingUtilities.invokeLater(new Runnable() { javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() { public void run() {
new GUI(null); new GUI(null, false);
} }
}); });