make profile manager i18n friendly, PDT+ b=15264, r=gayatrib@netscape.com

This commit is contained in:
ben%netscape.com 2000-02-15 01:33:48 +00:00
Родитель 43fa4681b6
Коммит 0a9ec9ef6b
7 изменённых файлов: 147 добавлений и 91 удалений

Просмотреть файл

@ -124,18 +124,26 @@ function processCreateProfileData( aProfName, aProfDir )
// dropout layery thing. yeah. something like that to tell them when
// it happens, not when the whole wizard is complete. blah.
if( profile.profileExists( aProfName ) ) {
try {
alert( bundle.GetStringFromName( "profileExists" ) );
}
catch(e) {
// mac stringbundle failure. put up a ridiculous hard coded message.
alert( "Oh Yah, the profile name you chose already exists, yah!");
}
alert( bundle.GetStringFromName( "profileExists" ) );
// this is a bad but probably acceptable solution for now.
// when we add more panels, we will want a better solution.
window.frames["content"].document.getElementById("ProfileName").focus();
return false;
}
var invalidChars = ["/", "\\", "*", ":"];
for( var i = 0; i < invalidChars.length; i++ )
{
if( aProfName.indexOf( invalidChars[i] ) != -1 ) {
var aString = pmbundle.GetStringFromName("invalidCharA");
var bString = pmbundle.GetStringFromName("invalidCharB");
bString = bString.replace(/\s*<html:br\/>/g,"\n");
var lString = aString + invalidChars[i] + bString;
alert( lString );
window.frames["content"].document.getElementById("ProfileName").focus();
return false;
}
}
profile.createNewProfile( aProfName, aProfDir );
return true;
}
@ -159,4 +167,4 @@ function ExitApp()
// load string bundle
var bundle = srGetStrBundle("chrome://profile/locale/createProfileWizard.properties");
var pmbundle = srGetStrBundle("chrome://profile/locale/profileManager.properties");

Просмотреть файл

@ -28,13 +28,14 @@ var set = null;
function CreateProfileWizard()
{
// Need to call CreateNewProfile xuls
window.openDialog('chrome://profile/content/createProfileWizard.xul', 'CPW', 'chrome');
window.openDialog('chrome://profile/content/createProfileWizard.xul', 'CPW', 'chrome,modal=yes');
}
// update the display to show the additional profile
function CreateProfile( aProfName, aProfDir )
{
AddItem( "profilekids", aProfName, aProfName );
var profile = new Profile( aProfName, aProfDir, "yes" );
AddItem( "profilekids", profile );
}
// rename the selected profile
@ -54,8 +55,8 @@ function RenameProfile()
}
else {
var selected = profileTree.selectedItems[0];
if( selected.getAttribute("rowMigrate") == "true" ) {
// auto migrate if the user wants to
if( selected.getAttribute("rowMigrate") == "no" ) {
// migrate if the user wants to
var lString = bundle.GetStringFromName("migratebeforerename");
lString = lString.replace(/\s*<html:br\/>/g,"\n");
if( confirm( lString ) )
@ -66,8 +67,21 @@ function RenameProfile()
else {
var oldName = selected.getAttribute("rowName");
var newName = prompt( bundle.GetStringFromName("renameprofilepromptA") + oldName + bundle.GetStringFromName("renameprofilepromptB"), "" );
dump("*** newName = |" + newName + "|\n");
if( newName == "" || !newName )
return false;
var invalidChars = ["/", "\\", "*", ":"];
for( var i = 0; i < invalidChars.length; i++ )
{
if( newName.indexOf( invalidChars[i] ) != -1 ) {
var aString = bundle.GetStringFromName("invalidCharA");
var bString = bundle.GetStringFromName("invalidCharB");
bString = bString.replace(/\s*<html:br\/>/g,"\n");
var lString = aString + invalidChars[i] + bString;
alert( lString );
return false;
}
}
var migrate = selected.getAttribute("rowMigrate");
dump("*** oldName = "+ oldName+ ", newName = "+ newName+ ", migrate = "+ migrate+ "\n");
@ -77,9 +91,8 @@ function RenameProfile()
selected.setAttribute( "rowName", newName );
selected.setAttribute( "profile_name", newName );
}
catch (ex) {
var lString = bundle.GetStringFromName("renamefailed");
lString = lString.replace(/\s*<html:br\/>/g,"\n");
catch(e) {
var lString = bundle.GetStringFromName("profileExists");
alert( lString );
}
}
@ -107,7 +120,7 @@ function ConfirmDelete()
var selected = profileTree.selectedItems[0];
var name = selected.getAttribute("rowName");
if( selected.getAttribute("rowMigrate") == "true" ) {
if( selected.getAttribute("rowMigrate") == "no" ) {
// 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*<html:br\/>/g,"\n");
@ -171,7 +184,6 @@ function SwitchProfileManagerMode()
var manageParent = manage.parentNode;
manageParent.removeChild( manage );
profileManagerMode = "manager"; // swap the mode
PersistAndLoadElements( selItems ); // save the selection and load elements
}
else {
prattleIndex = 0;
@ -182,7 +194,6 @@ function SwitchProfileManagerMode()
}
buttonDisplay = "display: none;";
profileManagerMode = "selection";
PersistAndLoadElements( selItems );
}
// swap deck
@ -203,28 +214,6 @@ function SwitchProfileManagerMode()
set = true;
}
// save which elements are selected in this mode and load elements into other mode,
// then reselect selected elements
function PersistAndLoadElements( aSelItems )
{
// persist the profiles that are selected;
var profileTree = document.getElementById("profiles");
var selItemNodes = profileTree.selectedItems;
for( var i = 0; i < selItemNodes.length; i++ )
{
aSelItems[i] = selItemNodes[i].getAttribute("profile_name");
}
loadElements(); // reload list of profiles
for( var i = 0; i < aSelItems.length; i++ )
{
var item = document.getElementsByAttribute("profile_name", aSelItems[i]);
if( item.length ) {
var item = item[0];
profileTree.addItemToSelection( item );
}
}
}
// change the title of the profile manager/selection window.
function ChangeCaption( aCaption )
{

Просмотреть файл

@ -30,6 +30,14 @@ if (profile)
profile = profile.QueryInterface(Components.interfaces.nsIProfile);
var unset = true;
var RDF = Components.classes['component://netscape/rdf/rdf-service'].getService();
RDF = RDF.QueryInterface(Components.interfaces.nsIRDFService);
var Registry;
var REGISTRY_NAMESPACE_URI = 'urn:mozilla-registry:'
var REGISTRY_VALUE_PREFIX = REGISTRY_NAMESPACE_URI + 'value:';
var kRegistry_Subkeys = RDF.GetResource(REGISTRY_NAMESPACE_URI + 'subkeys');
function StartUp()
{
SetUpOKCancelButtons();
@ -37,6 +45,11 @@ function StartUp()
if(window.location && window.location.search && window.location.search == "?manage=true" )
SwitchProfileManagerMode();
Registry = Components.classes['component://netscape/registry-viewer'].createInstance();
Registry = Registry.QueryInterface(Components.interfaces.nsIRegistryDataSource);
Registry.openDefaultRegistry();
Registry = Registry.QueryInterface(Components.interfaces.nsIRDFDataSource);
loadElements();
highlightCurrentProfile();
DoEnabling();
@ -60,64 +73,75 @@ function highlightCurrentProfile()
// function : <profileSelection.js>::AddItem();
// purpose : utility function for adding items to a tree.
function AddItem( aChildren, aCells, aIdfier, aMigrate)
function AddItem( aChildren, aProfileObject )
{
var kids = document.getElementById(aChildren);
var item = document.createElement("treeitem");
var row = document.createElement("treerow");
var cell = document.createElement("treecell");
cell.setAttribute("value",aCells);
cell.setAttribute("value", aProfileObject.mName );
cell.setAttribute("align","left");
if( aMigrate )
cell.setAttribute("class", "dimmed-lowcontrast" );
row.appendChild(cell);
item.appendChild(row);
item.setAttribute("profile_name", aIdfier);
item.setAttribute("rowName", aIdfier);
item.setAttribute("id", ( "profileName_" + aIdfier ) );
if( aMigrate )
item.setAttribute("rowMigrate", "true");
item.setAttribute("profile_name", aProfileObject.mName );
item.setAttribute("rowName", aProfileObject.mName );
item.setAttribute("id", ( "profileName_" + aProfileObject.mName ) );
item.setAttribute("rowMigrate", aProfileObject.mMigrated );
item.setAttribute("directory", aProfileObject.mDir );
// 23/10/99 - no roaming access yet!
// var roaming = document.getElementById("roamingitem");
// kids.insertBefore(item,roaming);
kids.appendChild(item);
}
function Profile ( aName, aDir, aMigrated )
{
this.mName = aName ? aName : null;
this.mDir = aDir ? aDir : null;
this.mMigrated = aMigrated ? aMigrated : null;
}
// function : <profileSelection.js>::loadElements();
// purpose : load profiles into tree
function loadElements()
{
var profileList = "";
profileList = profile.getProfileList();
profileList = profileList.split(",");
try {
currProfile = profile.currentProfile;
}
catch (ex) {
if (profileList != "")
currProfile = profileList;
}
dump("profile list = " + profileList + "\n");
// remove existing nodes...
var profilekids = document.getElementById( "profilekids" );
while( profilekids.hasChildNodes() )
var profileSRC = RDF.GetResource( "urn:mozilla-registry:key:/Profiles" );
var profileProperty = RDF.GetResource( "urn:mozilla-registry:subkeys" );
var profiles = Registry.GetTargets( profileSRC, profileProperty, true );
if( profiles )
profiles = profiles.QueryInterface( Components.interfaces.nsISimpleEnumerator );
while( profiles.HasMoreElements() )
{
profilekids.removeChild( profilekids.firstChild );
}
for (var i = 0; i < profileList.length; i++) {
var pvals = profileList[i].split(" - ");
// only add profiles that have been migrated
if( profileManagerMode == "selection" && pvals[1] != "migrate" ) {
AddItem( "profilekids", pvals[0], pvals[0], false );
var currProfile = profiles.GetNext().QueryInterface( Components.interfaces.nsIRDFResource );
// begin BAD BAD BAD BAD BAD BAD HACK {{
var profileName = currProfile.Value.substring( currProfile.Value.lastIndexOf("/") + 1 );
// }} end BAD BAD BAD BAD BAD BAD HACK
var arcs = Registry.ArcLabelsOut( currProfile )
if( arcs )
arcs = arcs.QueryInterface( Components.interfaces.nsISimpleEnumerator );
while( arcs.HasMoreElements() )
{
var property = arcs.GetNext().QueryInterface( Components.interfaces.nsIRDFResource );
if( property == kRegistry_Subkeys )
continue;
var propstr = property.Value.substring( REGISTRY_VALUE_PREFIX.length );
var target = Registry.GetTarget( currProfile, property, true );
var literal = target.QueryInterface( Components.interfaces.nsIRDFLiteral );
if( literal )
var targetstr = literal.Value;
else {
literal = target.QueryInterface( Components.interfaces.nsIRDFInt )
if( literal )
var targetstr = literal.Value;
}
if( propstr == "migrated" )
var migrated = targetstr;
else if( propstr == "directory" )
var directory = targetstr;
}
else if( profileManagerMode == "manager" ){
AddItem( "profilekids", pvals[0], pvals[0], ( pvals[1] == "migrate" ) );
}
}
var profile = new Profile( profileName, directory, migrated );
AddItem( "profilekids", profile );
}
}
// function : <profileSelection.js>::onStart();
@ -133,7 +157,7 @@ function onStart()
var selected = profileTree.selectedItems[0];
var profilename = selected.getAttribute("profile_name");
if( selected.getAttribute("rowMigrate") == "true" ) {
if( selected.getAttribute("rowMigrate") == "no" ) {
var lString = bundle.GetStringFromName("migratebeforestart");
lString = lString.replace(/\s*<html:br\/>/g,"\n");
if( confirm( lString ) )

Просмотреть файл

@ -44,7 +44,6 @@
<html:script language="javascript" src="chrome://profile/content/profileSelection.js"/>
<html:script language="javascript" src="chrome://profile/content/profileManager.js"/>
<keyset id="keyset">
<key id="fooKey" key="s" xulkey="true" shift="true" onkeydown="foo()"/>
</keyset>
@ -58,8 +57,7 @@
</box>
<spring flex="100%"/>
</toolbar>
<spring style="height: 4px;"/>
<box align="horizontal" flex="100%">
<box id="contentarea" align="horizontal" flex="100%">
<spring style="width: 7px;"/>
<!-- instructions -->
@ -127,7 +125,6 @@
</box>
<spring style="width: 7px;"/>
</box>
<html:div class="separator" align="horizontal"/>
<box class="selection" align="horizontal">
<spring style="width: 5px;"/>
<titledbutton class="dialog push padded" id="manage" value="&manage.label;" onclick="SwitchProfileManagerMode();"/>

Просмотреть файл

@ -23,3 +23,8 @@ exitButton=Exit
deleteFiles=Delete Files
dontDeleteFiles=Don't Delete Files
cancel=Cancel
invalidCharA=You cannot create or rename a profile to a name containing the character: "
invalidCharB="<html:br/><html:br/>Please choose a different name for the profile.
profileExists=A profile with this name already exists. Please choose another name.

Просмотреть файл

@ -1,5 +1,5 @@
<!ENTITY title "Delete Profile">
<!ENTITY intro "Deleting a profile will remove the profile from your Communicator login and cannot be undone. If you procede with the deletion, you may also choose to have Communicator delete your data files, including your saved mail, settings and certificates.">
<!ENTITY intro "Deleting a profile will remove the profile from your Mozilla login and cannot be undone. If you procede with the deletion, you may also choose to have Mozilla delete your data files, including your saved mail, settings and certificates.">
<!ENTITY question "Would you like to delete your files with your profile? (Choosing this option will delete all the files in your profile's folder.)">
<!ENTITY delete.yes.label "Delete Files">
<!ENTITY delete.no.label "Don't Delete Files">

Просмотреть файл

@ -1,3 +1,28 @@
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator client code, released
* March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributors:
* Chris Nelson <chrisn@statecollege.com>
*
*/
@import url(chrome://global/skin/);
toolbar.header {
@ -25,14 +50,18 @@ titledbutton.unMigratedProfile {
.dimmed-highcontrast {
color: #99cccc ! important;
}
.dimmed-lowcontrast {
color: graytext ;
treeitem[rowMigrate="no"] > treerow > treecell {
color: #8F8F8F;
}
treeitem[selected="true"] > treerow > treecell {
color: highlighttext;
/** icon courtesy of chris nelson, chrisn@statecollege.com **/
treeitem[rowMigrate="no"] > treerow > treecell > .tree-icon {
list-style-image: url("chrome://profile/skin/migrate.gif");
}
treeitem[rowMigrate="no"][selected="true"] > treerow > treecell {
color: #FFFFFF;
}
div.headertext {
color: white;
@ -65,9 +94,9 @@ div.separator {
}
/* display area */
box#contentsink {
border-top: 2px groove threedface;
border-bottom: 2px groove threedface;
box#contentarea {
border-top: 2px groove #CCCCCC;
border-bottom: 2px groove #CCCCCC;
padding: 7px;
}
@ -124,4 +153,8 @@ box#okCancelButtons.Button1 > spring#Button3Spring {
}
spring#Button3Spring {
width: 5px;
}
box.selection {
margin-top: 4px;
}