From cd8f45234e43446f2aaedba3fac440ee5153cc18 Mon Sep 17 00:00:00 2001 From: fros4943 Date: Fri, 23 Mar 2007 21:57:24 +0000 Subject: [PATCH] creating user platform configuration on demand --- .../cooja/dialogs/UserPlatformsDialog.java | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/tools/cooja/java/se/sics/cooja/dialogs/UserPlatformsDialog.java b/tools/cooja/java/se/sics/cooja/dialogs/UserPlatformsDialog.java index acdae43c2..f6c3ae623 100644 --- a/tools/cooja/java/se/sics/cooja/dialogs/UserPlatformsDialog.java +++ b/tools/cooja/java/se/sics/cooja/dialogs/UserPlatformsDialog.java @@ -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.6 2006/09/26 13:08:05 fros4943 Exp $ + * $Id: UserPlatformsDialog.java,v 1.7 2007/03/23 21:57:24 fros4943 Exp $ */ package se.sics.cooja.dialogs; @@ -373,9 +373,29 @@ public class UserPlatformsDialog extends JDialog { File userPlatformConfigFile = new File(userPlatform.getPath(), GUI.PLATFORM_CONFIG_FILENAME); if (!userPlatformConfigFile.exists()) { - logger.fatal("User platform has no configuration file: " - + userPlatformConfigFile); - return; + + Object[] options = {"Create", + "Cancel"}; + + int n = JOptionPane.showOptionDialog( + this, + "No " + GUI.PLATFORM_CONFIG_FILENAME + " file exists in specified directory!" + + "\nCreate an empty " + GUI.PLATFORM_CONFIG_FILENAME + " file?", + "Create user platform configuration?", + JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE, + null, options, options[1]); + + if (n == JOptionPane.NO_OPTION) + return; + + try { + userPlatformConfigFile.createNewFile(); + } catch (IOException e) { + logger.fatal("Could not create user platform configuration file: " + + userPlatformConfigFile); + return; + } } changablePlatformsList.add(userPlatform.getPath(), index);