fix for #43484 - sort the account manager and folder pane according to spec

r=putterman
This commit is contained in:
alecf%netscape.com 2000-08-10 22:02:52 +00:00
Родитель 17b1c02a54
Коммит 6c45e79b60
5 изменённых файлов: 71 добавлений и 13 удалений

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

@ -65,6 +65,11 @@ var setDefaultButton;
// called when the whole document loads // called when the whole document loads
// perform initialization here // perform initialization here
function onLoad() { function onLoad() {
var selectedAccount;
if (window.arguments && window.arguments[0])
selectedServer = window.arguments[0].server;
accountArray = new Array; accountArray = new Array;
RDF = Components.classes["component://netscape/rdf/rdf-service"].getService(Components.interfaces.nsIRDFService); RDF = Components.classes["component://netscape/rdf/rdf-service"].getService(Components.interfaces.nsIRDFService);
@ -81,21 +86,43 @@ function onLoad() {
deleteButton = document.getElementById("deleteButton"); deleteButton = document.getElementById("deleteButton");
setDefaultButton = document.getElementById("setDefaultButton"); setDefaultButton = document.getElementById("setDefaultButton");
selectFirstAccount() sortAccountList(accounttree);
selectServer(selectedServer)
} }
function selectFirstAccount() function sortAccountList(accounttree)
{ {
var tree = document.getElementById("accounttree"); var xulSortService = Components.classes["component://netscape/rdf/xul-sort-service"].getService(Components.interfaces.nsIXULSortService);
var firstItem = findFirstTreeItem(tree);
xulSortService.Sort(accounttree, 'http://home.netscape.com/NC-rdf#FolderTreeName?sort=true', 'ascending');
}
if (firstItem) accounttree.selectItem(firstItem); function selectServer(server)
{
var selectedItem;
if (server)
selectedItem = document.getElementById(server.serverURI);
if (!selectedItem)
selectedItem = getFirstAccount();
accounttree.selectItem(selectedItem);
var result = getServerIdAndPageIdFromTree(accounttree); var result = getServerIdAndPageIdFromTree(accounttree);
if (result) { if (result) {
updateButtons(accounttree,result.serverId); updateButtons(accounttree,result.serverId);
} }
} }
function getFirstAccount()
{
var tree = document.getElementById("accounttree");
var firstItem = findFirstTreeItem(tree);
return firstItem;
}
function findFirstTreeItem(tree) { function findFirstTreeItem(tree) {
var children = tree.childNodes; var children = tree.childNodes;

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

@ -36,10 +36,12 @@
<rule> <rule>
<treechildren flex="1"> <treechildren flex="1">
<treeitem uri="..." open="true" <treeitem uri="..." open="true"
sort="rdf:http://home.netscape.com/NC-rdf#FolderTreeName?sort=true"
IsDefaultServer="rdf:http://home.netscape.com/NC-rdf#IsDefaultServer" IsDefaultServer="rdf:http://home.netscape.com/NC-rdf#IsDefaultServer"
PageTag="rdf:http://home.netscape.com/NC-rdf#PageTag"> PageTag="rdf:http://home.netscape.com/NC-rdf#PageTag">
<treerow > <treerow >
<treecell class="treecell-indent" value="rdf:http://home.netscape.com/NC-rdf#Name"/> <treecell class="treecell-indent"
value="rdf:http://home.netscape.com/NC-rdf#Name"/>
</treerow> </treerow>
</treeitem> </treeitem>
</treechildren> </treechildren>

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

@ -123,6 +123,13 @@ function msgOpenAccountWizard()
function MsgAccountManager() function MsgAccountManager()
{ {
var server;
try {
folderURI = GetSelectedFolderURI();
server = GetServer(folderURI);
} catch (ex) { /* functions might not be defined */}
window.openDialog("chrome://messenger/content/AccountManager.xul", window.openDialog("chrome://messenger/content/AccountManager.xul",
"AccountManager", "chrome,modal,resizable"); "AccountManager", "chrome,modal,resizable",
{ server: server });
} }

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

@ -588,6 +588,7 @@ function GetSelectedMessage()
function GetServer(uri) function GetServer(uri)
{ {
if (!uri) return null;
try { try {
var folder = GetMsgFolderFromUri(uri); var folder = GetMsgFolderFromUri(uri);
return folder.server; return folder.server;

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

@ -226,7 +226,6 @@ nsMsgAccountManagerDataSource::Init()
void nsMsgAccountManagerDataSource::Cleanup() void nsMsgAccountManagerDataSource::Cleanup()
{ {
printf("*** AccountManager Datasource cleanup\n");
nsCOMPtr<nsIMsgAccountManager> am = nsCOMPtr<nsIMsgAccountManager> am =
do_QueryReferent(mAccountManager); do_QueryReferent(mAccountManager);
@ -321,15 +320,37 @@ nsMsgAccountManagerDataSource::GetTarget(nsIRDFResource *source,
// only answer for servers! // only answer for servers!
if (NS_FAILED(rv) || !server) if (NS_FAILED(rv) || !server)
return NS_RDF_NO_VALUE; return NS_RDF_NO_VALUE;
// order is:
// - default account
// - <other servers>
// - Local Folders
// - news
PRInt32 accountNum; PRInt32 accountNum;
nsCOMPtr<nsIMsgAccountManager> am = nsCOMPtr<nsIMsgAccountManager> am =
do_QueryReferent(mAccountManager); do_QueryReferent(mAccountManager);
rv = am->FindServerIndex(server, &accountNum);
if (NS_FAILED(rv)) return rv; if (isDefaultServer(server))
str = NS_LITERAL_STRING("0000");
else {
accountNum += 1000; rv = am->FindServerIndex(server, &accountNum);
str.AppendInt(accountNum); if (NS_FAILED(rv)) return rv;
// this is a hack for now - hardcode server order by type
nsXPIDLCString serverType;
server->GetType(getter_Copies(serverType));
if (nsCRT::strcasecmp(serverType, "none")==0)
accountNum += 2000;
else if (nsCRT::strcasecmp(serverType, "nntp")==0)
accountNum += 3000;
else
accountNum += 1000; // default is to appear at the top
str.AppendInt(accountNum);
}
} }
// GetTargets() stuff - need to return a valid answer so that // GetTargets() stuff - need to return a valid answer so that