bug fix: user platform dialog had wrong owner window
This commit is contained in:
parent
44201a4f4e
commit
5d6358b602
2 changed files with 96 additions and 39 deletions
|
@ -26,7 +26,7 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: ContikiMoteTypeDialog.java,v 1.4 2006/08/22 15:28:18 fros4943 Exp $
|
||||
* $Id: ContikiMoteTypeDialog.java,v 1.5 2006/08/23 14:31:12 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja.contikimote;
|
||||
|
@ -103,7 +103,6 @@ public class ContikiMoteTypeDialog extends JDialog {
|
|||
private Vector<MoteType> allOtherTypes = null; // Used to check for
|
||||
// conflicting parameters
|
||||
|
||||
private Frame myParentFrame;
|
||||
private ContikiMoteTypeDialog myDialog;
|
||||
|
||||
/**
|
||||
|
@ -331,7 +330,6 @@ public class ContikiMoteTypeDialog extends JDialog {
|
|||
super(frame, "Add Mote Type", true);
|
||||
|
||||
myDialog = this;
|
||||
myParentFrame = frame;
|
||||
|
||||
JLabel label;
|
||||
JPanel mainPane = new JPanel();
|
||||
|
@ -728,12 +726,12 @@ public class ContikiMoteTypeDialog extends JDialog {
|
|||
|
||||
Container contentPane = getContentPane();
|
||||
JScrollPane mainScrollPane = new JScrollPane(mainPane);
|
||||
// mainScrollPane.setPreferredSize(new Dimension(
|
||||
// mainPane.getPreferredSize().width + 50, 500));
|
||||
// mainScrollPane.setPreferredSize(new Dimension(
|
||||
// mainPane.getPreferredSize().width + 50, 500));
|
||||
contentPane.add(mainScrollPane, BorderLayout.CENTER);
|
||||
contentPane.add(buttonPane, BorderLayout.SOUTH);
|
||||
|
||||
// pack();
|
||||
// pack();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -906,8 +904,8 @@ public class ContikiMoteTypeDialog extends JDialog {
|
|||
ContikiMoteType.class, "C_SOURCES", projectSourceFile);
|
||||
if (userPlatform != null) {
|
||||
// We found a user platform - Add directory
|
||||
filesToCompile.add(new File(userPlatform.getPath(),
|
||||
file.getParent()));
|
||||
filesToCompile.add(new File(userPlatform.getPath(), file
|
||||
.getParent()));
|
||||
}
|
||||
}
|
||||
filesToCompile.add(new File(file.getName()));
|
||||
|
@ -1183,12 +1181,13 @@ public class ContikiMoteTypeDialog extends JDialog {
|
|||
// Add directory to search path
|
||||
sourceDirs += " "
|
||||
+ sourceFile.getPath().replace(File.separatorChar, '/');
|
||||
ccFlags += " -I" + sourceFile.getPath().replace(File.separatorChar, '/');
|
||||
ccFlags += " -I"
|
||||
+ sourceFile.getPath().replace(File.separatorChar, '/');
|
||||
} else if (sourceFile.isFile()) {
|
||||
// Add both file name and directory
|
||||
if (sourceFile.getParent() != null) {
|
||||
sourceDirs += " " +
|
||||
sourceFile.getParent().replace(File.separatorChar, '/');
|
||||
sourceDirs += " "
|
||||
+ sourceFile.getParent().replace(File.separatorChar, '/');
|
||||
}
|
||||
sourceFileNames += " " + sourceFile.getName();
|
||||
} else {
|
||||
|
@ -1200,7 +1199,7 @@ public class ContikiMoteTypeDialog extends JDialog {
|
|||
logger.info("Project dirs: " + sourceDirs);
|
||||
logger.info("Project sources: " + sourceFileNames);
|
||||
logger.info("Compiler flags: " + ccFlags);
|
||||
|
||||
|
||||
String[] env = new String[]{
|
||||
"CONTIKI=" + contikiDir.getPath().replace(File.separatorChar, '/'),
|
||||
"TARGET=cooja", "TYPEID=" + identifier,
|
||||
|
@ -1887,7 +1886,7 @@ public class ContikiMoteTypeDialog extends JDialog {
|
|||
pathsWereUpdated();
|
||||
} else if (e.getActionCommand().equals("manageuserplatforms")) {
|
||||
Vector<File> newPlatforms = UserPlatformsDialog.showDialog(
|
||||
myParentFrame, moteTypeUserPlatforms, GUI.currentGUI
|
||||
ContikiMoteTypeDialog.this, moteTypeUserPlatforms, GUI.currentGUI
|
||||
.getUserPlatforms());
|
||||
if (newPlatforms != null) {
|
||||
moteTypeUserPlatforms = newPlatforms;
|
||||
|
@ -1941,7 +1940,7 @@ public class ContikiMoteTypeDialog extends JDialog {
|
|||
testButton.setEnabled(settingsOK = false);
|
||||
}
|
||||
|
||||
processPanel.revalidate();
|
||||
processPanel.revalidate();
|
||||
processPanel.repaint();
|
||||
createButton.setEnabled(libraryCreatedOK = false);
|
||||
|
||||
|
@ -1977,7 +1976,7 @@ public class ContikiMoteTypeDialog extends JDialog {
|
|||
testButton.setEnabled(settingsOK = false);
|
||||
}
|
||||
|
||||
sensorPanel.revalidate();
|
||||
sensorPanel.revalidate();
|
||||
sensorPanel.repaint();
|
||||
createButton.setEnabled(libraryCreatedOK = false);
|
||||
} else if (e.getActionCommand().equals("scancoreinterfaces")) {
|
||||
|
@ -2014,7 +2013,7 @@ public class ContikiMoteTypeDialog extends JDialog {
|
|||
}
|
||||
recheckInterfaceDependencies();
|
||||
|
||||
coreInterfacePanel.revalidate();
|
||||
coreInterfacePanel.revalidate();
|
||||
coreInterfacePanel.repaint();
|
||||
createButton.setEnabled(libraryCreatedOK = false);
|
||||
|
||||
|
@ -2040,20 +2039,19 @@ public class ContikiMoteTypeDialog extends JDialog {
|
|||
ContikiMoteType.class, "MOTE_INTERFACES");
|
||||
Vector<Class<? extends MoteInterface>> moteIntfClasses = new Vector<Class<? extends MoteInterface>>();
|
||||
|
||||
ClassLoader classLoader =
|
||||
GUI.currentGUI.createUserPlatformClassLoader(moteTypeUserPlatforms);
|
||||
ClassLoader classLoader = GUI.currentGUI
|
||||
.createUserPlatformClassLoader(moteTypeUserPlatforms);
|
||||
|
||||
// Find and load the mote interface classes
|
||||
for (String moteInterface : moteInterfaces) {
|
||||
try {
|
||||
Class<? extends MoteInterface> newMoteInterfaceClass =
|
||||
classLoader.loadClass(moteInterface).
|
||||
asSubclass(MoteInterface.class);
|
||||
try {
|
||||
Class<? extends MoteInterface> newMoteInterfaceClass = classLoader
|
||||
.loadClass(moteInterface).asSubclass(MoteInterface.class);
|
||||
moteIntfClasses.add(newMoteInterfaceClass);
|
||||
// logger.info("Loaded mote interface: " + newMoteInterfaceClass);
|
||||
} catch (Exception ce) {
|
||||
} catch (Exception ce) {
|
||||
logger.warn("Failed to load mote interface: " + moteInterface);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create and add checkboxes for all mote interfaces
|
||||
|
@ -2076,7 +2074,7 @@ public class ContikiMoteTypeDialog extends JDialog {
|
|||
testButton.setEnabled(settingsOK = false);
|
||||
}
|
||||
|
||||
moteInterfacePanel.revalidate();
|
||||
moteInterfacePanel.revalidate();
|
||||
moteInterfacePanel.repaint();
|
||||
createButton.setEnabled(libraryCreatedOK = false);
|
||||
} else if (e.getActionCommand().equals("addprocess")) {
|
||||
|
@ -2092,8 +2090,8 @@ public class ContikiMoteTypeDialog extends JDialog {
|
|||
processCheckBox.addActionListener(myEventHandler);
|
||||
|
||||
processPanel.add(processCheckBox);
|
||||
processPanel.revalidate();
|
||||
processPanel.repaint();
|
||||
processPanel.revalidate();
|
||||
processPanel.repaint();
|
||||
}
|
||||
} else if (e.getActionCommand().equals("addsensor")) {
|
||||
String newSensorName = JOptionPane.showInputDialog(myDialog,
|
||||
|
@ -2103,8 +2101,8 @@ public class ContikiMoteTypeDialog extends JDialog {
|
|||
sensorCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
sensorCheckBox.setSelected(true);
|
||||
sensorPanel.add(sensorCheckBox);
|
||||
sensorPanel.revalidate();
|
||||
sensorPanel.repaint();
|
||||
sensorPanel.revalidate();
|
||||
sensorPanel.repaint();
|
||||
}
|
||||
} else if (e.getActionCommand().equals("addinterface")) {
|
||||
String newInterfaceName = JOptionPane.showInputDialog(myDialog,
|
||||
|
@ -2114,8 +2112,8 @@ public class ContikiMoteTypeDialog extends JDialog {
|
|||
interfaceCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
interfaceCheckBox.setSelected(true);
|
||||
coreInterfacePanel.add(interfaceCheckBox);
|
||||
coreInterfacePanel.revalidate();
|
||||
coreInterfacePanel.repaint();
|
||||
coreInterfacePanel.revalidate();
|
||||
coreInterfacePanel.repaint();
|
||||
}
|
||||
} else if (e.getActionCommand().equals("recheck_interface_dependencies")) {
|
||||
recheckInterfaceDependencies();
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: UserPlatformsDialog.java,v 1.3 2006/08/22 15:28:18 fros4943 Exp $
|
||||
* $Id: UserPlatformsDialog.java,v 1.4 2006/08/23 14:29:44 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja.dialogs;
|
||||
|
@ -66,7 +66,8 @@ public class UserPlatformsDialog extends JDialog {
|
|||
private Vector<File> changableUserPlatforms = null;
|
||||
|
||||
private UserPlatformsDialog myDialog;
|
||||
private Frame myParentFrame;
|
||||
private Frame myParentFrame = null;
|
||||
private Dialog myParentDialog = null;
|
||||
|
||||
/**
|
||||
* Allows user to alter the given user platforms list by adding new,
|
||||
|
@ -94,11 +95,47 @@ public class UserPlatformsDialog extends JDialog {
|
|||
return myDialog.changableUserPlatforms;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows user to alter the given user platforms list by adding new,
|
||||
* reordering or removing user platforms. Only the changable user platforms
|
||||
* may be changed,
|
||||
*
|
||||
* @param parentDialog
|
||||
* Parent dialog
|
||||
* @param changablePlatforms
|
||||
* Changeable user platforms
|
||||
* @param fixedPlatforms
|
||||
* Fixed user platform
|
||||
* @return Null if dialog aborted, else the new CHANGEABLE user platform list.
|
||||
*/
|
||||
public static Vector<File> showDialog(Dialog parentDialog,
|
||||
Vector<File> changablePlatforms, Vector<File> fixedPlatforms) {
|
||||
UserPlatformsDialog myDialog = new UserPlatformsDialog(parentDialog,
|
||||
changablePlatforms, fixedPlatforms);
|
||||
myDialog.setLocationRelativeTo(parentDialog);
|
||||
|
||||
if (myDialog != null) {
|
||||
myDialog.setVisible(true);
|
||||
}
|
||||
|
||||
return myDialog.changableUserPlatforms;
|
||||
}
|
||||
|
||||
private UserPlatformsDialog(Frame frame, Vector<File> changablePlatforms,
|
||||
Vector<File> fixedPlatforms) {
|
||||
super(frame, "Manage User Platforms", true);
|
||||
|
||||
myParentFrame = frame;
|
||||
init(changablePlatforms, fixedPlatforms);
|
||||
}
|
||||
|
||||
private UserPlatformsDialog(Dialog dialog, Vector<File> changablePlatforms,
|
||||
Vector<File> fixedPlatforms) {
|
||||
super(dialog, "Manage User Platforms", true);
|
||||
myParentDialog = dialog;
|
||||
init(changablePlatforms, fixedPlatforms);
|
||||
}
|
||||
|
||||
private void init(Vector<File> changablePlatforms, Vector<File> fixedPlatforms) {
|
||||
myDialog = this;
|
||||
|
||||
JPanel mainPane = new JPanel();
|
||||
|
@ -155,12 +192,12 @@ public class UserPlatformsDialog extends JDialog {
|
|||
listPane2.add(new JLabel("Fixed:"));
|
||||
listPane2.add(fixedPlatformsList);
|
||||
}
|
||||
|
||||
|
||||
listPane2.add(new JLabel("Changable:"));
|
||||
listPane2.add(changablePlatformsList);
|
||||
|
||||
listPane.add(listPane2);
|
||||
|
||||
|
||||
smallPane = new JPanel();
|
||||
smallPane.setLayout(new BoxLayout(smallPane, BoxLayout.Y_AXIS));
|
||||
|
||||
|
@ -245,7 +282,7 @@ public class UserPlatformsDialog extends JDialog {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Add the user platform configurations
|
||||
for (String userPlatform : changablePlatformsList.getItems()) {
|
||||
try {
|
||||
|
@ -257,7 +294,10 @@ public class UserPlatformsDialog extends JDialog {
|
|||
}
|
||||
|
||||
// Show merged configuration
|
||||
ConfigViewer.showDialog(myParentFrame, config);
|
||||
if (myParentFrame != null)
|
||||
ConfigViewer.showDialog(myParentFrame, config);
|
||||
else
|
||||
ConfigViewer.showDialog(myParentDialog, config);
|
||||
}
|
||||
});
|
||||
addRemovePane.add(button);
|
||||
|
@ -307,7 +347,7 @@ public class UserPlatformsDialog extends JDialog {
|
|||
fixedPlatformsList.add(userPlatform.getPath());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Add already existing user platforms
|
||||
for (File userPlatform : changablePlatforms) {
|
||||
addUserPlatform(userPlatform);
|
||||
|
@ -361,15 +401,34 @@ class ConfigViewer extends JDialog {
|
|||
public static void showDialog(Frame parentFrame, PlatformConfig config) {
|
||||
ConfigViewer myDialog = new ConfigViewer(parentFrame, config);
|
||||
myDialog.setLocationRelativeTo(parentFrame);
|
||||
myDialog.setAlwaysOnTop(true);
|
||||
|
||||
if (myDialog != null) {
|
||||
myDialog.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
public static void showDialog(Dialog parentDialog, PlatformConfig config) {
|
||||
ConfigViewer myDialog = new ConfigViewer(parentDialog, config);
|
||||
myDialog.setLocationRelativeTo(parentDialog);
|
||||
myDialog.setAlwaysOnTop(true);
|
||||
|
||||
if (myDialog != null) {
|
||||
myDialog.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
private ConfigViewer(Dialog dialog, PlatformConfig config) {
|
||||
super(dialog, "Current class configuration", true);
|
||||
init(config);
|
||||
}
|
||||
|
||||
private ConfigViewer(Frame frame, PlatformConfig config) {
|
||||
super(frame, "Current class configuration", true);
|
||||
init(config);
|
||||
}
|
||||
|
||||
private void init(PlatformConfig config) {
|
||||
JPanel mainPane = new JPanel(new BorderLayout());
|
||||
JLabel label;
|
||||
JButton button;
|
||||
|
|
Loading…
Reference in a new issue