Bug #370575 --> In <mail3PaneWindowCommands.js>, "Error: server has no properties" on "Tools" menu opening.

sr=bienvenu
This commit is contained in:
scott%scott-macgregor.org 2007-03-10 01:21:52 +00:00
Родитель 75695f9466
Коммит 634044202a
1 изменённых файлов: 34 добавлений и 32 удалений

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

@ -55,7 +55,7 @@ var FolderPaneController =
case "cmd_copy": case "cmd_copy":
case "cmd_paste": case "cmd_paste":
return true; return true;
default: default:
return false; return false;
} }
@ -63,7 +63,7 @@ var FolderPaneController =
isCommandEnabled: function(command) isCommandEnabled: function(command)
{ {
if (IsFakeAccount()) if (IsFakeAccount())
return false; return false;
switch ( command ) switch ( command )
@ -99,7 +99,7 @@ var FolderPaneController =
} }
catch (ex) { catch (ex) {
//dump("specialFolder failure: " + ex + "\n"); //dump("specialFolder failure: " + ex + "\n");
} }
if (specialFolder == "Inbox" || specialFolder == "Trash" || specialFolder == "Drafts" || if (specialFolder == "Inbox" || specialFolder == "Trash" || specialFolder == "Drafts" ||
specialFolder == "Sent" || specialFolder == "Templates" || specialFolder == "Unsent Messages" || specialFolder == "Sent" || specialFolder == "Templates" || specialFolder == "Unsent Messages" ||
(specialFolder == "Junk" && !CanRenameDeleteJunkMail(GetSelectedFolderURI())) || isServer == "true") (specialFolder == "Junk" && !CanRenameDeleteJunkMail(GetSelectedFolderURI())) || isServer == "true")
@ -130,7 +130,7 @@ var FolderPaneController =
break; break;
} }
}, },
onEvent: function(event) onEvent: function(event)
{ {
} }
@ -249,7 +249,7 @@ var DefaultController =
enabled.value = false; enabled.value = false;
var checkStatus = new Object(); var checkStatus = new Object();
if (IsFakeAccount()) if (IsFakeAccount())
return false; return false;
switch ( command ) switch ( command )
@ -383,7 +383,7 @@ var DefaultController =
if (GetNumSelectedMessages() <= 0) return false; if (GetNumSelectedMessages() <= 0) return false;
case "cmd_expandAllThreads": case "cmd_expandAllThreads":
case "cmd_collapseAllThreads": case "cmd_collapseAllThreads":
if (!gDBView || !gDBView.supportsThreading) if (!gDBView || !gDBView.supportsThreading)
return false; return false;
return (gDBView.viewFlags & nsMsgViewFlagsType.kThreadedDisplay); return (gDBView.viewFlags & nsMsgViewFlagsType.kThreadedDisplay);
case "cmd_nextFlaggedMsg": case "cmd_nextFlaggedMsg":
@ -425,7 +425,7 @@ var DefaultController =
case "cmd_downloadSelected": case "cmd_downloadSelected":
return (IsFolderSelected() && MailOfflineMgr.isOnline() && GetNumSelectedMessages() > 0); return (IsFolderSelected() && MailOfflineMgr.isOnline() && GetNumSelectedMessages() > 0);
case "cmd_synchronizeOffline": case "cmd_synchronizeOffline":
return MailOfflineMgr.isOnline() && IsAccountOfflineEnabled(); return MailOfflineMgr.isOnline() && IsAccountOfflineEnabled();
case "cmd_settingsOffline": case "cmd_settingsOffline":
return IsAccountOfflineEnabled(); return IsAccountOfflineEnabled();
case "cmd_moveToFolderAgain": case "cmd_moveToFolderAgain":
@ -441,7 +441,7 @@ var DefaultController =
// if the user invoked a key short cut then it is possible that we got here for a command which is // if the user invoked a key short cut then it is possible that we got here for a command which is
// really disabled. kick out if the command should be disabled. // really disabled. kick out if the command should be disabled.
if (!this.isCommandEnabled(command)) return; if (!this.isCommandEnabled(command)) return;
switch ( command ) switch ( command )
{ {
case "cmd_close": case "cmd_close":
@ -483,7 +483,7 @@ var DefaultController =
break; break;
case "cmd_createFilterFromMenu": case "cmd_createFilterFromMenu":
MsgCreateFilter(); MsgCreateFilter();
break; break;
case "cmd_createFilterFromPopup": case "cmd_createFilterFromPopup":
break;// This does nothing because the createfilter is invoked from the popupnode oncommand. break;// This does nothing because the createfilter is invoked from the popupnode oncommand.
case "button_delete": case "button_delete":
@ -598,19 +598,19 @@ var DefaultController =
case "cmd_find": case "cmd_find":
// make sure the message pane has focus before we start a find since we only support searching // make sure the message pane has focus before we start a find since we only support searching
// within the message body. Do it here and not in MsgFind() which can be called from standalone where we don't want to set focus // within the message body. Do it here and not in MsgFind() which can be called from standalone where we don't want to set focus
SetFocusMessagePane(); SetFocusMessagePane();
MsgFind(); MsgFind();
return; return;
case "cmd_findAgain": case "cmd_findAgain":
// make sure the message pane has focus before we start a find since we only support searching // make sure the message pane has focus before we start a find since we only support searching
// within the message body. Do it here and not in MsgFind() which can be called from standalone where we don't want to set focus // within the message body. Do it here and not in MsgFind() which can be called from standalone where we don't want to set focus
SetFocusMessagePane(); SetFocusMessagePane();
MsgFindAgain(false); MsgFindAgain(false);
return; return;
case "cmd_findPrevious": case "cmd_findPrevious":
// make sure the message pane has focus before we start a find since we only support searching // make sure the message pane has focus before we start a find since we only support searching
// within the message body. Do it here and not in MsgFind() which can be called from standalone where we don't want to set focus // within the message body. Do it here and not in MsgFind() which can be called from standalone where we don't want to set focus
SetFocusMessagePane(); SetFocusMessagePane();
MsgFindAgain(true); MsgFindAgain(true);
return; return;
case "cmd_markReadByDate": case "cmd_markReadByDate":
@ -631,7 +631,7 @@ var DefaultController =
return; return;
case "cmd_markAllRead": case "cmd_markAllRead":
gDBView.doCommand(nsMsgViewCommandType.markAllRead); gDBView.doCommand(nsMsgViewCommandType.markAllRead);
return; return;
case "button_junk": case "button_junk":
MsgJunk(); MsgJunk();
return; return;
@ -699,7 +699,7 @@ var DefaultController =
break; break;
} }
}, },
onEvent: function(event) onEvent: function(event)
{ {
// on blur events set the menu item texts back to the normal values // on blur events set the menu item texts back to the normal values
@ -728,16 +728,16 @@ function FocusRingUpdate_Mail()
// WhichPaneHasFocus() uses on top.document.commandDispatcher.focusedElement // WhichPaneHasFocus() uses on top.document.commandDispatcher.focusedElement
// to determine which pane has focus // to determine which pane has focus
// if the focusedElement is null, we're here on a blur. // if the focusedElement is null, we're here on a blur.
// nsFocusController::Blur() calls nsFocusController::SetFocusedElement(null), // nsFocusController::Blur() calls nsFocusController::SetFocusedElement(null),
// which will update any commands listening for "focus". // which will update any commands listening for "focus".
// we really only care about nsFocusController::Focus() happens, // we really only care about nsFocusController::Focus() happens,
// which calls nsFocusController::SetFocusedElement(element) // which calls nsFocusController::SetFocusedElement(element)
var currentFocusedElement = WhichPaneHasFocus(); var currentFocusedElement = WhichPaneHasFocus();
if (currentFocusedElement != gLastFocusedElement) { if (currentFocusedElement != gLastFocusedElement) {
if (currentFocusedElement) if (currentFocusedElement)
currentFocusedElement.setAttribute("focusring", "true"); currentFocusedElement.setAttribute("focusring", "true");
if (gLastFocusedElement) if (gLastFocusedElement)
gLastFocusedElement.removeAttribute("focusring"); gLastFocusedElement.removeAttribute("focusring");
@ -756,32 +756,32 @@ function WhichPaneHasFocus()
var threadTree = GetThreadTree(); var threadTree = GetThreadTree();
var folderTree = GetFolderTree(); var folderTree = GetFolderTree();
var messagePane = GetMessagePane(); var messagePane = GetMessagePane();
if (top.document.commandDispatcher.focusedWindow == GetMessagePaneFrame()) if (top.document.commandDispatcher.focusedWindow == GetMessagePaneFrame())
return messagePane; return messagePane;
var currentNode = top.document.commandDispatcher.focusedElement; var currentNode = top.document.commandDispatcher.focusedElement;
while (currentNode) { while (currentNode) {
if (currentNode === threadTree || if (currentNode === threadTree ||
currentNode === folderTree || currentNode === folderTree ||
currentNode === messagePane) currentNode === messagePane)
return currentNode; return currentNode;
currentNode = currentNode.parentNode; currentNode = currentNode.parentNode;
} }
return null; return null;
} }
function SetupCommandUpdateHandlers() function SetupCommandUpdateHandlers()
{ {
var widget; var widget;
// folder pane // folder pane
widget = GetFolderTree(); widget = GetFolderTree();
if ( widget ) if ( widget )
widget.controllers.appendController(FolderPaneController); widget.controllers.appendController(FolderPaneController);
top.controllers.insertControllerAt(0, DefaultController); top.controllers.insertControllerAt(0, DefaultController);
} }
@ -848,6 +848,8 @@ function IsRenameFolderEnabled()
function IsCanSearchMessagesEnabled() function IsCanSearchMessagesEnabled()
{ {
var folderURI = GetSelectedFolderURI(); var folderURI = GetSelectedFolderURI();
if (!folderURI)
return false;
var server = GetServer(folderURI); var server = GetServer(folderURI);
return server.canSearchMessages; return server.canSearchMessages;
} }
@ -858,7 +860,7 @@ function IsFolderCharsetEnabled()
function IsPropertiesEnabled(command) function IsPropertiesEnabled(command)
{ {
try try
{ {
var folderTree = GetFolderTree(); var folderTree = GetFolderTree();
var folderResource = GetSelectedFolderResource(); var folderResource = GetSelectedFolderResource();
@ -867,10 +869,10 @@ function IsPropertiesEnabled(command)
// it should be "Edit | Properties..." // it should be "Edit | Properties..."
if (GetFolderAttribute(folderTree, folderResource, "IsServer") == "true") if (GetFolderAttribute(folderTree, folderResource, "IsServer") == "true")
goSetMenuValue(command, "valueGeneric"); goSetMenuValue(command, "valueGeneric");
else else
goSetMenuValue(command, isNewsURI(folderResource.Value) ? "valueNewsgroup" : "valueFolder"); goSetMenuValue(command, isNewsURI(folderResource.Value) ? "valueNewsgroup" : "valueFolder");
} }
catch (ex) catch (ex)
{ {
// properties menu failure // properties menu failure
} }
@ -933,8 +935,8 @@ function MsgDeleteFolder()
var protocolInfo = Components.classes["@mozilla.org/messenger/protocol/info;1?type=" + selectedFolder.server.type].getService(Components.interfaces.nsIMsgProtocolInfo); var protocolInfo = Components.classes["@mozilla.org/messenger/protocol/info;1?type=" + selectedFolder.server.type].getService(Components.interfaces.nsIMsgProtocolInfo);
// do not allow deletion of special folders on imap accounts // do not allow deletion of special folders on imap accounts
if ((specialFolder == "Sent" || if ((specialFolder == "Sent" ||
specialFolder == "Drafts" || specialFolder == "Drafts" ||
specialFolder == "Templates" || specialFolder == "Templates" ||
(specialFolder == "Junk" && !CanRenameDeleteJunkMail(GetSelectedFolderURI()))) && (specialFolder == "Junk" && !CanRenameDeleteJunkMail(GetSelectedFolderURI()))) &&
!protocolInfo.specialFoldersDeletionAllowed) !protocolInfo.specialFoldersDeletionAllowed)
@ -944,7 +946,7 @@ function MsgDeleteFolder()
var specialFolderDeletionErrTitle = gMessengerBundle.getString("specialFolderDeletionErrTitle"); var specialFolderDeletionErrTitle = gMessengerBundle.getString("specialFolderDeletionErrTitle");
promptService.alert(window, specialFolderDeletionErrTitle, errorMessage); promptService.alert(window, specialFolderDeletionErrTitle, errorMessage);
continue; continue;
} }
else if (isNewsURI(folderResource.Value)) else if (isNewsURI(folderResource.Value))
{ {
var unsubscribe = ConfirmUnsubscribe(selectedFolder); var unsubscribe = ConfirmUnsubscribe(selectedFolder);
@ -1051,7 +1053,7 @@ function SwitchPaneFocus(event)
folderTree.focus(); folderTree.focus();
else if (focusedElement != messagePane && !IsMessagePaneCollapsed()) else if (focusedElement != messagePane && !IsMessagePaneCollapsed())
SetFocusMessagePane(); SetFocusMessagePane();
else else
threadTree.focus(); threadTree.focus();
} }
else else
@ -1084,7 +1086,7 @@ function SetFocusMessagePane()
document.commandDispatcher.advanceFocusIntoSubtree(GetMessagePane()); document.commandDispatcher.advanceFocusIntoSubtree(GetMessagePane());
} }
function is_collapsed(element) function is_collapsed(element)
{ {
return (element.getAttribute('state') == 'collapsed'); return (element.getAttribute('state') == 'collapsed');
} }