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 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * 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; package se.sics.cooja.contikimote;
@ -103,7 +103,6 @@ public class ContikiMoteTypeDialog extends JDialog {
private Vector<MoteType> allOtherTypes = null; // Used to check for private Vector<MoteType> allOtherTypes = null; // Used to check for
// conflicting parameters // conflicting parameters
private Frame myParentFrame;
private ContikiMoteTypeDialog myDialog; private ContikiMoteTypeDialog myDialog;
/** /**
@ -331,7 +330,6 @@ public class ContikiMoteTypeDialog extends JDialog {
super(frame, "Add Mote Type", true); super(frame, "Add Mote Type", true);
myDialog = this; myDialog = this;
myParentFrame = frame;
JLabel label; JLabel label;
JPanel mainPane = new JPanel(); JPanel mainPane = new JPanel();
@ -728,12 +726,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();
} }
/** /**
@ -906,8 +904,8 @@ public class ContikiMoteTypeDialog extends JDialog {
ContikiMoteType.class, "C_SOURCES", projectSourceFile); ContikiMoteType.class, "C_SOURCES", projectSourceFile);
if (userPlatform != null) { if (userPlatform != null) {
// We found a user platform - Add directory // We found a user platform - Add directory
filesToCompile.add(new File(userPlatform.getPath(), filesToCompile.add(new File(userPlatform.getPath(), file
file.getParent())); .getParent()));
} }
} }
filesToCompile.add(new File(file.getName())); filesToCompile.add(new File(file.getName()));
@ -1183,12 +1181,13 @@ public class ContikiMoteTypeDialog extends JDialog {
// Add directory to search path // Add directory to search path
sourceDirs += " " sourceDirs += " "
+ sourceFile.getPath().replace(File.separatorChar, '/'); + sourceFile.getPath().replace(File.separatorChar, '/');
ccFlags += " -I" + sourceFile.getPath().replace(File.separatorChar, '/'); ccFlags += " -I"
+ 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
if (sourceFile.getParent() != null) { if (sourceFile.getParent() != null) {
sourceDirs += " " + sourceDirs += " "
sourceFile.getParent().replace(File.separatorChar, '/'); + sourceFile.getParent().replace(File.separatorChar, '/');
} }
sourceFileNames += " " + sourceFile.getName(); sourceFileNames += " " + sourceFile.getName();
} else { } else {
@ -1887,7 +1886,7 @@ public class ContikiMoteTypeDialog extends JDialog {
pathsWereUpdated(); pathsWereUpdated();
} else if (e.getActionCommand().equals("manageuserplatforms")) { } else if (e.getActionCommand().equals("manageuserplatforms")) {
Vector<File> newPlatforms = UserPlatformsDialog.showDialog( Vector<File> newPlatforms = UserPlatformsDialog.showDialog(
myParentFrame, moteTypeUserPlatforms, GUI.currentGUI ContikiMoteTypeDialog.this, moteTypeUserPlatforms, GUI.currentGUI
.getUserPlatforms()); .getUserPlatforms());
if (newPlatforms != null) { if (newPlatforms != null) {
moteTypeUserPlatforms = newPlatforms; moteTypeUserPlatforms = newPlatforms;
@ -2040,15 +2039,14 @@ 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 = ClassLoader classLoader = GUI.currentGUI
GUI.currentGUI.createUserPlatformClassLoader(moteTypeUserPlatforms); .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 { try {
Class<? extends MoteInterface> newMoteInterfaceClass = Class<? extends MoteInterface> newMoteInterfaceClass = classLoader
classLoader.loadClass(moteInterface). .loadClass(moteInterface).asSubclass(MoteInterface.class);
asSubclass(MoteInterface.class);
moteIntfClasses.add(newMoteInterfaceClass); moteIntfClasses.add(newMoteInterfaceClass);
// logger.info("Loaded mote interface: " + newMoteInterfaceClass); // logger.info("Loaded mote interface: " + newMoteInterfaceClass);
} catch (Exception ce) { } catch (Exception ce) {

View file

@ -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: 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; package se.sics.cooja.dialogs;
@ -66,7 +66,8 @@ public class UserPlatformsDialog extends JDialog {
private Vector<File> changableUserPlatforms = null; private Vector<File> changableUserPlatforms = null;
private UserPlatformsDialog myDialog; 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, * Allows user to alter the given user platforms list by adding new,
@ -94,11 +95,47 @@ public class UserPlatformsDialog extends JDialog {
return myDialog.changableUserPlatforms; 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, private UserPlatformsDialog(Frame frame, Vector<File> changablePlatforms,
Vector<File> fixedPlatforms) { Vector<File> fixedPlatforms) {
super(frame, "Manage User Platforms", true); super(frame, "Manage User Platforms", true);
myParentFrame = frame; 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; myDialog = this;
JPanel mainPane = new JPanel(); JPanel mainPane = new JPanel();
@ -257,7 +294,10 @@ public class UserPlatformsDialog extends JDialog {
} }
// Show merged configuration // Show merged configuration
if (myParentFrame != null)
ConfigViewer.showDialog(myParentFrame, config); ConfigViewer.showDialog(myParentFrame, config);
else
ConfigViewer.showDialog(myParentDialog, config);
} }
}); });
addRemovePane.add(button); addRemovePane.add(button);
@ -361,15 +401,34 @@ class ConfigViewer extends JDialog {
public static void showDialog(Frame parentFrame, PlatformConfig config) { public static void showDialog(Frame parentFrame, PlatformConfig config) {
ConfigViewer myDialog = new ConfigViewer(parentFrame, config); ConfigViewer myDialog = new ConfigViewer(parentFrame, config);
myDialog.setLocationRelativeTo(parentFrame); myDialog.setLocationRelativeTo(parentFrame);
myDialog.setAlwaysOnTop(true);
if (myDialog != null) { if (myDialog != null) {
myDialog.setVisible(true); 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) { private ConfigViewer(Frame frame, PlatformConfig config) {
super(frame, "Current class configuration", true); super(frame, "Current class configuration", true);
init(config);
}
private void init(PlatformConfig config) {
JPanel mainPane = new JPanel(new BorderLayout()); JPanel mainPane = new JPanel(new BorderLayout());
JLabel label; JLabel label;
JButton button; JButton button;