Fix for bugs 43879 and 40818. Fix up search menus and remove folder picker from rename dialog. r=alecf

This commit is contained in:
putterman%netscape.com 2000-08-16 22:56:09 +00:00
parent 3d07f452cf
commit c3bbca4902
5 changed files with 124 additions and 37 deletions

View File

@ -205,6 +205,7 @@ var DefaultController =
case "cmd_redo":
case "cmd_expandAllThreads":
case "cmd_collapseAllThreads":
case "cmd_renameFolder":
return true;
default:
return false;
@ -282,6 +283,8 @@ var DefaultController =
case "cmd_undo":
case "cmd_redo":
return SetupUndoRedoCommand(command);
case "cmd_renameFolder":
return IsRenameFolderEnabled();
default:
return false;
}
@ -380,6 +383,9 @@ var DefaultController =
case "cmd_collapseAllThreads":
ExpandOrCollapseThreads(false);
break;
case "cmd_renameFolder":
MsgRenameFolder();
return;
}
},
@ -439,6 +445,7 @@ function CommandUpdate_Mail()
goUpdateCommand('cmd_viewUnreadMsgs');
goUpdateCommand('cmd_expandAllThreads');
goUpdateCommand('cmd_collapseAllThreads');
goUpdateCommand('cmd_renameFolder');
}
function SetupUndoRedoCommand(command)
@ -542,6 +549,20 @@ function SetupCommandUpdateHandlers()
top.controllers.insertControllerAt(0, DefaultController);
}
function IsRenameFolderEnabled()
{
var tree = GetFolderTree();
var folderList = tree.selectedItems;
if(folderList.length == 1)
{
var folderNode = folderList[0];
return(folderNode.getAttribute("CanRename") == "true");
}
else
return false;
}
function MsgDeleteFolder()
{
//get the selected elements
@ -647,25 +668,11 @@ function FillInFolderTooltip(cellNode)
{
var folderNode = cellNode.parentNode.parentNode;
var uri = folderNode.getAttribute('id');
var folderResource = RDF.GetResource(uri);
var folderTree = GetFolderTree();
var db = folderTree.database;
var nameProperty = RDF.GetResource('http://home.netscape.com/NC-rdf#Name');
var nameResult;
try {
nameResult = db.GetTarget(folderResource, nameProperty , true);
}
catch (ex) {
//dump("failed to get the name of the folder for the tooltip: "+ex+"\n");
return;
}
nameResult = nameResult.QueryInterface(Components.interfaces.nsIRDFLiteral);
var name = nameResult.Value;
var name = GetFolderNameFromUri(uri, folderTree);
var folderResource = RDF.GetResource(uri);
var msgFolder = folderResource.QueryInterface(Components.interfaces.nsIMsgFolder);
var unreadCount = msgFolder.getNumUnread(false);
if(unreadCount < 0)
@ -685,6 +692,26 @@ function FillInFolderTooltip(cellNode)
}
function GetFolderNameFromUri(uri, tree)
{
var folderResource = RDF.GetResource(uri);
var db = tree.database;
var nameProperty = RDF.GetResource('http://home.netscape.com/NC-rdf#Name');
var nameResult;
try {
nameResult = db.GetTarget(folderResource, nameProperty , true);
}
catch (ex) {
return "";
}
nameResult = nameResult.QueryInterface(Components.interfaces.nsIRDFLiteral);
return nameResult.Value;
}
//Sets the thread tree's template's treeitem to be open so that all threads are expanded.
function ExpandOrCollapseThreads(expand)

View File

@ -93,6 +93,7 @@ Rights Reserved.
<broadcaster id="button_reply"/>
<broadcaster id="button_replyall"/>
<broadcaster id="button_forward"/>
<broadcaster id="cmd_renameFolder" oncommand="goDoCommand('cmd_renameFolder')" />
<broadcaster id="cmd_expandAllThreads" oncommand="goDoCommand('cmd_expandAllThreads')" disabled="true"/>
<broadcaster id="cmd_collapseAllThreads" oncommand="goDoCommand('cmd_collapseAllThreads')" disabled="true"/>
@ -369,9 +370,9 @@ Rights Reserved.
accesskey="&subscribeCmd.accesskey;"
oncommand="MsgSubscribe();"/>
<menuseparator/>
<menuitem value="&renameFolder.label;"
<menuitem id="menu_renameFolder" value="&renameFolder.label;"
accesskey="&renameFolder.accesskey;"
oncommand="MsgRenameFolder();"/>
observes="cmd_renameFolder"/>
<menuitem value="&compactFolder.label;" accesskey="&compactFolder.accesskey;" oncommand="MsgCompactFolder();"/>
<menuseparator/>
<menuitem value="&importCmd.label;" accesskey="&importCmd.accesskey;" oncommand="toImport();"/>
@ -510,18 +511,9 @@ Rights Reserved.
<menuitem value="&findCmd.label;" accesskey="&findCmd.accesskey;" oncommand="MsgFind();"/>
<menuitem value="&findAgainCmd.label;" accesskey="&findAgainCmd.accesskey;" oncommand="MsgFindAgain();"/>
<menuseparator/>
<!--
<menuitem value="&searchCurrentCmd.label;" accesskey="&searchCurrentCmd.accesskey;" disabled="true" oncommand="MsgSearchCurrent();"/>
<menuitem value="&searchParentCmd.label;" accesskey="&searchCurrentCmd.accesskey;" disabled="true" oncommand="MsgSearchParent();"/>
<menuitem value="&searchParentParentCmd.label;" accesskey="&searchParentParentCmd.accesskey;" disabled="true" oncommand="MsgSearchParentParent();"/>
<menuseparator/>
-->
<menuitem value="&searchInternetCmd.label;" accesskey="&searchInternetCmd.accesskey;" disabled="true" oncommand="MsgSearchInternet();"/>
<menuitem value="&searchInternetCmd.label;" accesskey="&searchInternetCmd.accesskey;" oncommand="openTopWin('http://search.netscape.com/')"/>
<menuitem value="&searchMailCmd.label;" accesskey="&searchMailCmd.accesskey;" oncommand="MsgSearchMessages();"/>
<menuitem value="&searchBookmarksCmd.label;" accesskey="&searchBookmarksCmd.accesskey;" disabled="true" oncommand="MsgSearchBookmarks();"/>
<menuitem value="&searchPeopleCmd.label;" accesskey="&searchPeopleCmd.accesskey;" disabled="true" oncommand="MsgSearchPeople();"/>
<menuseparator/>
<menuitem value="&searchLocalCmd.label;" accesskey="&searchLocalCmd.accesskey;" disabled="true" oncommand="MsgSearchLocal();"/>
<menuitem value="&searchBookmarksCmd.label;" accesskey="&searchBookmarksCmd.accesskey;" oncommand="window.openDialog('chrome://communicator/content/bookmarks/bm-find.xul', 'FindBookmarksWindow', 'centerscreen,dialog=no,close,chrome,resizable');"/>
</menupopup>
</menu>
<menu value="&goMenu.label;" accesskey="&goMenu.accesskey;">

View File

@ -1,5 +1,6 @@
var okCallback = 0;
var pickerID = null;
var preselectedFolderURI = null;
function newFolderNameOnLoad(pickerDOMID)
{
@ -31,7 +32,9 @@ function newFolderNameOnLoad(pickerDOMID)
else {
dump("passed null for preselectedURI, do nothing\n");
}
MsgFolderPickerOnLoad(pickerID);
var picker = document.getElementById(pickerID);
if(picker)
MsgFolderPickerOnLoad(pickerID);
}
function newFolderNameOKButtonCallback()
@ -40,7 +43,9 @@ function newFolderNameOKButtonCallback()
{
var name = document.getElementById("name").value;
var picker = document.getElementById(pickerID);
var uri = picker.getAttribute("uri");
var uri = picker.getAttribute("uri");
dump("uri,name in callback = " + uri + "," + name + "\n");
top.okCallback(name, uri);
}
@ -54,3 +59,66 @@ function newFolderNameCancelButtonCallback()
dump("in newFolderNameCancelButtonCallback\n");
return true;
}
function renameFolderNameOnLoad(pickerDOMID)
{
doSetOKCancel(renameFolderNameOKButtonCallback, renameFolderNameCancelButtonCallback);
// look in arguments[0] for parameters
if (window.arguments && window.arguments[0]) {
if ( window.arguments[0].title ) {
// dump("title = " + window.arguments[0].title + "\n");
top.window.title = window.arguments[0].title;
}
if ( window.arguments[0].okCallback ) {
top.okCallback = window.arguments[0].okCallback;
}
}
// pre select the folderPicker, based on what they selected in the folder pane
if (window.arguments[0].preselectedURI) {
try {
preselectedFolderURI = window.arguments[0].preselectedURI;
dump("pick this one: " + window.arguments[0].preselectedURI + "\n");
}
catch (ex) {
dump("failed to preflight the folderPicker thing.\n");
}
}
else {
dump("passed null for preselectedURI, do nothing\n");
}
if(window.arguments[0].name)
{
var name = document.getElementById("name");
name.value = window.arguments[0].name;
name.setSelectionRange(0,-1);
name.focusTextField();
}
}
function renameFolderNameOKButtonCallback()
{
if ( top.okCallback )
{
var name = document.getElementById("name").value;
var uri = preselectedFolderURI;
dump("uri,name in callback = " + uri + "," + name + "\n");
top.okCallback(name, uri);
}
return true;
}
function renameFolderNameCancelButtonCallback()
{
// close the window
dump("in renameFolderNameCancelButtonCallback\n");
return true;
}

View File

@ -30,7 +30,7 @@ Rights Reserved.
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
align="vertical"
class="dialog"
onload="newFolderNameOnLoad('msgRenameFolderPicker');" >
onload="renameFolderNameOnLoad();" >
<script language="JavaScript" src="chrome://global/content/strres.js"/>
<script language="JavaScript" src="chrome://messenger/content/mailCommands.js"/>
@ -45,10 +45,6 @@ Rights Reserved.
<text value="&rename.label;" />
<textfield tabindex="0" id="name" />
<box align="horizontal">
<menu id="msgRenameFolderPicker"/>
<spring flex="100%"/>
</box>
<spring flex="100%"/>
<box id="okCancelButtons"/>

View File

@ -80,6 +80,10 @@ function GetSelectedFolderURI()
function MsgRenameFolder()
{
var preselectedURI = GetSelectedFolderURI();
var folderTree = GetFolderTree();
var name = GetFolderNameFromUri(preselectedURI, folderTree);
dump("preselectedURI = " + preselectedURI + "\n");
var windowTitle = Bundle.GetStringFromName("renameFolderDialogTitle");
var dialog = window.openDialog(
@ -87,7 +91,7 @@ function MsgRenameFolder()
"newFolder",
"chrome,modal",
{preselectedURI:preselectedURI, title:windowTitle,
okCallback:RenameFolder});
okCallback:RenameFolder, name:name});
}
function RenameFolder(name,uri)