mote type classloaders + no pack()
This commit is contained in:
parent
c1dc1c4fd3
commit
e10f020fec
1 changed files with 37 additions and 26 deletions
|
@ -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.2 2006/08/21 15:06:28 fros4943 Exp $
|
* $Id: ContikiMoteTypeDialog.java,v 1.3 2006/08/22 12:26:36 nifi Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.contikimote;
|
package se.sics.cooja.contikimote;
|
||||||
|
@ -313,11 +313,11 @@ public class ContikiMoteTypeDialog extends JDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set position and focus of dialog
|
// Set position and focus of dialog
|
||||||
|
myDialog.pack();
|
||||||
myDialog.setLocationRelativeTo(parentFrame);
|
myDialog.setLocationRelativeTo(parentFrame);
|
||||||
myDialog.textDescription.requestFocus();
|
myDialog.textDescription.requestFocus();
|
||||||
myDialog.textDescription.select(0, myDialog.textDescription.getText()
|
myDialog.textDescription.select(0, myDialog.textDescription.getText()
|
||||||
.length());
|
.length());
|
||||||
|
|
||||||
myDialog.setVisible(true);
|
myDialog.setVisible(true);
|
||||||
|
|
||||||
if (myDialog.myMoteType != null) {
|
if (myDialog.myMoteType != null) {
|
||||||
|
@ -728,12 +728,12 @@ public class ContikiMoteTypeDialog extends JDialog {
|
||||||
|
|
||||||
Container contentPane = getContentPane();
|
Container contentPane = getContentPane();
|
||||||
JScrollPane mainScrollPane = new JScrollPane(mainPane);
|
JScrollPane mainScrollPane = new JScrollPane(mainPane);
|
||||||
mainScrollPane.setPreferredSize(new Dimension(
|
// mainScrollPane.setPreferredSize(new Dimension(
|
||||||
mainPane.getPreferredSize().width + 50, 500));
|
// mainPane.getPreferredSize().width + 50, 500));
|
||||||
contentPane.add(mainScrollPane, BorderLayout.CENTER);
|
contentPane.add(mainScrollPane, BorderLayout.CENTER);
|
||||||
contentPane.add(buttonPane, BorderLayout.SOUTH);
|
contentPane.add(buttonPane, BorderLayout.SOUTH);
|
||||||
|
|
||||||
pack();
|
// pack();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1035,8 +1035,8 @@ public class ContikiMoteTypeDialog extends JDialog {
|
||||||
processString = "PROCINIT(NULL);";
|
processString = "PROCINIT(NULL);";
|
||||||
|
|
||||||
if (!userProcessString.equals(""))
|
if (!userProcessString.equals(""))
|
||||||
processString = processString.concat("\nAUTOSTART_PROCESSES("
|
processString = processString + "\nAUTOSTART_PROCESSES("
|
||||||
+ userProcessString + ");");
|
+ userProcessString + ");";
|
||||||
else
|
else
|
||||||
processString = processString.concat("\nAUTOSTART_PROCESSES(NULL);");
|
processString = processString.concat("\nAUTOSTART_PROCESSES(NULL);");
|
||||||
|
|
||||||
|
@ -1056,7 +1056,7 @@ public class ContikiMoteTypeDialog extends JDialog {
|
||||||
reader = new FileReader(mainTemplate);
|
reader = new FileReader(mainTemplate);
|
||||||
} else {
|
} else {
|
||||||
InputStream input = ContikiMoteTypeDialog.class
|
InputStream input = ContikiMoteTypeDialog.class
|
||||||
.getResourceAsStream(File.separatorChar + mainTemplate);
|
.getResourceAsStream('/' + mainTemplate);
|
||||||
if (input == null) {
|
if (input == null) {
|
||||||
throw new FileNotFoundException(mainTemplate + " not found");
|
throw new FileNotFoundException(mainTemplate + " not found");
|
||||||
}
|
}
|
||||||
|
@ -1173,7 +1173,8 @@ public class ContikiMoteTypeDialog extends JDialog {
|
||||||
+ sourceFile.getPath().replace(File.separatorChar, '/');
|
+ sourceFile.getPath().replace(File.separatorChar, '/');
|
||||||
} else if (sourceFile.isFile()) {
|
} else if (sourceFile.isFile()) {
|
||||||
// Add both file name and directory
|
// Add both file name and directory
|
||||||
sourceDirs += " " + sourceFile.getParent();
|
sourceDirs += " " +
|
||||||
|
sourceFile.getParent().replace(File.separatorChar, '/');
|
||||||
sourceFileNames += " " + sourceFile.getName();
|
sourceFileNames += " " + sourceFile.getName();
|
||||||
} else {
|
} else {
|
||||||
// Add filename and hope Contiki knows where to find it...
|
// Add filename and hope Contiki knows where to find it...
|
||||||
|
@ -1530,7 +1531,6 @@ public class ContikiMoteTypeDialog extends JDialog {
|
||||||
processCheckBox.addActionListener(myEventHandler);
|
processCheckBox.addActionListener(myEventHandler);
|
||||||
|
|
||||||
processPanel.add(processCheckBox);
|
processPanel.add(processCheckBox);
|
||||||
myDialog.pack();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
JCheckBox processCheckBox = new JCheckBox(autostartProcess,
|
JCheckBox processCheckBox = new JCheckBox(autostartProcess,
|
||||||
|
@ -1542,7 +1542,6 @@ public class ContikiMoteTypeDialog extends JDialog {
|
||||||
processCheckBox.addActionListener(myEventHandler);
|
processCheckBox.addActionListener(myEventHandler);
|
||||||
|
|
||||||
processPanel.add(processCheckBox);
|
processPanel.add(processCheckBox);
|
||||||
myDialog.pack();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1562,9 +1561,13 @@ public class ContikiMoteTypeDialog extends JDialog {
|
||||||
moteInterfacePanel.removeAll();
|
moteInterfacePanel.removeAll();
|
||||||
processPanel.removeAll();
|
processPanel.removeAll();
|
||||||
sensorPanel.removeAll();
|
sensorPanel.removeAll();
|
||||||
|
coreInterfacePanel.revalidate();
|
||||||
coreInterfacePanel.repaint();
|
coreInterfacePanel.repaint();
|
||||||
|
moteInterfacePanel.revalidate();
|
||||||
moteInterfacePanel.repaint();
|
moteInterfacePanel.repaint();
|
||||||
|
processPanel.revalidate();
|
||||||
processPanel.repaint();
|
processPanel.repaint();
|
||||||
|
sensorPanel.revalidate();
|
||||||
sensorPanel.repaint();
|
sensorPanel.repaint();
|
||||||
createButton.setEnabled(libraryCreatedOK = false);
|
createButton.setEnabled(libraryCreatedOK = false);
|
||||||
|
|
||||||
|
@ -1694,8 +1697,11 @@ public class ContikiMoteTypeDialog extends JDialog {
|
||||||
coreInterfacePanel.removeAll();
|
coreInterfacePanel.removeAll();
|
||||||
processPanel.removeAll();
|
processPanel.removeAll();
|
||||||
sensorPanel.removeAll();
|
sensorPanel.removeAll();
|
||||||
|
coreInterfacePanel.revalidate();
|
||||||
coreInterfacePanel.repaint();
|
coreInterfacePanel.repaint();
|
||||||
|
processPanel.revalidate();
|
||||||
processPanel.repaint();
|
processPanel.repaint();
|
||||||
|
sensorPanel.revalidate();
|
||||||
sensorPanel.repaint();
|
sensorPanel.repaint();
|
||||||
testButton.setEnabled(settingsOK = false);
|
testButton.setEnabled(settingsOK = false);
|
||||||
createButton.setEnabled(libraryCreatedOK = false);
|
createButton.setEnabled(libraryCreatedOK = false);
|
||||||
|
@ -1916,8 +1922,8 @@ public class ContikiMoteTypeDialog extends JDialog {
|
||||||
testButton.setEnabled(settingsOK = false);
|
testButton.setEnabled(settingsOK = false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
processPanel.revalidate();
|
||||||
processPanel.repaint();
|
processPanel.repaint();
|
||||||
myDialog.pack();
|
|
||||||
createButton.setEnabled(libraryCreatedOK = false);
|
createButton.setEnabled(libraryCreatedOK = false);
|
||||||
|
|
||||||
} else if (e.getActionCommand().equals("scansensors")) {
|
} else if (e.getActionCommand().equals("scansensors")) {
|
||||||
|
@ -1952,8 +1958,8 @@ public class ContikiMoteTypeDialog extends JDialog {
|
||||||
testButton.setEnabled(settingsOK = false);
|
testButton.setEnabled(settingsOK = false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sensorPanel.revalidate();
|
||||||
sensorPanel.repaint();
|
sensorPanel.repaint();
|
||||||
myDialog.pack();
|
|
||||||
createButton.setEnabled(libraryCreatedOK = false);
|
createButton.setEnabled(libraryCreatedOK = false);
|
||||||
} else if (e.getActionCommand().equals("scancoreinterfaces")) {
|
} else if (e.getActionCommand().equals("scancoreinterfaces")) {
|
||||||
// Clear core interface panel
|
// Clear core interface panel
|
||||||
|
@ -1989,8 +1995,8 @@ public class ContikiMoteTypeDialog extends JDialog {
|
||||||
}
|
}
|
||||||
recheckInterfaceDependencies();
|
recheckInterfaceDependencies();
|
||||||
|
|
||||||
|
coreInterfacePanel.revalidate();
|
||||||
coreInterfacePanel.repaint();
|
coreInterfacePanel.repaint();
|
||||||
myDialog.pack();
|
|
||||||
createButton.setEnabled(libraryCreatedOK = false);
|
createButton.setEnabled(libraryCreatedOK = false);
|
||||||
|
|
||||||
} else if (e.getActionCommand().equals("scanmoteinterfaces")) {
|
} else if (e.getActionCommand().equals("scanmoteinterfaces")) {
|
||||||
|
@ -2021,18 +2027,20 @@ public class ContikiMoteTypeDialog extends JDialog {
|
||||||
ContikiMoteType.class, "MOTE_INTERFACES");
|
ContikiMoteType.class, "MOTE_INTERFACES");
|
||||||
Vector<Class<? extends MoteInterface>> moteIntfClasses = new Vector<Class<? extends MoteInterface>>();
|
Vector<Class<? extends MoteInterface>> moteIntfClasses = new Vector<Class<? extends MoteInterface>>();
|
||||||
|
|
||||||
|
ClassLoader classLoader =
|
||||||
|
GUI.currentGUI.createUserPlatformClassLoader(moteTypeUserPlatforms);
|
||||||
|
|
||||||
// Find and load the mote interface classes
|
// Find and load the mote interface classes
|
||||||
for (String moteInterface : moteInterfaces) {
|
for (String moteInterface : moteInterfaces) {
|
||||||
|
try {
|
||||||
Class<? extends MoteInterface> newMoteInterfaceClass = GUI.currentGUI
|
Class<? extends MoteInterface> newMoteInterfaceClass =
|
||||||
.tryLoadClass(this, MoteInterface.class, moteInterface);
|
classLoader.loadClass(moteInterface).
|
||||||
|
asSubclass(MoteInterface.class);
|
||||||
if (newMoteInterfaceClass == null) {
|
|
||||||
logger.warn("Failed to load mote interface: " + moteInterface);
|
|
||||||
} else {
|
|
||||||
moteIntfClasses.add(newMoteInterfaceClass);
|
moteIntfClasses.add(newMoteInterfaceClass);
|
||||||
// logger.info("Loaded mote interface: " + newMoteInterfaceClass);
|
// logger.info("Loaded mote interface: " + newMoteInterfaceClass);
|
||||||
}
|
} catch (Exception ce) {
|
||||||
|
logger.warn("Failed to load mote interface: " + moteInterface);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create and add checkboxes for all mote interfaces
|
// Create and add checkboxes for all mote interfaces
|
||||||
|
@ -2055,8 +2063,8 @@ public class ContikiMoteTypeDialog extends JDialog {
|
||||||
testButton.setEnabled(settingsOK = false);
|
testButton.setEnabled(settingsOK = false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
moteInterfacePanel.revalidate();
|
||||||
moteInterfacePanel.repaint();
|
moteInterfacePanel.repaint();
|
||||||
myDialog.pack();
|
|
||||||
createButton.setEnabled(libraryCreatedOK = false);
|
createButton.setEnabled(libraryCreatedOK = false);
|
||||||
} else if (e.getActionCommand().equals("addprocess")) {
|
} else if (e.getActionCommand().equals("addprocess")) {
|
||||||
String newProcessName = JOptionPane.showInputDialog(myDialog,
|
String newProcessName = JOptionPane.showInputDialog(myDialog,
|
||||||
|
@ -2071,8 +2079,9 @@ public class ContikiMoteTypeDialog extends JDialog {
|
||||||
processCheckBox.addActionListener(myEventHandler);
|
processCheckBox.addActionListener(myEventHandler);
|
||||||
|
|
||||||
processPanel.add(processCheckBox);
|
processPanel.add(processCheckBox);
|
||||||
|
processPanel.revalidate();
|
||||||
|
processPanel.repaint();
|
||||||
}
|
}
|
||||||
myDialog.pack();
|
|
||||||
} else if (e.getActionCommand().equals("addsensor")) {
|
} else if (e.getActionCommand().equals("addsensor")) {
|
||||||
String newSensorName = JOptionPane.showInputDialog(myDialog,
|
String newSensorName = JOptionPane.showInputDialog(myDialog,
|
||||||
"Enter sensor name");
|
"Enter sensor name");
|
||||||
|
@ -2081,8 +2090,9 @@ public class ContikiMoteTypeDialog extends JDialog {
|
||||||
sensorCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT);
|
sensorCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||||
sensorCheckBox.setSelected(true);
|
sensorCheckBox.setSelected(true);
|
||||||
sensorPanel.add(sensorCheckBox);
|
sensorPanel.add(sensorCheckBox);
|
||||||
|
sensorPanel.revalidate();
|
||||||
|
sensorPanel.repaint();
|
||||||
}
|
}
|
||||||
myDialog.pack();
|
|
||||||
} else if (e.getActionCommand().equals("addinterface")) {
|
} else if (e.getActionCommand().equals("addinterface")) {
|
||||||
String newInterfaceName = JOptionPane.showInputDialog(myDialog,
|
String newInterfaceName = JOptionPane.showInputDialog(myDialog,
|
||||||
"Enter interface name");
|
"Enter interface name");
|
||||||
|
@ -2091,8 +2101,9 @@ public class ContikiMoteTypeDialog extends JDialog {
|
||||||
interfaceCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT);
|
interfaceCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||||
interfaceCheckBox.setSelected(true);
|
interfaceCheckBox.setSelected(true);
|
||||||
coreInterfacePanel.add(interfaceCheckBox);
|
coreInterfacePanel.add(interfaceCheckBox);
|
||||||
|
coreInterfacePanel.revalidate();
|
||||||
|
coreInterfacePanel.repaint();
|
||||||
}
|
}
|
||||||
myDialog.pack();
|
|
||||||
} else if (e.getActionCommand().equals("recheck_interface_dependencies")) {
|
} else if (e.getActionCommand().equals("recheck_interface_dependencies")) {
|
||||||
recheckInterfaceDependencies();
|
recheckInterfaceDependencies();
|
||||||
} else if (e.getActionCommand().startsWith("process_clicked")) {
|
} else if (e.getActionCommand().startsWith("process_clicked")) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue