diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/ESBMoteType.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/ESBMoteType.java index e1e05c123..d834210ca 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/ESBMoteType.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/ESBMoteType.java @@ -26,11 +26,12 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ESBMoteType.java,v 1.2 2008/02/11 15:17:30 fros4943 Exp $ + * $Id: ESBMoteType.java,v 1.3 2008/02/12 15:12:38 fros4943 Exp $ */ package se.sics.cooja.mspmote; +import java.awt.Container; import java.awt.Image; import java.awt.MediaTracker; import java.awt.Toolkit; @@ -60,14 +61,14 @@ public class ESBMoteType extends MspMoteType { Toolkit toolkit = Toolkit.getDefaultToolkit(); URL imageURL = this.getClass().getClassLoader().getResource("images/esb.jpg"); Image image = toolkit.getImage(imageURL); - MediaTracker tracker = new MediaTracker(GUI.frame); + MediaTracker tracker = new MediaTracker(GUI.getTopParentContainer()); tracker.addImage(image, 1); try { tracker.waitForAll(); } catch (InterruptedException ex) { } - if (image.getHeight(GUI.frame) > 0 && image.getWidth(GUI.frame) > 0) { - image = image.getScaledInstance((100*image.getWidth(GUI.frame)/image.getHeight(GUI.frame)), 100, Image.SCALE_DEFAULT); + if (image.getHeight(GUI.getTopParentContainer()) > 0 && image.getWidth(GUI.getTopParentContainer()) > 0) { + image = image.getScaledInstance((100*image.getWidth(GUI.getTopParentContainer())/image.getHeight(GUI.getTopParentContainer())), 100, Image.SCALE_DEFAULT); return new ImageIcon(image); } @@ -78,9 +79,9 @@ public class ESBMoteType extends MspMoteType { return new ESBMote(this, simulation); } - public boolean configureAndInit(JFrame parentFrame, Simulation simulation, + public boolean configureAndInit(Container parentContainer, Simulation simulation, boolean visAvailable) throws MoteTypeCreationException { - return configureAndInitMspType(parentFrame, simulation, visAvailable, target, targetNice); + return configureAndInitMspType(parentContainer, simulation, visAvailable, target, targetNice); } } diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMoteType.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMoteType.java index 768670426..629c240c4 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMoteType.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMoteType.java @@ -26,12 +26,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: MspMoteType.java,v 1.3 2008/02/11 15:17:30 fros4943 Exp $ + * $Id: MspMoteType.java,v 1.4 2008/02/12 15:12:38 fros4943 Exp $ */ package se.sics.cooja.mspmote; import java.awt.*; +import java.awt.Dialog.ModalityType; import java.awt.event.*; import java.io.*; import java.util.*; @@ -131,7 +132,7 @@ public abstract class MspMoteType implements MoteType { /** * Configures and initialized Msp mote types. * - * @param parentFrame Graphical parent frame + * @param parentContainer Graphical parent container * @param simulation Current simulation * @param visAvailable Enable graphical interfaces and user input * @param target Contiki target platform name @@ -139,7 +140,7 @@ public abstract class MspMoteType implements MoteType { * @return True is successful * @throws MoteTypeCreationException Mote type creation failed */ - protected boolean configureAndInitMspType(JFrame parentFrame, Simulation simulation, + protected boolean configureAndInitMspType(Container parentContainer, Simulation simulation, boolean visAvailable, String target, String targetNice) throws MoteTypeCreationException { boolean compileFromSource = false; @@ -178,7 +179,7 @@ public abstract class MspMoteType implements MoteType { + "If you want to use an already existing file, click 'Select'.\n\n" + "To compile this file from source, click 'Compile'"; String title = "Select or compile " + targetNice + " firmware"; - int answer = JOptionPane.showOptionDialog(GUI.frame, + int answer = JOptionPane.showOptionDialog(GUI.getTopParentContainer(), question, title, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); @@ -202,7 +203,7 @@ public abstract class MspMoteType implements MoteType { compiler.setCompileCommand(compileCommand); if (visAvailable) { - boolean success = compiler.showDialog(GUI.frame, this); + boolean success = compiler.showDialog(GUI.getTopParentContainer(), this); if (success) { setSourceFile(compiler.getSourceFile()); setELFFile(compiler.getOutputFile()); @@ -270,7 +271,7 @@ public abstract class MspMoteType implements MoteType { }); fc.setDialogTitle("Select ELF file"); - if (fc.showOpenDialog(parentFrame) == JFileChooser.APPROVE_OPTION) { + if (fc.showOpenDialog(parentContainer) == JFileChooser.APPROVE_OPTION) { File selectedFile = fc.getSelectedFile(); if (!selectedFile.exists()) { @@ -558,8 +559,19 @@ public abstract class MspMoteType implements MoteType { } } - public boolean showDialog(Frame parentFrame, final MspMoteType moteType) { - myDialog = new JDialog(parentFrame, "Compile ELF file", true); + public boolean showDialog(Container parentContainer, final MspMoteType moteType) { + + if (parentContainer instanceof Window) { + myDialog = new JDialog((Window)parentContainer, "Compile ELF file", ModalityType.APPLICATION_MODAL); + } else if (parentContainer instanceof Dialog) { + myDialog = new JDialog((Dialog)parentContainer, "Compile ELF file", ModalityType.APPLICATION_MODAL); + } else if (parentContainer instanceof Frame) { + myDialog = new JDialog((Frame)parentContainer, "Compile ELF file", ModalityType.APPLICATION_MODAL); + } else { + logger.fatal("Unknown parent container type: " + parentContainer); + return false; + } + final MessageList taskOutput = new MessageList(); // BOTTOM BUTTON PART @@ -780,7 +792,7 @@ public abstract class MspMoteType implements MoteType { contentPane.add(buttonBox, BorderLayout.SOUTH); myDialog.pack(); - myDialog.setLocationRelativeTo(parentFrame); + myDialog.setLocationRelativeTo(parentContainer); myDialog.getRootPane().setDefaultButton(compileButton); // Dispose on escape key @@ -957,7 +969,7 @@ public abstract class MspMoteType implements MoteType { } } - return configureAndInit(GUI.frame, simulation, visAvailable); + return configureAndInit(GUI.getTopParentContainer(), simulation, visAvailable); } } diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/SkyMoteType.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/SkyMoteType.java index 194a4906a..cdc0ff37b 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/SkyMoteType.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/SkyMoteType.java @@ -26,18 +26,17 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: SkyMoteType.java,v 1.1 2008/02/11 15:22:07 fros4943 Exp $ + * $Id: SkyMoteType.java,v 1.2 2008/02/12 15:12:38 fros4943 Exp $ */ package se.sics.cooja.mspmote; +import java.awt.Container; import java.awt.Image; import java.awt.MediaTracker; import java.awt.Toolkit; import java.net.URL; - import javax.swing.*; - import org.apache.log4j.Logger; import se.sics.cooja.*; @@ -62,14 +61,14 @@ public class SkyMoteType extends MspMoteType { Toolkit toolkit = Toolkit.getDefaultToolkit(); URL imageURL = this.getClass().getClassLoader().getResource("images/sky.jpg"); Image image = toolkit.getImage(imageURL); - MediaTracker tracker = new MediaTracker(GUI.frame); + MediaTracker tracker = new MediaTracker(GUI.getTopParentContainer()); tracker.addImage(image, 1); try { tracker.waitForAll(); } catch (InterruptedException ex) { } - if (image.getHeight(GUI.frame) > 0 && image.getWidth(GUI.frame) > 0) { - image = image.getScaledInstance((200*image.getWidth(GUI.frame)/image.getHeight(GUI.frame)), 200, Image.SCALE_DEFAULT); + if (image.getHeight(GUI.getTopParentContainer()) > 0 && image.getWidth(GUI.getTopParentContainer()) > 0) { + image = image.getScaledInstance((200*image.getWidth(GUI.getTopParentContainer())/image.getHeight(GUI.getTopParentContainer())), 200, Image.SCALE_DEFAULT); return new ImageIcon(image); } @@ -80,9 +79,9 @@ public class SkyMoteType extends MspMoteType { return new SkyMote(this, simulation); } - public boolean configureAndInit(JFrame parentFrame, Simulation simulation, + public boolean configureAndInit(Container parentContainer, Simulation simulation, boolean visAvailable) throws MoteTypeCreationException { - return configureAndInitMspType(parentFrame, simulation, visAvailable, target, targetNice); + return configureAndInitMspType(parentContainer, simulation, visAvailable, target, targetNice); } } diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/plugins/MspStackWatcher.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/plugins/MspStackWatcher.java index 7f5caca52..5e4240eec 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/plugins/MspStackWatcher.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/plugins/MspStackWatcher.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: MspStackWatcher.java,v 1.2 2008/02/11 11:48:38 fros4943 Exp $ + * $Id: MspStackWatcher.java,v 1.3 2008/02/12 15:13:11 fros4943 Exp $ */ package se.sics.cooja.mspmote.plugins; @@ -53,7 +53,6 @@ public class MspStackWatcher extends VisPlugin { private MSP430 cpu; private Simulation simulation; private Observer stackObserver = null; - private Observer logObserver = null; private JButton startButton; private JButton stopButton;