removed public static JFrame frame variable. components should instead access the top parent container via getTopParentContainer()
This commit is contained in:
parent
27ac84d009
commit
6c8151b449
16 changed files with 399 additions and 230 deletions
|
@ -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: CoreComm.java,v 1.10 2007/05/11 10:15:42 fros4943 Exp $
|
* $Id: CoreComm.java,v 1.11 2008/02/12 15:03:02 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja;
|
package se.sics.cooja;
|
||||||
|
@ -99,10 +99,12 @@ public abstract class CoreComm {
|
||||||
* filename
|
* filename
|
||||||
*/
|
*/
|
||||||
public static boolean hasLibraryFileBeenLoaded(File libraryFile) {
|
public static boolean hasLibraryFileBeenLoaded(File libraryFile) {
|
||||||
for (File loadedFile : coreCommFiles)
|
for (File loadedFile : coreCommFiles) {
|
||||||
if (loadedFile != null
|
if (loadedFile != null
|
||||||
&& loadedFile.getName().equals(libraryFile.getName()))
|
&& loadedFile.getName().equals(libraryFile.getName())) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,8 +153,9 @@ public abstract class CoreComm {
|
||||||
destFilename = className + ".java";
|
destFilename = className + ".java";
|
||||||
|
|
||||||
File dir = new File("se/sics/cooja/corecomm");
|
File dir = new File("se/sics/cooja/corecomm");
|
||||||
if (!dir.exists())
|
if (!dir.exists()) {
|
||||||
dir.mkdirs();
|
dir.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
sourceFileWriter = new BufferedWriter(new OutputStreamWriter(
|
sourceFileWriter = new BufferedWriter(new OutputStreamWriter(
|
||||||
new FileOutputStream("se/sics/cooja/corecomm/" + destFilename)));
|
new FileOutputStream("se/sics/cooja/corecomm/" + destFilename)));
|
||||||
|
@ -168,10 +171,12 @@ public abstract class CoreComm {
|
||||||
templateFileReader.close();
|
templateFileReader.close();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
try {
|
try {
|
||||||
if (sourceFileWriter != null)
|
if (sourceFileWriter != null) {
|
||||||
sourceFileWriter.close();
|
sourceFileWriter.close();
|
||||||
if (templateFileReader != null)
|
}
|
||||||
|
if (templateFileReader != null) {
|
||||||
templateFileReader.close();
|
templateFileReader.close();
|
||||||
|
}
|
||||||
} catch (Exception e2) {
|
} catch (Exception e2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,10 +186,11 @@ public abstract class CoreComm {
|
||||||
}
|
}
|
||||||
|
|
||||||
File genFile = new File("se/sics/cooja/corecomm/" + destFilename);
|
File genFile = new File("se/sics/cooja/corecomm/" + destFilename);
|
||||||
if (genFile.exists())
|
if (genFile.exists()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
throw (MoteTypeCreationException) new MoteTypeCreationException(
|
throw new MoteTypeCreationException(
|
||||||
"Could not generate corecomm source file: " + className + ".java");
|
"Could not generate corecomm source file: " + className + ".java");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,8 +228,9 @@ public abstract class CoreComm {
|
||||||
}
|
}
|
||||||
p.waitFor();
|
p.waitFor();
|
||||||
|
|
||||||
if (classFile.exists())
|
if (classFile.exists()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Try including cooja.jar
|
// Try including cooja.jar
|
||||||
cmd = new String[] {
|
cmd = new String[] {
|
||||||
|
@ -246,8 +253,9 @@ public abstract class CoreComm {
|
||||||
}
|
}
|
||||||
p.waitFor();
|
p.waitFor();
|
||||||
|
|
||||||
if (classFile.exists())
|
if (classFile.exists()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
MoteTypeCreationException exception = (MoteTypeCreationException) new MoteTypeCreationException(
|
MoteTypeCreationException exception = (MoteTypeCreationException) new MoteTypeCreationException(
|
||||||
|
@ -282,8 +290,9 @@ public abstract class CoreComm {
|
||||||
throws MoteTypeCreationException {
|
throws MoteTypeCreationException {
|
||||||
Class loadedClass = null;
|
Class loadedClass = null;
|
||||||
try {
|
try {
|
||||||
ClassLoader urlClassLoader = new URLClassLoader(new URL[] { new File(".")
|
ClassLoader urlClassLoader = new URLClassLoader(
|
||||||
.toURL() }, CoreComm.class.getClassLoader());
|
new URL[] { new File(".").toURI().toURL() },
|
||||||
|
CoreComm.class.getClassLoader());
|
||||||
loadedClass = urlClassLoader.loadClass("se.sics.cooja.corecomm."
|
loadedClass = urlClassLoader.loadClass("se.sics.cooja.corecomm."
|
||||||
+ className);
|
+ className);
|
||||||
|
|
||||||
|
@ -296,9 +305,10 @@ public abstract class CoreComm {
|
||||||
"Could not load corecomm class file: " + className + ".class")
|
"Could not load corecomm class file: " + className + ".class")
|
||||||
.initCause(e);
|
.initCause(e);
|
||||||
}
|
}
|
||||||
if (loadedClass == null)
|
if (loadedClass == null) {
|
||||||
throw (MoteTypeCreationException) new MoteTypeCreationException(
|
throw new MoteTypeCreationException(
|
||||||
"Could not load corecomm class file: " + className + ".class");
|
"Could not load corecomm class file: " + className + ".class");
|
||||||
|
}
|
||||||
|
|
||||||
return loadedClass;
|
return loadedClass;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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: Simulation.java,v 1.18 2007/10/03 14:20:57 fros4943 Exp $
|
* $Id: Simulation.java,v 1.19 2008/02/12 15:03:43 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja;
|
package se.sics.cooja;
|
||||||
|
@ -470,7 +470,7 @@ public class Simulation extends Observable implements Runnable {
|
||||||
// Show configure simulation dialog
|
// Show configure simulation dialog
|
||||||
boolean createdOK = false;
|
boolean createdOK = false;
|
||||||
if (visAvailable) {
|
if (visAvailable) {
|
||||||
createdOK = CreateSimDialog.showDialog(GUI.frame, this);
|
createdOK = CreateSimDialog.showDialog(GUI.getTopParentContainer(), this);
|
||||||
} else {
|
} else {
|
||||||
createdOK = true;
|
createdOK = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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: ContikiMoteType.java,v 1.24 2008/02/11 14:00:19 fros4943 Exp $
|
* $Id: ContikiMoteType.java,v 1.25 2008/02/12 15:04:43 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.contikimote;
|
package se.sics.cooja.contikimote;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Container;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.security.*;
|
import java.security.*;
|
||||||
|
@ -202,10 +203,10 @@ public class ContikiMoteType implements MoteType {
|
||||||
return new ContikiMote(this, simulation);
|
return new ContikiMote(this, simulation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean configureAndInit(JFrame parentFrame, Simulation simulation,
|
public boolean configureAndInit(Container parentContainer, Simulation simulation,
|
||||||
boolean visAvailable) throws MoteTypeCreationException {
|
boolean visAvailable) throws MoteTypeCreationException {
|
||||||
if (visAvailable) {
|
if (visAvailable) {
|
||||||
return ContikiMoteTypeDialog.showDialog(parentFrame, simulation, this);
|
return ContikiMoteTypeDialog.showDialog(parentContainer, simulation, this);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Create temp output directory if not already exists
|
// Create temp output directory if not already exists
|
||||||
|
@ -1401,7 +1402,7 @@ public class ContikiMoteType implements MoteType {
|
||||||
}
|
}
|
||||||
|
|
||||||
mySimulation = simulation;
|
mySimulation = simulation;
|
||||||
boolean createdOK = configureAndInit(GUI.frame, simulation, visAvailable);
|
boolean createdOK = configureAndInit(GUI.getTopParentContainer(), simulation, visAvailable);
|
||||||
return createdOK;
|
return createdOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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: ContikiMoteTypeDialog.java,v 1.39 2008/01/08 12:33:25 fros4943 Exp $
|
* $Id: ContikiMoteTypeDialog.java,v 1.40 2008/02/12 15:04:20 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.contikimote;
|
package se.sics.cooja.contikimote;
|
||||||
|
@ -116,19 +116,29 @@ public class ContikiMoteTypeDialog extends JDialog {
|
||||||
* Shows a dialog for configuring a Contiki mote type and compiling the shared
|
* Shows a dialog for configuring a Contiki mote type and compiling the shared
|
||||||
* library it uses.
|
* library it uses.
|
||||||
*
|
*
|
||||||
* @param parentFrame
|
* @param parentContainer
|
||||||
* Parent frame for dialog
|
* Parent container for dialog
|
||||||
* @param simulation
|
* @param simulation
|
||||||
* Simulation holding (or that will hold) mote type
|
* Simulation holding (or that will hold) mote type
|
||||||
* @param moteTypeToConfigure
|
* @param moteTypeToConfigure
|
||||||
* Mote type to configure
|
* Mote type to configure
|
||||||
* @return True if compilation succeded and library is ready to be loaded
|
* @return True if compilation succeeded and library is ready to be loaded
|
||||||
*/
|
*/
|
||||||
public static boolean showDialog(Frame parentFrame, Simulation simulation,
|
public static boolean showDialog(Container parentContainer, Simulation simulation,
|
||||||
ContikiMoteType moteTypeToConfigure) {
|
ContikiMoteType moteTypeToConfigure) {
|
||||||
|
|
||||||
final ContikiMoteTypeDialog myDialog = new ContikiMoteTypeDialog(
|
ContikiMoteTypeDialog myDialog = null;
|
||||||
parentFrame);
|
if (parentContainer instanceof Window) {
|
||||||
|
myDialog = new ContikiMoteTypeDialog((Window) parentContainer);
|
||||||
|
} else if (parentContainer instanceof Dialog) {
|
||||||
|
myDialog = new ContikiMoteTypeDialog((Dialog) parentContainer);
|
||||||
|
} else if (parentContainer instanceof Frame) {
|
||||||
|
myDialog = new ContikiMoteTypeDialog((Frame) parentContainer);
|
||||||
|
} else {
|
||||||
|
logger.fatal("Unknown parent container type: " + parentContainer);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
myDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
|
myDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
|
||||||
|
|
||||||
myDialog.myMoteType = moteTypeToConfigure;
|
myDialog.myMoteType = moteTypeToConfigure;
|
||||||
|
@ -403,7 +413,7 @@ public class ContikiMoteTypeDialog extends JDialog {
|
||||||
|
|
||||||
// Set position and focus of dialog
|
// Set position and focus of dialog
|
||||||
myDialog.pack();
|
myDialog.pack();
|
||||||
myDialog.setLocationRelativeTo(parentFrame);
|
myDialog.setLocationRelativeTo(parentContainer);
|
||||||
myDialog.textDescription.requestFocus();
|
myDialog.textDescription.requestFocus();
|
||||||
myDialog.textDescription.select(0, myDialog.textDescription.getText()
|
myDialog.textDescription.select(0, myDialog.textDescription.getText()
|
||||||
.length());
|
.length());
|
||||||
|
@ -428,9 +438,20 @@ public class ContikiMoteTypeDialog extends JDialog {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ContikiMoteTypeDialog(Dialog dialog) {
|
||||||
|
super(dialog, "Add Mote Type", ModalityType.TOOLKIT_MODAL);
|
||||||
|
setupDialog();
|
||||||
|
}
|
||||||
|
private ContikiMoteTypeDialog(Window window) {
|
||||||
|
super(window, "Add Mote Type", ModalityType.TOOLKIT_MODAL);
|
||||||
|
setupDialog();
|
||||||
|
}
|
||||||
private ContikiMoteTypeDialog(Frame frame) {
|
private ContikiMoteTypeDialog(Frame frame) {
|
||||||
super(frame, "Add Mote Type", true);
|
super(frame, "Add Mote Type", ModalityType.TOOLKIT_MODAL);
|
||||||
|
setupDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupDialog() {
|
||||||
myDialog = this;
|
myDialog = this;
|
||||||
|
|
||||||
JLabel label;
|
JLabel label;
|
||||||
|
@ -2513,8 +2534,8 @@ public class ContikiMoteTypeDialog extends JDialog {
|
||||||
// Find and load the mote interface classes
|
// Find and load the mote interface classes
|
||||||
for (String moteInterface : moteInterfaces) {
|
for (String moteInterface : moteInterfaces) {
|
||||||
try {
|
try {
|
||||||
Class<? extends MoteInterface> newMoteInterfaceClass = classLoader
|
Class<? extends MoteInterface> newMoteInterfaceClass =
|
||||||
.loadClass(moteInterface).asSubclass(MoteInterface.class);
|
myGUI.tryLoadClass(this, MoteInterface.class, moteInterface);
|
||||||
moteIntfClasses.add(newMoteInterfaceClass);
|
moteIntfClasses.add(newMoteInterfaceClass);
|
||||||
// logger.info("Loaded mote interface: " + newMoteInterfaceClass);
|
// logger.info("Loaded mote interface: " + newMoteInterfaceClass);
|
||||||
} catch (Exception ce) {
|
} catch (Exception ce) {
|
||||||
|
|
|
@ -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: AddMoteDialog.java,v 1.4 2007/11/29 05:37:35 fros4943 Exp $
|
* $Id: AddMoteDialog.java,v 1.5 2008/02/12 15:05:14 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.dialogs;
|
package se.sics.cooja.dialogs;
|
||||||
|
@ -74,19 +74,30 @@ public class AddMoteDialog extends JDialog {
|
||||||
* Shows a dialog which enables a user to create and add motes of the given
|
* Shows a dialog which enables a user to create and add motes of the given
|
||||||
* type.
|
* type.
|
||||||
*
|
*
|
||||||
* @param parentFrame
|
* @param parentContainer
|
||||||
* Parent frame for dialog
|
* Parent container for dialog
|
||||||
* @param simulation
|
* @param simulation
|
||||||
* Simulation
|
* Simulation
|
||||||
* @param moteType
|
* @param moteType
|
||||||
* Mote type
|
* Mote type
|
||||||
* @return New motes or null if aborted
|
* @return New motes or null if aborted
|
||||||
*/
|
*/
|
||||||
public static Vector<Mote> showDialog(Frame parentFrame,
|
public static Vector<Mote> showDialog(Container parentContainer,
|
||||||
Simulation simulation, MoteType moteType) {
|
Simulation simulation, MoteType moteType) {
|
||||||
|
|
||||||
AddMoteDialog myDialog = new AddMoteDialog(parentFrame, simulation, moteType);
|
AddMoteDialog myDialog = null;
|
||||||
myDialog.setLocationRelativeTo(parentFrame);
|
if (parentContainer instanceof Window) {
|
||||||
|
myDialog = new AddMoteDialog((Window)parentContainer, simulation, moteType);
|
||||||
|
} else if (parentContainer instanceof Dialog) {
|
||||||
|
myDialog = new AddMoteDialog((Dialog)parentContainer, simulation, moteType);
|
||||||
|
} else if (parentContainer instanceof Frame) {
|
||||||
|
myDialog = new AddMoteDialog((Frame)parentContainer, simulation, moteType);
|
||||||
|
} else {
|
||||||
|
logger.fatal("Unknown parent container type: " + parentContainer);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
myDialog.setLocationRelativeTo(parentContainer);
|
||||||
myDialog.checkSettings();
|
myDialog.checkSettings();
|
||||||
|
|
||||||
if (myDialog != null) {
|
if (myDialog != null) {
|
||||||
|
@ -96,7 +107,19 @@ public class AddMoteDialog extends JDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
private AddMoteDialog(Frame frame, Simulation simulation, MoteType moteType) {
|
private AddMoteDialog(Frame frame, Simulation simulation, MoteType moteType) {
|
||||||
super(frame, "Add motes (" + moteType.getDescription() + ")", true);
|
super(frame, "Add motes (" + moteType.getDescription() + ")", ModalityType.APPLICATION_MODAL);
|
||||||
|
setupDialog(simulation, moteType);
|
||||||
|
}
|
||||||
|
private AddMoteDialog(Window window, Simulation simulation, MoteType moteType) {
|
||||||
|
super(window, "Add motes (" + moteType.getDescription() + ")", ModalityType.APPLICATION_MODAL);
|
||||||
|
setupDialog(simulation, moteType);
|
||||||
|
}
|
||||||
|
private AddMoteDialog(Dialog dialog, Simulation simulation, MoteType moteType) {
|
||||||
|
super(dialog, "Add motes (" + moteType.getDescription() + ")", ModalityType.APPLICATION_MODAL);
|
||||||
|
setupDialog(simulation, moteType);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupDialog(Simulation simulation, MoteType moteType) {
|
||||||
this.moteType = moteType;
|
this.moteType = moteType;
|
||||||
this.simulation = simulation;
|
this.simulation = simulation;
|
||||||
|
|
||||||
|
|
|
@ -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: CreateSimDialog.java,v 1.7 2007/09/30 12:03:49 fros4943 Exp $
|
* $Id: CreateSimDialog.java,v 1.8 2008/02/12 15:06:09 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.dialogs;
|
package se.sics.cooja.dialogs;
|
||||||
|
@ -70,12 +70,22 @@ public class CreateSimDialog extends JDialog {
|
||||||
/**
|
/**
|
||||||
* Shows a dialog for configuring a simulation.
|
* Shows a dialog for configuring a simulation.
|
||||||
*
|
*
|
||||||
* @param parentFrame Parent frame for dialog
|
* @param parentContainer Parent container for dialog
|
||||||
* @param simulationToConfigure Simulation to configure
|
* @param simulationToConfigure Simulation to configure
|
||||||
* @return True if simulation configured correctly
|
* @return True if simulation configured correctly
|
||||||
*/
|
*/
|
||||||
public static boolean showDialog(Frame parentFrame, Simulation simulationToConfigure) {
|
public static boolean showDialog(Container parentContainer, Simulation simulationToConfigure) {
|
||||||
final CreateSimDialog myDialog = new CreateSimDialog(parentFrame, simulationToConfigure.getGUI());
|
final CreateSimDialog myDialog;
|
||||||
|
if (parentContainer instanceof Window) {
|
||||||
|
myDialog = new CreateSimDialog((Window) parentContainer, simulationToConfigure.getGUI());
|
||||||
|
} else if (parentContainer instanceof Dialog) {
|
||||||
|
myDialog = new CreateSimDialog((Dialog) parentContainer, simulationToConfigure.getGUI());
|
||||||
|
} else if (parentContainer instanceof Frame) {
|
||||||
|
myDialog = new CreateSimDialog((Frame) parentContainer, simulationToConfigure.getGUI());
|
||||||
|
} else {
|
||||||
|
logger.fatal("Unknown parent container type: " + parentContainer);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
myDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
|
myDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
|
||||||
myDialog.addWindowListener(new WindowListener() {
|
myDialog.addWindowListener(new WindowListener() {
|
||||||
|
@ -149,7 +159,7 @@ public class CreateSimDialog extends JDialog {
|
||||||
|
|
||||||
|
|
||||||
// Set position and focus of dialog
|
// Set position and focus of dialog
|
||||||
myDialog.setLocationRelativeTo(parentFrame);
|
myDialog.setLocationRelativeTo(parentContainer);
|
||||||
myDialog.title.requestFocus();
|
myDialog.title.requestFocus();
|
||||||
myDialog.title.select(0, myDialog.title.getText().length());
|
myDialog.title.select(0, myDialog.title.getText().length());
|
||||||
|
|
||||||
|
@ -172,9 +182,20 @@ public class CreateSimDialog extends JDialog {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private CreateSimDialog(Dialog dialog, GUI gui) {
|
||||||
|
super(dialog, "Create new simulation", ModalityType.TOOLKIT_MODAL);
|
||||||
|
setupDialog(gui);
|
||||||
|
}
|
||||||
|
private CreateSimDialog(Window window, GUI gui) {
|
||||||
|
super(window, "Create new simulation", ModalityType.TOOLKIT_MODAL);
|
||||||
|
setupDialog(gui);
|
||||||
|
}
|
||||||
private CreateSimDialog(Frame frame, GUI gui) {
|
private CreateSimDialog(Frame frame, GUI gui) {
|
||||||
super(frame, "Create new simulation", true);
|
super(frame, "Create new simulation", ModalityType.TOOLKIT_MODAL);
|
||||||
|
setupDialog(gui);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupDialog(GUI gui) {
|
||||||
myDialog = this;
|
myDialog = this;
|
||||||
myGUI = gui;
|
myGUI = gui;
|
||||||
|
|
||||||
|
|
|
@ -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: ExternalToolsDialog.java,v 1.7 2007/09/28 07:21:21 fros4943 Exp $
|
* $Id: ExternalToolsDialog.java,v 1.8 2008/02/12 15:06:09 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.dialogs;
|
package se.sics.cooja.dialogs;
|
||||||
|
@ -61,21 +61,43 @@ public class ExternalToolsDialog extends JDialog {
|
||||||
/**
|
/**
|
||||||
* Creates a dialog for viewing/editing external tools settings.
|
* Creates a dialog for viewing/editing external tools settings.
|
||||||
*
|
*
|
||||||
* @param parentFrame
|
* @param parentContainer
|
||||||
* Parent frame for dialog
|
* Parent container for dialog
|
||||||
*/
|
*/
|
||||||
public static void showDialog(Frame parentFrame) {
|
public static void showDialog(Container parentContainer) {
|
||||||
ExternalToolsDialog myDialog = new ExternalToolsDialog(parentFrame);
|
|
||||||
myDialog.setLocationRelativeTo(parentFrame);
|
ExternalToolsDialog myDialog = null;
|
||||||
|
if (parentContainer instanceof Window) {
|
||||||
|
myDialog = new ExternalToolsDialog((Window) parentContainer);
|
||||||
|
} else if (parentContainer instanceof Dialog) {
|
||||||
|
myDialog = new ExternalToolsDialog((Dialog) parentContainer);
|
||||||
|
} else if (parentContainer instanceof Frame) {
|
||||||
|
myDialog = new ExternalToolsDialog((Frame) parentContainer);
|
||||||
|
} else {
|
||||||
|
logger.fatal("Unknown parent container type: " + parentContainer);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
myDialog.setLocationRelativeTo(parentContainer);
|
||||||
|
|
||||||
if (myDialog != null) {
|
if (myDialog != null) {
|
||||||
myDialog.setVisible(true);
|
myDialog.setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ExternalToolsDialog(Dialog dialog) {
|
||||||
|
super(dialog, "Edit Settings", ModalityType.TOOLKIT_MODAL);
|
||||||
|
setupDialog();
|
||||||
|
}
|
||||||
|
private ExternalToolsDialog(Window window) {
|
||||||
|
super(window, "Edit Settings", ModalityType.TOOLKIT_MODAL);
|
||||||
|
setupDialog();
|
||||||
|
}
|
||||||
private ExternalToolsDialog(Frame frame) {
|
private ExternalToolsDialog(Frame frame) {
|
||||||
super(frame, "Edit Settings", true);
|
super(frame, "Edit Settings", ModalityType.TOOLKIT_MODAL);
|
||||||
|
setupDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupDialog() {
|
||||||
myDialog = this;
|
myDialog = this;
|
||||||
|
|
||||||
JLabel label;
|
JLabel label;
|
||||||
|
|
|
@ -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: ProjectDirectoriesDialog.java,v 1.4 2007/08/21 14:18:04 fros4943 Exp $
|
* $Id: ProjectDirectoriesDialog.java,v 1.5 2008/02/12 15:06:09 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.dialogs;
|
package se.sics.cooja.dialogs;
|
||||||
|
@ -63,30 +63,37 @@ public class ProjectDirectoriesDialog extends JDialog {
|
||||||
private List changableProjectsList = new List();
|
private List changableProjectsList = new List();
|
||||||
private List fixedProjectsList = null;
|
private List fixedProjectsList = null;
|
||||||
private Vector<File> changableProjects = null;
|
private Vector<File> changableProjects = null;
|
||||||
private Vector<File> fixedProjects = null;
|
|
||||||
|
|
||||||
private ProjectDirectoriesDialog myDialog;
|
private ProjectDirectoriesDialog myDialog;
|
||||||
private Frame myParentFrame = null;
|
|
||||||
private Dialog myParentDialog = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows user to alter the given project directories list by adding new,
|
* Allows user to alter the given project directories list by adding new,
|
||||||
* reordering or removing project directories. Only the changable project directories
|
* reordering or removing project directories. Only the changable project directories
|
||||||
* can be altered.
|
* can be altered.
|
||||||
*
|
*
|
||||||
* @param parentFrame
|
* @param parentContainer
|
||||||
* Parent frame
|
* Parent container
|
||||||
* @param changableProjects
|
* @param changableProjects
|
||||||
* Changeable project directories
|
* Changeable project directories
|
||||||
* @param fixedProjects
|
* @param fixedProjects
|
||||||
* Fixed project directory
|
* Fixed project directory
|
||||||
* @return Null if dialog aborted, else the new CHANGEABLE project directory list.
|
* @return Null if dialog aborted, else the new CHANGEABLE project directory list.
|
||||||
*/
|
*/
|
||||||
public static Vector<File> showDialog(Frame parentFrame,
|
public static Vector<File> showDialog(Container parentContainer,
|
||||||
Vector<File> changableProjects, Vector<File> fixedProjects) {
|
Vector<File> changableProjects, Vector<File> fixedProjects) {
|
||||||
ProjectDirectoriesDialog myDialog = new ProjectDirectoriesDialog(parentFrame,
|
|
||||||
changableProjects, fixedProjects);
|
ProjectDirectoriesDialog myDialog = null;
|
||||||
myDialog.setLocationRelativeTo(parentFrame);
|
if (parentContainer instanceof Window) {
|
||||||
|
myDialog = new ProjectDirectoriesDialog((Window) parentContainer, changableProjects, fixedProjects);
|
||||||
|
} else if (parentContainer instanceof Dialog) {
|
||||||
|
myDialog = new ProjectDirectoriesDialog((Dialog) parentContainer, changableProjects, fixedProjects);
|
||||||
|
} else if (parentContainer instanceof Frame) {
|
||||||
|
myDialog = new ProjectDirectoriesDialog((Frame) parentContainer, changableProjects, fixedProjects);
|
||||||
|
} else {
|
||||||
|
logger.fatal("Unknown parent container type: " + parentContainer);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
myDialog.setLocationRelativeTo(parentContainer);
|
||||||
|
|
||||||
if (myDialog != null) {
|
if (myDialog != null) {
|
||||||
myDialog.setVisible(true);
|
myDialog.setVisible(true);
|
||||||
|
@ -123,19 +130,23 @@ public class ProjectDirectoriesDialog extends JDialog {
|
||||||
|
|
||||||
private ProjectDirectoriesDialog(Frame frame, Vector<File> changableProjects,
|
private ProjectDirectoriesDialog(Frame frame, Vector<File> changableProjects,
|
||||||
Vector<File> fixedProjects) {
|
Vector<File> fixedProjects) {
|
||||||
super(frame, "Manage Project Directories", true);
|
super(frame, "Manage Project Directories", ModalityType.APPLICATION_MODAL);
|
||||||
myParentFrame = frame;
|
setupDialog(changableProjects, fixedProjects);
|
||||||
init(changableProjects, fixedProjects);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ProjectDirectoriesDialog(Dialog dialog, Vector<File> changableProjects,
|
private ProjectDirectoriesDialog(Dialog dialog, Vector<File> changableProjects,
|
||||||
Vector<File> fixedProjects) {
|
Vector<File> fixedProjects) {
|
||||||
super(dialog, "Manage Project Directories", true);
|
super(dialog, "Manage Project Directories", ModalityType.APPLICATION_MODAL);
|
||||||
myParentDialog = dialog;
|
setupDialog(changableProjects, fixedProjects);
|
||||||
init(changableProjects, fixedProjects);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init(Vector<File> changablePlatforms, Vector<File> fixedProjects) {
|
private ProjectDirectoriesDialog(Window window, Vector<File> changableProjects,
|
||||||
|
Vector<File> fixedProjects) {
|
||||||
|
super(window, "Manage Project Directories", ModalityType.APPLICATION_MODAL);
|
||||||
|
setupDialog(changableProjects, fixedProjects);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupDialog(Vector<File> changablePlatforms, Vector<File> fixedProjects) {
|
||||||
myDialog = this;
|
myDialog = this;
|
||||||
|
|
||||||
JPanel mainPane = new JPanel();
|
JPanel mainPane = new JPanel();
|
||||||
|
@ -339,11 +350,7 @@ public class ProjectDirectoriesDialog extends JDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show merged configuration
|
// Show merged configuration
|
||||||
if (myParentFrame != null) {
|
ConfigViewer.showDialog(ProjectDirectoriesDialog.this, config);
|
||||||
ConfigViewer.showDialog(myParentFrame, config);
|
|
||||||
} else {
|
|
||||||
ConfigViewer.showDialog(myParentDialog, config);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
addRemovePane.add(button);
|
addRemovePane.add(button);
|
||||||
|
@ -353,10 +360,10 @@ public class ProjectDirectoriesDialog extends JDialog {
|
||||||
button = new JButton("Add manually");
|
button = new JButton("Add manually");
|
||||||
button.addActionListener(new ActionListener() {
|
button.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
ProjectDirectoryInputDialog pathDialog = new ProjectDirectoryInputDialog(myParentFrame);
|
ProjectDirectoryInputDialog pathDialog = new ProjectDirectoryInputDialog(ProjectDirectoriesDialog.this);
|
||||||
pathDialog.pack();
|
pathDialog.pack();
|
||||||
|
|
||||||
pathDialog.setLocationRelativeTo(myParentFrame);
|
pathDialog.setLocationRelativeTo(ProjectDirectoriesDialog.this);
|
||||||
pathDialog.setVisible(true);
|
pathDialog.setVisible(true);
|
||||||
|
|
||||||
File projectPath = pathDialog.getProjectDirectory();
|
File projectPath = pathDialog.getProjectDirectory();
|
||||||
|
|
|
@ -21,9 +21,20 @@ class ProjectDirectoryInputDialog extends JDialog implements ActionListener, Pro
|
||||||
private String buttonAdd = "Add";
|
private String buttonAdd = "Add";
|
||||||
private String buttonCancel = "Cancel";
|
private String buttonCancel = "Cancel";
|
||||||
|
|
||||||
public ProjectDirectoryInputDialog(Frame parent) {
|
public ProjectDirectoryInputDialog(Window window) {
|
||||||
super(parent, true);
|
super(window, ModalityType.APPLICATION_MODAL);
|
||||||
|
setupDialog();
|
||||||
|
}
|
||||||
|
public ProjectDirectoryInputDialog(Dialog dialog) {
|
||||||
|
super(dialog, ModalityType.APPLICATION_MODAL);
|
||||||
|
setupDialog();
|
||||||
|
}
|
||||||
|
public ProjectDirectoryInputDialog(Frame frame) {
|
||||||
|
super(frame, ModalityType.APPLICATION_MODAL);
|
||||||
|
setupDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setupDialog() {
|
||||||
setTitle("Enter path");
|
setTitle("Enter path");
|
||||||
|
|
||||||
textField = new JTextField(10);
|
textField = new JTextField(10);
|
||||||
|
|
|
@ -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: MantisMoteType.java,v 1.5 2007/09/18 11:33:58 fros4943 Exp $
|
* $Id: MantisMoteType.java,v 1.6 2008/02/12 15:10:49 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.mantismote;
|
package se.sics.cooja.mantismote;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Container;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
@ -40,7 +41,6 @@ import java.util.regex.Pattern;
|
||||||
|
|
||||||
import javax.swing.Box;
|
import javax.swing.Box;
|
||||||
import javax.swing.BoxLayout;
|
import javax.swing.BoxLayout;
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
@ -106,8 +106,9 @@ public class MantisMoteType implements MoteType {
|
||||||
*/
|
*/
|
||||||
public MantisMoteType(File libFile, File objFile,
|
public MantisMoteType(File libFile, File objFile,
|
||||||
Vector<Class<? extends MoteInterface>> moteInterfaceClasses) {
|
Vector<Class<? extends MoteInterface>> moteInterfaceClasses) {
|
||||||
if (!doInit(libFile, objFile, moteInterfaceClasses))
|
if (!doInit(libFile, objFile, moteInterfaceClasses)) {
|
||||||
logger.fatal("Mantis mote type creation failed!");
|
logger.fatal("Mantis mote type creation failed!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -360,9 +361,11 @@ public class MantisMoteType implements MoteType {
|
||||||
return new MantisMote(this, mySimulation);
|
return new MantisMote(this, mySimulation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean configureAndInit(JFrame parentFrame, Simulation simulation, boolean visAvailable) {
|
public boolean configureAndInit(Container parentContainer, Simulation simulation, boolean visAvailable) {
|
||||||
if (!visAvailable) logger.fatal(">>>>>>> NOT IMPLEMENTED");
|
if (!visAvailable) {
|
||||||
return MantisMoteTypeDialog.showDialog(parentFrame, simulation, this);
|
logger.fatal(">>>>>>> NOT IMPLEMENTED");
|
||||||
|
}
|
||||||
|
return MantisMoteTypeDialog.showDialog(parentContainer, simulation, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<Element> getConfigXML() {
|
public Collection<Element> getConfigXML() {
|
||||||
|
@ -406,7 +409,7 @@ public class MantisMoteType implements MoteType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean createdOK = configureAndInit(GUI.frame, simulation, visAvailable);
|
boolean createdOK = configureAndInit(GUI.getTopParentContainer(), simulation, visAvailable);
|
||||||
return createdOK;
|
return createdOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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: MantisMoteTypeDialog.java,v 1.5 2007/03/24 00:44:55 fros4943 Exp $
|
* $Id: MantisMoteTypeDialog.java,v 1.6 2008/02/12 15:10:49 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.mantismote;
|
package se.sics.cooja.mantismote;
|
||||||
|
@ -93,19 +93,28 @@ public class MantisMoteTypeDialog extends JDialog {
|
||||||
/**
|
/**
|
||||||
* Shows a dialog for configuring a Mantis mote type.
|
* Shows a dialog for configuring a Mantis mote type.
|
||||||
*
|
*
|
||||||
* @param parentFrame
|
* @param parentContainer
|
||||||
* Parent frame for dialog
|
* Parent container for dialog
|
||||||
* @param simulation
|
* @param simulation
|
||||||
* Simulation holding (or that will hold) mote type
|
* Simulation holding (or that will hold) mote type
|
||||||
* @param moteTypeToConfigure
|
* @param moteTypeToConfigure
|
||||||
* Mote type to configure
|
* Mote type to configure
|
||||||
* @return True if mote type configuration succeded and library is ready to be loaded
|
* @return True if mote type configuration succeded and library is ready to be loaded
|
||||||
*/
|
*/
|
||||||
public static boolean showDialog(Frame parentFrame, Simulation simulation,
|
public static boolean showDialog(Container parentContainer, Simulation simulation,
|
||||||
MantisMoteType moteTypeToConfigure) {
|
MantisMoteType moteTypeToConfigure) {
|
||||||
|
|
||||||
final MantisMoteTypeDialog myDialog = new MantisMoteTypeDialog(
|
MantisMoteTypeDialog myDialog = null;
|
||||||
parentFrame);
|
if (parentContainer instanceof Window) {
|
||||||
|
myDialog = new MantisMoteTypeDialog((Window) parentContainer);
|
||||||
|
} else if (parentContainer instanceof Dialog) {
|
||||||
|
myDialog = new MantisMoteTypeDialog((Dialog) parentContainer);
|
||||||
|
} else if (parentContainer instanceof Frame) {
|
||||||
|
myDialog = new MantisMoteTypeDialog((Frame) parentContainer);
|
||||||
|
} else {
|
||||||
|
logger.fatal("Unknown parent container type: " + parentContainer);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
myDialog.myMoteType = moteTypeToConfigure;
|
myDialog.myMoteType = moteTypeToConfigure;
|
||||||
myDialog.allOtherTypes = simulation.getMoteTypes();
|
myDialog.allOtherTypes = simulation.getMoteTypes();
|
||||||
|
@ -172,7 +181,7 @@ public class MantisMoteTypeDialog extends JDialog {
|
||||||
|
|
||||||
// Set position and focus of dialog
|
// Set position and focus of dialog
|
||||||
myDialog.pack();
|
myDialog.pack();
|
||||||
myDialog.setLocationRelativeTo(parentFrame);
|
myDialog.setLocationRelativeTo(parentContainer);
|
||||||
myDialog.textDescription.requestFocus();
|
myDialog.textDescription.requestFocus();
|
||||||
myDialog.textDescription.select(0, myDialog.textDescription.getText().length());
|
myDialog.textDescription.select(0, myDialog.textDescription.getText().length());
|
||||||
myDialog.pathsWereUpdated();
|
myDialog.pathsWereUpdated();
|
||||||
|
@ -185,9 +194,20 @@ public class MantisMoteTypeDialog extends JDialog {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private MantisMoteTypeDialog(Dialog dialog) {
|
||||||
|
super(dialog, "Configure Mantis Mote Type", ModalityType.TOOLKIT_MODAL);
|
||||||
|
setupDialog();
|
||||||
|
}
|
||||||
|
private MantisMoteTypeDialog(Window window) {
|
||||||
|
super(window, "Configure Mantis Mote Type", ModalityType.TOOLKIT_MODAL);
|
||||||
|
setupDialog();
|
||||||
|
}
|
||||||
private MantisMoteTypeDialog(Frame frame) {
|
private MantisMoteTypeDialog(Frame frame) {
|
||||||
super(frame, "Configure Mantis Mote Type", true);
|
super(frame, "Configure Mantis Mote Type", ModalityType.TOOLKIT_MODAL);
|
||||||
|
setupDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupDialog() {
|
||||||
myDialog = this;
|
myDialog = this;
|
||||||
|
|
||||||
JLabel label;
|
JLabel label;
|
||||||
|
@ -361,8 +381,9 @@ public class MantisMoteTypeDialog extends JDialog {
|
||||||
if (compilationThread != null && compilationThread.isAlive()) {
|
if (compilationThread != null && compilationThread.isAlive()) {
|
||||||
compilationThread.interrupt();
|
compilationThread.interrupt();
|
||||||
}
|
}
|
||||||
if (progressDialog != null && progressDialog.isDisplayable())
|
if (progressDialog != null && progressDialog.isDisplayable()) {
|
||||||
progressDialog.dispose();
|
progressDialog.dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -398,10 +419,11 @@ public class MantisMoteTypeDialog extends JDialog {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
libraryCreatedOK = false;
|
libraryCreatedOK = false;
|
||||||
progressBar.setBackground(Color.ORANGE);
|
progressBar.setBackground(Color.ORANGE);
|
||||||
if (e.getMessage() != null)
|
if (e.getMessage() != null) {
|
||||||
progressBar.setString("source file generation failed: " + e.getMessage());
|
progressBar.setString("source file generation failed: " + e.getMessage());
|
||||||
else
|
} else {
|
||||||
progressBar.setString("source file generation failed");
|
progressBar.setString("source file generation failed");
|
||||||
|
}
|
||||||
|
|
||||||
progressBar.setIndeterminate(false);
|
progressBar.setIndeterminate(false);
|
||||||
progressBar.setValue(0);
|
progressBar.setValue(0);
|
||||||
|
@ -445,8 +467,9 @@ public class MantisMoteTypeDialog extends JDialog {
|
||||||
libraryCreatedOK = false;
|
libraryCreatedOK = false;
|
||||||
} else {
|
} else {
|
||||||
libraryCreatedOK = true;
|
libraryCreatedOK = true;
|
||||||
if (!libFile.exists())
|
if (!libFile.exists()) {
|
||||||
libraryCreatedOK = false;
|
libraryCreatedOK = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (libraryCreatedOK) {
|
if (libraryCreatedOK) {
|
||||||
|
@ -515,10 +538,12 @@ public class MantisMoteTypeDialog extends JDialog {
|
||||||
sourceFile.close();
|
sourceFile.close();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
try {
|
try {
|
||||||
if (destFile != null)
|
if (destFile != null) {
|
||||||
destFile.close();
|
destFile.close();
|
||||||
if (sourceFile != null)
|
}
|
||||||
|
if (sourceFile != null) {
|
||||||
sourceFile.close();
|
sourceFile.close();
|
||||||
|
}
|
||||||
} catch (Exception e2) {
|
} catch (Exception e2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -545,42 +570,48 @@ public class MantisMoteTypeDialog extends JDialog {
|
||||||
|
|
||||||
// Check needed files
|
// Check needed files
|
||||||
if (!workingDir.exists()) {
|
if (!workingDir.exists()) {
|
||||||
if (errorStream != null)
|
if (errorStream != null) {
|
||||||
errorStream.println("Bad paths");
|
errorStream.println("Bad paths");
|
||||||
|
}
|
||||||
logger.fatal("Working directory does not exist");
|
logger.fatal("Working directory does not exist");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!workingDir.isDirectory()) {
|
if (!workingDir.isDirectory()) {
|
||||||
if (errorStream != null)
|
if (errorStream != null) {
|
||||||
errorStream.println("Bad paths");
|
errorStream.println("Bad paths");
|
||||||
|
}
|
||||||
logger.fatal("Working directory is not a directory");
|
logger.fatal("Working directory is not a directory");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (libFile.exists()) {
|
if (libFile.exists()) {
|
||||||
if (errorStream != null)
|
if (errorStream != null) {
|
||||||
errorStream.println("Bad output filenames");
|
errorStream.println("Bad output filenames");
|
||||||
|
}
|
||||||
logger.fatal("Library already exists");
|
logger.fatal("Library already exists");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sourceFile.exists()) {
|
if (!sourceFile.exists()) {
|
||||||
if (errorStream != null)
|
if (errorStream != null) {
|
||||||
errorStream.println("Bad dependency files");
|
errorStream.println("Bad dependency files");
|
||||||
|
}
|
||||||
logger.fatal("Source file not found");
|
logger.fatal("Source file not found");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!binFile.exists()) {
|
if (!binFile.exists()) {
|
||||||
if (errorStream != null)
|
if (errorStream != null) {
|
||||||
errorStream.println("Bad dependency files");
|
errorStream.println("Bad dependency files");
|
||||||
|
}
|
||||||
logger.fatal("Link object file not found");
|
logger.fatal("Link object file not found");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CoreComm.hasLibraryFileBeenLoaded(libFile)) {
|
if (CoreComm.hasLibraryFileBeenLoaded(libFile)) {
|
||||||
if (errorStream != null)
|
if (errorStream != null) {
|
||||||
errorStream.println("Bad output filenames");
|
errorStream.println("Bad output filenames");
|
||||||
|
}
|
||||||
logger.fatal("A library has already been loaded with the same name before");
|
logger.fatal("A library has already been loaded with the same name before");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -606,8 +637,9 @@ public class MantisMoteTypeDialog extends JDialog {
|
||||||
String readLine;
|
String readLine;
|
||||||
try {
|
try {
|
||||||
while ((readLine = input.readLine()) != null) {
|
while ((readLine = input.readLine()) != null) {
|
||||||
if (outputStream != null && readLine != null)
|
if (outputStream != null && readLine != null) {
|
||||||
outputStream.println(readLine);
|
outputStream.println(readLine);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.warn("Error while reading from process");
|
logger.warn("Error while reading from process");
|
||||||
|
@ -620,8 +652,9 @@ public class MantisMoteTypeDialog extends JDialog {
|
||||||
String readLine;
|
String readLine;
|
||||||
try {
|
try {
|
||||||
while ((readLine = err.readLine()) != null) {
|
while ((readLine = err.readLine()) != null) {
|
||||||
if (errorStream != null && readLine != null)
|
if (errorStream != null && readLine != null) {
|
||||||
errorStream.println(readLine);
|
errorStream.println(readLine);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.warn("Error while reading from process");
|
logger.warn("Error while reading from process");
|
||||||
|
@ -722,28 +755,31 @@ public class MantisMoteTypeDialog extends JDialog {
|
||||||
ActionListener,
|
ActionListener,
|
||||||
DocumentListener {
|
DocumentListener {
|
||||||
public void insertUpdate(DocumentEvent e) {
|
public void insertUpdate(DocumentEvent e) {
|
||||||
if (myDialog.isVisible())
|
if (myDialog.isVisible()) {
|
||||||
javax.swing.SwingUtilities.invokeLater(new Runnable() {
|
javax.swing.SwingUtilities.invokeLater(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
pathsWereUpdated();
|
pathsWereUpdated();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public void removeUpdate(DocumentEvent e) {
|
public void removeUpdate(DocumentEvent e) {
|
||||||
if (myDialog.isVisible())
|
if (myDialog.isVisible()) {
|
||||||
javax.swing.SwingUtilities.invokeLater(new Runnable() {
|
javax.swing.SwingUtilities.invokeLater(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
pathsWereUpdated();
|
pathsWereUpdated();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public void changedUpdate(DocumentEvent e) {
|
public void changedUpdate(DocumentEvent e) {
|
||||||
if (myDialog.isVisible())
|
if (myDialog.isVisible()) {
|
||||||
javax.swing.SwingUtilities.invokeLater(new Runnable() {
|
javax.swing.SwingUtilities.invokeLater(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
pathsWereUpdated();
|
pathsWereUpdated();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
if (e.getActionCommand().equals("cancel")) {
|
if (e.getActionCommand().equals("cancel")) {
|
||||||
|
@ -783,8 +819,9 @@ public class MantisMoteTypeDialog extends JDialog {
|
||||||
}
|
}
|
||||||
createButton.setEnabled(libraryCreatedOK = false);
|
createButton.setEnabled(libraryCreatedOK = false);
|
||||||
pathsWereUpdated();
|
pathsWereUpdated();
|
||||||
} else
|
} else {
|
||||||
logger.warn("Unhandled action: " + e.getActionCommand());
|
logger.warn("Unhandled action: " + e.getActionCommand());
|
||||||
|
}
|
||||||
|
|
||||||
createButton.setEnabled(libraryCreatedOK = false);
|
createButton.setEnabled(libraryCreatedOK = false);
|
||||||
|
|
||||||
|
|
|
@ -24,12 +24,13 @@
|
||||||
* (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: AbstractApplicationMoteType.java,v 1.1 2007/05/31 07:21:29 fros4943 Exp $
|
* $Id: AbstractApplicationMoteType.java,v 1.2 2008/02/12 15:10:49 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.motes;
|
package se.sics.cooja.motes;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Container;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
@ -62,7 +63,7 @@ public abstract class AbstractApplicationMoteType implements MoteType {
|
||||||
description = "Application Mote Type #" + identifier;
|
description = "Application Mote Type #" + identifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean configureAndInit(JFrame parentFrame, Simulation simulation, boolean visAvailable) {
|
public boolean configureAndInit(Container parentContainer, Simulation simulation, boolean visAvailable) {
|
||||||
|
|
||||||
if (identifier == null) {
|
if (identifier == null) {
|
||||||
// Create unique identifier
|
// Create unique identifier
|
||||||
|
@ -233,7 +234,7 @@ public abstract class AbstractApplicationMoteType implements MoteType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean createdOK = configureAndInit(GUI.frame, simulation, visAvailable);
|
boolean createdOK = configureAndInit(GUI.getTopParentContainer(), simulation, visAvailable);
|
||||||
return createdOK;
|
return createdOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
package se.sics.cooja.motes;
|
package se.sics.cooja.motes;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Container;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
@ -76,7 +77,7 @@ public class DisturberMoteType implements MoteType {
|
||||||
return new DisturberMote(this, simulation);
|
return new DisturberMote(this, simulation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean configureAndInit(JFrame parentFrame, Simulation simulation, boolean visAvailable) {
|
public boolean configureAndInit(Container parentContainer, Simulation simulation, boolean visAvailable) {
|
||||||
|
|
||||||
if (identifier == null) {
|
if (identifier == null) {
|
||||||
// Create unique identifier
|
// Create unique identifier
|
||||||
|
@ -251,7 +252,7 @@ public class DisturberMoteType implements MoteType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean createdOK = configureAndInit(GUI.frame, simulation, visAvailable);
|
boolean createdOK = configureAndInit(GUI.getTopParentContainer(), simulation, visAvailable);
|
||||||
return createdOK;
|
return createdOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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: DummyMoteType.java,v 1.4 2008/02/07 10:34:45 fros4943 Exp $
|
* $Id: DummyMoteType.java,v 1.5 2008/02/12 15:10:49 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.motes;
|
package se.sics.cooja.motes;
|
||||||
|
|
||||||
|
import java.awt.Container;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
@ -61,7 +62,7 @@ public class DummyMoteType implements MoteType {
|
||||||
return new DummyMote(this, simulation);
|
return new DummyMote(this, simulation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean configureAndInit(JFrame parentFrame, Simulation simulation, boolean visAvailable) {
|
public boolean configureAndInit(Container parentContainer, Simulation simulation, boolean visAvailable) {
|
||||||
|
|
||||||
if (identifier == null) {
|
if (identifier == null) {
|
||||||
// Create unique identifier
|
// Create unique identifier
|
||||||
|
@ -152,7 +153,7 @@ public class DummyMoteType implements MoteType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean createdOK = configureAndInit(GUI.frame, simulation, visAvailable);
|
boolean createdOK = configureAndInit(GUI.getTopParentContainer(), simulation, visAvailable);
|
||||||
return createdOK;
|
return createdOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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: LogListener.java,v 1.7 2008/02/08 14:42:33 fros4943 Exp $
|
* $Id: LogListener.java,v 1.8 2008/02/12 15:11:40 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.plugins;
|
package se.sics.cooja.plugins;
|
||||||
|
@ -155,7 +155,7 @@ public class LogListener extends VisPlugin {
|
||||||
public void actionPerformed(ActionEvent ev) {
|
public void actionPerformed(ActionEvent ev) {
|
||||||
JFileChooser fc = new JFileChooser();
|
JFileChooser fc = new JFileChooser();
|
||||||
|
|
||||||
int returnVal = fc.showSaveDialog(GUI.frame);
|
int returnVal = fc.showSaveDialog(GUI.getTopParentContainer());
|
||||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
||||||
File saveFile = fc.getSelectedFile();
|
File saveFile = fc.getSelectedFile();
|
||||||
|
|
||||||
|
@ -163,9 +163,8 @@ public class LogListener extends VisPlugin {
|
||||||
String s1 = "Overwrite";
|
String s1 = "Overwrite";
|
||||||
String s2 = "Cancel";
|
String s2 = "Cancel";
|
||||||
Object[] options = { s1, s2 };
|
Object[] options = { s1, s2 };
|
||||||
int n = JOptionPane
|
int n = JOptionPane.showOptionDialog(
|
||||||
.showOptionDialog(
|
GUI.getTopParentContainer(),
|
||||||
GUI.frame,
|
|
||||||
"A file with the same name already exists.\nDo you want to remove it?",
|
"A file with the same name already exists.\nDo you want to remove it?",
|
||||||
"Overwrite existing file?", JOptionPane.YES_NO_OPTION,
|
"Overwrite existing file?", JOptionPane.YES_NO_OPTION,
|
||||||
JOptionPane.QUESTION_MESSAGE, null, options, s1);
|
JOptionPane.QUESTION_MESSAGE, null, options, s1);
|
||||||
|
|
|
@ -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: Visualizer2D.java,v 1.11 2007/05/30 20:57:58 fros4943 Exp $
|
* $Id: Visualizer2D.java,v 1.12 2008/02/12 15:11:40 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.plugins;
|
package se.sics.cooja.plugins;
|
||||||
|
@ -188,11 +188,13 @@ public abstract class Visualizer2D extends VisPlugin {
|
||||||
// Detect mote highligts
|
// Detect mote highligts
|
||||||
myGUI.addMoteHighligtObserver(moteHighligtObserver = new Observer() {
|
myGUI.addMoteHighligtObserver(moteHighligtObserver = new Observer() {
|
||||||
public void update(Observable obs, Object obj) {
|
public void update(Observable obs, Object obj) {
|
||||||
if (!(obj instanceof Mote))
|
if (!(obj instanceof Mote)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (highlightTimer != null && highlightTimer.isRunning())
|
if (highlightTimer != null && highlightTimer.isRunning()) {
|
||||||
highlightTimer.stop();
|
highlightTimer.stop();
|
||||||
|
}
|
||||||
|
|
||||||
highlightTimer = new Timer(100, null);
|
highlightTimer = new Timer(100, null);
|
||||||
highlightedMote = (Mote) obj;
|
highlightedMote = (Mote) obj;
|
||||||
|
@ -207,10 +209,11 @@ public abstract class Visualizer2D extends VisPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Toggle color
|
// Toggle color
|
||||||
if (highlightColor == Color.GRAY)
|
if (highlightColor == Color.GRAY) {
|
||||||
highlightColor = Color.CYAN;
|
highlightColor = Color.CYAN;
|
||||||
else
|
} else {
|
||||||
highlightColor = Color.GRAY;
|
highlightColor = Color.GRAY;
|
||||||
|
}
|
||||||
highlightTimer.setDelay(highlightTimer.getDelay()-1);
|
highlightTimer.setDelay(highlightTimer.getDelay()-1);
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
@ -231,31 +234,34 @@ public abstract class Visualizer2D extends VisPlugin {
|
||||||
// Detect mouse events
|
// Detect mouse events
|
||||||
canvas.addMouseListener(new MouseListener() {
|
canvas.addMouseListener(new MouseListener() {
|
||||||
public void mousePressed(MouseEvent e) {
|
public void mousePressed(MouseEvent e) {
|
||||||
if (e.isPopupTrigger())
|
if (e.isPopupTrigger()) {
|
||||||
myPlugin.handlePopupRequest(e.getPoint().x, e.getPoint().y);
|
myPlugin.handlePopupRequest(e.getPoint().x, e.getPoint().y);
|
||||||
else if (SwingUtilities.isLeftMouseButton(e)){
|
} else if (SwingUtilities.isLeftMouseButton(e)){
|
||||||
//myPlugin.handleMoveRequest(e.getPoint().x, e.getPoint().y, false);
|
//myPlugin.handleMoveRequest(e.getPoint().x, e.getPoint().y, false);
|
||||||
beginMoveRequest(e.getPoint().x, e.getPoint().y);
|
beginMoveRequest(e.getPoint().x, e.getPoint().y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void mouseReleased(MouseEvent e) {
|
public void mouseReleased(MouseEvent e) {
|
||||||
if (e.isPopupTrigger())
|
if (e.isPopupTrigger()) {
|
||||||
myPlugin.handlePopupRequest(e.getPoint().x, e.getPoint().y);
|
myPlugin.handlePopupRequest(e.getPoint().x, e.getPoint().y);
|
||||||
else {
|
} else {
|
||||||
myPlugin.handleMoveRequest(e.getPoint().x, e.getPoint().y, true);
|
myPlugin.handleMoveRequest(e.getPoint().x, e.getPoint().y, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void mouseEntered(MouseEvent e) {
|
public void mouseEntered(MouseEvent e) {
|
||||||
if (e.isPopupTrigger())
|
if (e.isPopupTrigger()) {
|
||||||
myPlugin.handlePopupRequest(e.getPoint().x, e.getPoint().y);
|
myPlugin.handlePopupRequest(e.getPoint().x, e.getPoint().y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public void mouseExited(MouseEvent e) {
|
public void mouseExited(MouseEvent e) {
|
||||||
if (e.isPopupTrigger())
|
if (e.isPopupTrigger()) {
|
||||||
myPlugin.handlePopupRequest(e.getPoint().x, e.getPoint().y);
|
myPlugin.handlePopupRequest(e.getPoint().x, e.getPoint().y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
if (e.isPopupTrigger())
|
if (e.isPopupTrigger()) {
|
||||||
myPlugin.handlePopupRequest(e.getPoint().x, e.getPoint().y);
|
myPlugin.handlePopupRequest(e.getPoint().x, e.getPoint().y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -303,8 +309,9 @@ public abstract class Visualizer2D extends VisPlugin {
|
||||||
|
|
||||||
private void handlePopupRequest(final int x, final int y) {
|
private void handlePopupRequest(final int x, final int y) {
|
||||||
final Vector<Mote> foundMotes = findMotesAtPosition(x, y);
|
final Vector<Mote> foundMotes = findMotesAtPosition(x, y);
|
||||||
if (foundMotes == null || foundMotes.size() == 0)
|
if (foundMotes == null || foundMotes.size() == 0) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
JPopupMenu pickMoteMenu = new JPopupMenu();
|
JPopupMenu pickMoteMenu = new JPopupMenu();
|
||||||
pickMoteMenu.add(new JLabel("Select action:"));
|
pickMoteMenu.add(new JLabel("Select action:"));
|
||||||
|
@ -312,10 +319,6 @@ public abstract class Visualizer2D extends VisPlugin {
|
||||||
|
|
||||||
// Add 'show mote plugins'-actions
|
// Add 'show mote plugins'-actions
|
||||||
for (final Mote mote : foundMotes) {
|
for (final Mote mote : foundMotes) {
|
||||||
final Point pos = new Point(canvas.getLocationOnScreen().x + x, canvas
|
|
||||||
.getLocationOnScreen().y
|
|
||||||
+ y);
|
|
||||||
|
|
||||||
pickMoteMenu.add(simulation.getGUI().createMotePluginsSubmenu(mote));
|
pickMoteMenu.add(simulation.getGUI().createMotePluginsSubmenu(mote));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,8 +348,9 @@ public abstract class Visualizer2D extends VisPlugin {
|
||||||
|
|
||||||
private void beginMoveRequest(final int x, final int y) {
|
private void beginMoveRequest(final int x, final int y) {
|
||||||
final Vector<Mote> foundMotes = findMotesAtPosition(x, y);
|
final Vector<Mote> foundMotes = findMotesAtPosition(x, y);
|
||||||
if (foundMotes == null || foundMotes.size() == 0)
|
if (foundMotes == null || foundMotes.size() == 0) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
moteMoveBeginTime = System.currentTimeMillis();
|
moteMoveBeginTime = System.currentTimeMillis();
|
||||||
beginMoveRequest(foundMotes.get(0));
|
beginMoveRequest(foundMotes.get(0));
|
||||||
|
@ -428,8 +432,9 @@ public abstract class Visualizer2D extends VisPlugin {
|
||||||
motesFound.add(simulation.getMote(i));
|
motesFound.add(simulation.getMote(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (motesFound.size() == 0)
|
if (motesFound.size() == 0) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return motesFound;
|
return motesFound;
|
||||||
}
|
}
|
||||||
|
@ -511,31 +516,37 @@ public abstract class Visualizer2D extends VisPlugin {
|
||||||
for (int i = 0; i < simulation.getMotesCount(); i++) {
|
for (int i = 0; i < simulation.getMotesCount(); i++) {
|
||||||
motePos = simulation.getMote(i).getInterfaces().getPosition();
|
motePos = simulation.getMote(i).getInterfaces().getPosition();
|
||||||
|
|
||||||
if (motePos.getXCoordinate() < smallestXCoord)
|
if (motePos.getXCoordinate() < smallestXCoord) {
|
||||||
smallestXCoord = motePos.getXCoordinate();
|
smallestXCoord = motePos.getXCoordinate();
|
||||||
|
}
|
||||||
|
|
||||||
if (motePos.getXCoordinate() > biggestXCoord)
|
if (motePos.getXCoordinate() > biggestXCoord) {
|
||||||
biggestXCoord = motePos.getXCoordinate();
|
biggestXCoord = motePos.getXCoordinate();
|
||||||
|
}
|
||||||
|
|
||||||
if (motePos.getYCoordinate() < smallestYCoord)
|
if (motePos.getYCoordinate() < smallestYCoord) {
|
||||||
smallestYCoord = motePos.getYCoordinate();
|
smallestYCoord = motePos.getYCoordinate();
|
||||||
|
}
|
||||||
|
|
||||||
if (motePos.getYCoordinate() > biggestYCoord)
|
if (motePos.getYCoordinate() > biggestYCoord) {
|
||||||
biggestYCoord = motePos.getYCoordinate();
|
biggestYCoord = motePos.getYCoordinate();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((biggestXCoord - smallestXCoord) == 0) {
|
if ((biggestXCoord - smallestXCoord) == 0) {
|
||||||
factorXCoordToPixel = 1;
|
factorXCoordToPixel = 1;
|
||||||
} else
|
} else {
|
||||||
factorXCoordToPixel = ((double) canvas.getPreferredSize().width - 2 * CANVAS_BORDER_WIDTH)
|
factorXCoordToPixel = ((double) canvas.getPreferredSize().width - 2 * CANVAS_BORDER_WIDTH)
|
||||||
/ (biggestXCoord - smallestXCoord);
|
/ (biggestXCoord - smallestXCoord);
|
||||||
|
}
|
||||||
|
|
||||||
if ((biggestYCoord - smallestYCoord) == 0) {
|
if ((biggestYCoord - smallestYCoord) == 0) {
|
||||||
factorYCoordToPixel = 1;
|
factorYCoordToPixel = 1;
|
||||||
} else
|
} else {
|
||||||
factorYCoordToPixel = ((double) canvas.getPreferredSize().height - 2 * CANVAS_BORDER_WIDTH)
|
factorYCoordToPixel = ((double) canvas.getPreferredSize().height - 2 * CANVAS_BORDER_WIDTH)
|
||||||
/ (biggestYCoord - smallestYCoord);
|
/ (biggestYCoord - smallestYCoord);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -593,11 +604,11 @@ public abstract class Visualizer2D extends VisPlugin {
|
||||||
+ CANVAS_BORDER_WIDTH;
|
+ CANVAS_BORDER_WIDTH;
|
||||||
}
|
}
|
||||||
private double factorXPixelToCoord(int xPixel) {
|
private double factorXPixelToCoord(int xPixel) {
|
||||||
return ((double) (xPixel - CANVAS_BORDER_WIDTH) / factorXCoordToPixel)
|
return ((xPixel - CANVAS_BORDER_WIDTH) / factorXCoordToPixel)
|
||||||
+ smallestXCoord;
|
+ smallestXCoord;
|
||||||
}
|
}
|
||||||
private double factorYPixelToCoord(int yPixel) {
|
private double factorYPixelToCoord(int yPixel) {
|
||||||
return ((double) (yPixel - CANVAS_BORDER_WIDTH) / factorYCoordToPixel)
|
return ((yPixel - CANVAS_BORDER_WIDTH) / factorYCoordToPixel)
|
||||||
+ smallestYCoord;
|
+ smallestYCoord;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue