bug fix: user platform dialog had wrong owner window

This commit is contained in:
fros4943 2006-08-23 14:29:44 +00:00
parent 44201a4f4e
commit 5d6358b602
2 changed files with 96 additions and 39 deletions

View file

@ -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();
@ -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 {
@ -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;
@ -2040,15 +2039,14 @@ 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);
Class<? extends MoteInterface> newMoteInterfaceClass = classLoader
.loadClass(moteInterface).asSubclass(MoteInterface.class);
moteIntfClasses.add(newMoteInterfaceClass);
// logger.info("Loaded mote interface: " + newMoteInterfaceClass);
} catch (Exception ce) {

View file

@ -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();
@ -257,7 +294,10 @@ public class UserPlatformsDialog extends JDialog {
}
// Show merged configuration
if (myParentFrame != null)
ConfigViewer.showDialog(myParentFrame, config);
else
ConfigViewer.showDialog(myParentDialog, config);
}
});
addRemovePane.add(button);
@ -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;