diff --git a/profile/resources/content/profileManager.js b/profile/resources/content/profileManager.js index 38c05aa0b674..a95dc2cafdc0 100644 --- a/profile/resources/content/profileManager.js +++ b/profile/resources/content/profileManager.js @@ -22,6 +22,8 @@ * Ben Goodger */ +var commonDialogService = nsJSComponentManager.getService("component://netscape/appshell/commonDialogs", + "nsICommonDialogs"); var bundle = srGetStrBundle("chrome://communicator/locale/profile/profileManager.properties"); var profileManagerMode = "selection"; var set = null; @@ -50,30 +52,26 @@ function RenameProfile() if( renameButton.getAttribute("disabled") == "true" ) return; var profileTree = document.getElementById( "profiles" ); - if( !profileTree.selectedItems.length ) { - alert( bundle.GetStringFromName("noneselectedrename") ); - return; - } - else if( profileTree.selectedItems.length != 1 ) { - alert( bundle.GetStringFromName("wrongnumberselectedrename") ); - return; + var selected = profileTree.selectedItems[0]; + if( selected.firstChild.firstChild.getAttribute("rowMigrate") == "no" ) { + // migrate if the user wants to + var lString = bundle.GetStringFromName("migratebeforerename"); + lString = lString.replace(/\s*/g,"\n"); + var title = bundle.GetStringFromName("migratetitle"); + if (commonDialogService.Confirm(window, title, lString)) + profile.migrateProfile( profilename, true ); + else + return false; } else { - var selected = profileTree.selectedItems[0]; - if( selected.firstChild.firstChild.getAttribute("rowMigrate") == "no" ) { - // migrate if the user wants to - var lString = bundle.GetStringFromName("migratebeforerename"); - lString = lString.replace(/\s*/g,"\n"); - if( confirm( lString ) ) - profile.migrateProfile( profilename, true ); - else - return false; - } - else { - var oldName = selected.getAttribute("rowName"); - var newName = prompt( bundle.GetStringFromName("renameprofilepromptA") + oldName + bundle.GetStringFromName("renameprofilepromptB"), oldName ); + var oldName = selected.getAttribute("rowName"); + var result = { }; + var dialogTitle = bundle.GetStringFromName("renameprofiletitle"); + var msg = bundle.GetStringFromName("renameprofilepromptA") + oldName + bundle.GetStringFromName("renameprofilepromptB"); + if (commonDialogService.Prompt(window, dialogTitle, msg, oldName, result)) { + var newName = result.value; dump("*** newName = |" + newName + "|\n"); - if( newName == "" || !newName ) + if (!newName) return false; var invalidChars = ["/", "\\", "*", ":"]; for( var i = 0; i < invalidChars.length; i++ ) @@ -87,7 +85,7 @@ function RenameProfile() return false; } } - + var migrate = selected.firstChild.firstChild.getAttribute("rowMigrate"); dump("*** oldName = "+ oldName+ ", newName = "+ newName+ ", migrate = "+ migrate+ "\n"); try { @@ -98,7 +96,8 @@ function RenameProfile() } catch(e) { var lString = bundle.GetStringFromName("profileExists"); - alert( lString ); + var profileExistsTitle = bundle.GetStringFromName("profileExistsTitle"); + commonDialogService.Alert(window, profileExistsTitle, lString); } } } @@ -113,14 +112,6 @@ function ConfirmDelete() if( deleteButton.getAttribute("disabled") == "true" ) return; var profileTree = document.getElementById( "profiles" ); - if( !profileTree.selectedItems.length ) { - alert( bundle.GetStringFromName( "noneselecteddelete" ) ); - return; - } - else if( profileTree.selectedItems.length != 1 ) { - alert( bundle.GetStringFromName("wrongnumberselectedrename") ); - return; - } var selected = profileTree.selectedItems[0]; var name = selected.getAttribute("rowName"); @@ -129,7 +120,8 @@ function ConfirmDelete() // auto migrate if the user wants to. THIS IS REALLY REALLY DUMB PLEASE FIX THE BACK END. var lString = bundle.GetStringFromName("migratebeforedelete"); lString = lString.replace(/\s*/g,"\n"); - if( confirm( lString ) ) + var title = bundle.GetStringFromName("deletetitle"); + if (commonDialogService.Confirm(window, title, lString)) profile.migrateProfile( profilename, true ); else return false; @@ -164,7 +156,9 @@ function DeleteProfile( deleteFiles ) function ConfirmMigrateAll() { - if( confirm( bundle.GetStringFromName("migrateallprofiles") ) ) + var string = bundle.GetStringFromName("migrateallprofiles"); + var title = bundle.GetStringFromName("migrateallprofilestitle"); + if (commonDialogService.Confirm(window, title, string)) return true; else return false; diff --git a/profile/resources/content/profileSelection.js b/profile/resources/content/profileSelection.js index e6c7756bee75..c6f71072e95d 100644 --- a/profile/resources/content/profileSelection.js +++ b/profile/resources/content/profileSelection.js @@ -155,7 +155,8 @@ function onStart() if( selected.firstChild.firstChild.getAttribute("rowMigrate") == "no" ) { var lString = bundle.GetStringFromName("migratebeforestart"); lString = lString.replace(/\s*/g,"\n"); - if( confirm( lString ) ) + var title = bundle.GetStringFromName("migratetitle"); + if (commonDialogService.Confirm(window, title, lString)) profile.migrateProfile( profilename, true ); else return false; @@ -174,9 +175,9 @@ function onStart() ExitApp(); } catch (ex) { - var stringA = bundle.GetStringFromName(failProfileStartA); - var stringB = bundle.GetStringFromName(failProfileStartB); - alert(stringA + " " + profilename + " " + stringB); + //var stringA = bundle.GetStringFromName(failProfileStartA); + //var stringB = bundle.GetStringFromName(failProfileStartB); + //alert(stringA + " " + profilename + " " + stringB); } } diff --git a/profile/resources/content/profileSelection.xul b/profile/resources/content/profileSelection.xul index 986dab4a2db4..73683e3106f0 100644 --- a/profile/resources/content/profileSelection.xul +++ b/profile/resources/content/profileSelection.xul @@ -54,7 +54,7 @@ - + diff --git a/profile/resources/locale/en-US/profileManager.properties b/profile/resources/locale/en-US/profileManager.properties index 7428640baaeb..637f2c4e04ef 100644 --- a/profile/resources/locale/en-US/profileManager.properties +++ b/profile/resources/locale/en-US/profileManager.properties @@ -1,15 +1,16 @@ -noneselectedrename=You must select a profile to rename. -wrongnumberselectedrename=You can only rename one profile at a time. Please select only one profile and try again. migratebeforerename=The profile you selected was created with a previous version of Communicator and must be copied and converted to a Mozilla profile before it can be renamed. Do you want to convert this profile now? migratebeforedelete=The profile you selected was created with a previous version of Communicator and must be copied and converted to a Mozilla profile before it can be deleted. Do you want to convert this profile now?Its really really stupid to enforce this. Please let us not require someone to migrate a profile before deleting it! --Ben. migratebeforestart=The profile you selected was created with a previous version of Communicator and must be copied and converted before you can use it with Mozilla.Your original 4.x profile will not be altered.Choose OK to copy and convert the profile. +migratetitle=Migrate Profile +migrateallprofilestitle=Migrate All Profiles renamefailed=Sorry, Mozilla has failed to rename the profile you have selected.Resolution:1) Restart Mozilla and try again. 2) Close other applications or restart your computer.3) Check to ensure the profile files are not damaged. renameprofilepromptA=Rename the profile " renameprofilepromptB=" to: +renameprofiletitle=Rename Profile -noneselecteddelete=You must select a profile to delete. deletefailed=Sorry, Mozilla has failed to delete the profile you have selected.Resolution:1) Restart Mozilla and try again. 2) Close other applications or restart your computer.3) Check to ensure the profile files are not damaged. +deletetitle=Delete Profile pm_title=Manage User Profiles ps_title=Select User Profile @@ -28,3 +29,4 @@ invalidCharA=You cannot create or rename a profile to a name containing the char invalidCharB="Please choose a different name for the profile. profileExists=A profile with this name already exists. Please choose another name. +profileExistsTitle=Profile Exists