removed public static JFrame frame variable. components should instead access the top parent container via getTopParentContainer()
This commit is contained in:
parent
773736a6ca
commit
f1721cad53
4 changed files with 37 additions and 26 deletions
|
@ -26,11 +26,12 @@
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* 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;
|
package se.sics.cooja.mspmote;
|
||||||
|
|
||||||
|
import java.awt.Container;
|
||||||
import java.awt.Image;
|
import java.awt.Image;
|
||||||
import java.awt.MediaTracker;
|
import java.awt.MediaTracker;
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
|
@ -60,14 +61,14 @@ public class ESBMoteType extends MspMoteType {
|
||||||
Toolkit toolkit = Toolkit.getDefaultToolkit();
|
Toolkit toolkit = Toolkit.getDefaultToolkit();
|
||||||
URL imageURL = this.getClass().getClassLoader().getResource("images/esb.jpg");
|
URL imageURL = this.getClass().getClassLoader().getResource("images/esb.jpg");
|
||||||
Image image = toolkit.getImage(imageURL);
|
Image image = toolkit.getImage(imageURL);
|
||||||
MediaTracker tracker = new MediaTracker(GUI.frame);
|
MediaTracker tracker = new MediaTracker(GUI.getTopParentContainer());
|
||||||
tracker.addImage(image, 1);
|
tracker.addImage(image, 1);
|
||||||
try {
|
try {
|
||||||
tracker.waitForAll();
|
tracker.waitForAll();
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
}
|
}
|
||||||
if (image.getHeight(GUI.frame) > 0 && image.getWidth(GUI.frame) > 0) {
|
if (image.getHeight(GUI.getTopParentContainer()) > 0 && image.getWidth(GUI.getTopParentContainer()) > 0) {
|
||||||
image = image.getScaledInstance((100*image.getWidth(GUI.frame)/image.getHeight(GUI.frame)), 100, Image.SCALE_DEFAULT);
|
image = image.getScaledInstance((100*image.getWidth(GUI.getTopParentContainer())/image.getHeight(GUI.getTopParentContainer())), 100, Image.SCALE_DEFAULT);
|
||||||
return new ImageIcon(image);
|
return new ImageIcon(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,9 +79,9 @@ public class ESBMoteType extends MspMoteType {
|
||||||
return new ESBMote(this, simulation);
|
return new ESBMote(this, simulation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean configureAndInit(JFrame parentFrame, Simulation simulation,
|
public boolean configureAndInit(Container parentContainer, Simulation simulation,
|
||||||
boolean visAvailable) throws MoteTypeCreationException {
|
boolean visAvailable) throws MoteTypeCreationException {
|
||||||
return configureAndInitMspType(parentFrame, simulation, visAvailable, target, targetNice);
|
return configureAndInitMspType(parentContainer, simulation, visAvailable, target, targetNice);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,12 +26,13 @@
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* 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;
|
package se.sics.cooja.mspmote;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
import java.awt.Dialog.ModalityType;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
@ -131,7 +132,7 @@ public abstract class MspMoteType implements MoteType {
|
||||||
/**
|
/**
|
||||||
* Configures and initialized Msp mote types.
|
* Configures and initialized Msp mote types.
|
||||||
*
|
*
|
||||||
* @param parentFrame Graphical parent frame
|
* @param parentContainer Graphical parent container
|
||||||
* @param simulation Current simulation
|
* @param simulation Current simulation
|
||||||
* @param visAvailable Enable graphical interfaces and user input
|
* @param visAvailable Enable graphical interfaces and user input
|
||||||
* @param target Contiki target platform name
|
* @param target Contiki target platform name
|
||||||
|
@ -139,7 +140,7 @@ public abstract class MspMoteType implements MoteType {
|
||||||
* @return True is successful
|
* @return True is successful
|
||||||
* @throws MoteTypeCreationException Mote type creation failed
|
* @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)
|
boolean visAvailable, String target, String targetNice)
|
||||||
throws MoteTypeCreationException {
|
throws MoteTypeCreationException {
|
||||||
boolean compileFromSource = false;
|
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"
|
+ "If you want to use an already existing file, click 'Select'.\n\n"
|
||||||
+ "To compile this file from source, click 'Compile'";
|
+ "To compile this file from source, click 'Compile'";
|
||||||
String title = "Select or compile " + targetNice + " firmware";
|
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,
|
question, title, JOptionPane.YES_NO_OPTION,
|
||||||
JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
|
JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
|
||||||
|
|
||||||
|
@ -202,7 +203,7 @@ public abstract class MspMoteType implements MoteType {
|
||||||
compiler.setCompileCommand(compileCommand);
|
compiler.setCompileCommand(compileCommand);
|
||||||
|
|
||||||
if (visAvailable) {
|
if (visAvailable) {
|
||||||
boolean success = compiler.showDialog(GUI.frame, this);
|
boolean success = compiler.showDialog(GUI.getTopParentContainer(), this);
|
||||||
if (success) {
|
if (success) {
|
||||||
setSourceFile(compiler.getSourceFile());
|
setSourceFile(compiler.getSourceFile());
|
||||||
setELFFile(compiler.getOutputFile());
|
setELFFile(compiler.getOutputFile());
|
||||||
|
@ -270,7 +271,7 @@ public abstract class MspMoteType implements MoteType {
|
||||||
});
|
});
|
||||||
fc.setDialogTitle("Select ELF file");
|
fc.setDialogTitle("Select ELF file");
|
||||||
|
|
||||||
if (fc.showOpenDialog(parentFrame) == JFileChooser.APPROVE_OPTION) {
|
if (fc.showOpenDialog(parentContainer) == JFileChooser.APPROVE_OPTION) {
|
||||||
File selectedFile = fc.getSelectedFile();
|
File selectedFile = fc.getSelectedFile();
|
||||||
|
|
||||||
if (!selectedFile.exists()) {
|
if (!selectedFile.exists()) {
|
||||||
|
@ -558,8 +559,19 @@ public abstract class MspMoteType implements MoteType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean showDialog(Frame parentFrame, final MspMoteType moteType) {
|
public boolean showDialog(Container parentContainer, final MspMoteType moteType) {
|
||||||
myDialog = new JDialog(parentFrame, "Compile ELF file", true);
|
|
||||||
|
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();
|
final MessageList taskOutput = new MessageList();
|
||||||
|
|
||||||
// BOTTOM BUTTON PART
|
// BOTTOM BUTTON PART
|
||||||
|
@ -780,7 +792,7 @@ public abstract class MspMoteType implements MoteType {
|
||||||
contentPane.add(buttonBox, BorderLayout.SOUTH);
|
contentPane.add(buttonBox, BorderLayout.SOUTH);
|
||||||
|
|
||||||
myDialog.pack();
|
myDialog.pack();
|
||||||
myDialog.setLocationRelativeTo(parentFrame);
|
myDialog.setLocationRelativeTo(parentContainer);
|
||||||
myDialog.getRootPane().setDefaultButton(compileButton);
|
myDialog.getRootPane().setDefaultButton(compileButton);
|
||||||
|
|
||||||
// Dispose on escape key
|
// 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,18 +26,17 @@
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* 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;
|
package se.sics.cooja.mspmote;
|
||||||
|
|
||||||
|
import java.awt.Container;
|
||||||
import java.awt.Image;
|
import java.awt.Image;
|
||||||
import java.awt.MediaTracker;
|
import java.awt.MediaTracker;
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import se.sics.cooja.*;
|
import se.sics.cooja.*;
|
||||||
|
@ -62,14 +61,14 @@ public class SkyMoteType extends MspMoteType {
|
||||||
Toolkit toolkit = Toolkit.getDefaultToolkit();
|
Toolkit toolkit = Toolkit.getDefaultToolkit();
|
||||||
URL imageURL = this.getClass().getClassLoader().getResource("images/sky.jpg");
|
URL imageURL = this.getClass().getClassLoader().getResource("images/sky.jpg");
|
||||||
Image image = toolkit.getImage(imageURL);
|
Image image = toolkit.getImage(imageURL);
|
||||||
MediaTracker tracker = new MediaTracker(GUI.frame);
|
MediaTracker tracker = new MediaTracker(GUI.getTopParentContainer());
|
||||||
tracker.addImage(image, 1);
|
tracker.addImage(image, 1);
|
||||||
try {
|
try {
|
||||||
tracker.waitForAll();
|
tracker.waitForAll();
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
}
|
}
|
||||||
if (image.getHeight(GUI.frame) > 0 && image.getWidth(GUI.frame) > 0) {
|
if (image.getHeight(GUI.getTopParentContainer()) > 0 && image.getWidth(GUI.getTopParentContainer()) > 0) {
|
||||||
image = image.getScaledInstance((200*image.getWidth(GUI.frame)/image.getHeight(GUI.frame)), 200, Image.SCALE_DEFAULT);
|
image = image.getScaledInstance((200*image.getWidth(GUI.getTopParentContainer())/image.getHeight(GUI.getTopParentContainer())), 200, Image.SCALE_DEFAULT);
|
||||||
return new ImageIcon(image);
|
return new ImageIcon(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,9 +79,9 @@ public class SkyMoteType extends MspMoteType {
|
||||||
return new SkyMote(this, simulation);
|
return new SkyMote(this, simulation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean configureAndInit(JFrame parentFrame, Simulation simulation,
|
public boolean configureAndInit(Container parentContainer, Simulation simulation,
|
||||||
boolean visAvailable) throws MoteTypeCreationException {
|
boolean visAvailable) throws MoteTypeCreationException {
|
||||||
return configureAndInitMspType(parentFrame, simulation, visAvailable, target, targetNice);
|
return configureAndInitMspType(parentContainer, simulation, visAvailable, target, targetNice);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* 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;
|
package se.sics.cooja.mspmote.plugins;
|
||||||
|
@ -53,7 +53,6 @@ public class MspStackWatcher extends VisPlugin {
|
||||||
private MSP430 cpu;
|
private MSP430 cpu;
|
||||||
private Simulation simulation;
|
private Simulation simulation;
|
||||||
private Observer stackObserver = null;
|
private Observer stackObserver = null;
|
||||||
private Observer logObserver = null;
|
|
||||||
private JButton startButton;
|
private JButton startButton;
|
||||||
private JButton stopButton;
|
private JButton stopButton;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue