Bug 637835 - "Error: gFolderDisplay is not defined" in Advanced Search dialog when trying to drag search result entry (d&d impossible). r=Mnyromyr sr=Neil
authorJens Hatlak <jh@junetz.de>
Sat, 07 May 2011 11:29:59 +0200
changeset 7720 d5d1e732604fd6de668685e415a3f3139cd514be
parent 7719 813c489a99d0d424a32cb64974b71f4ef7ed99d0
child 7721 10cdb94a0d26d233706c14ff7a3e23045ee01148
push idunknown
push userunknown
push dateunknown
reviewersMnyromyr, Neil
bugs637835
Bug 637835 - "Error: gFolderDisplay is not defined" in Advanced Search dialog when trying to drag search result entry (d&d impossible). r=Mnyromyr sr=Neil
suite/mailnews/search/SearchDialog.js
suite/mailnews/search/SearchDialog.xul
--- a/suite/mailnews/search/SearchDialog.js
+++ b/suite/mailnews/search/SearchDialog.js
@@ -33,19 +33,19 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 var searchSessionContractID = "@mozilla.org/messenger/searchSession;1";
-var gSearchView;
+var gDBView;
 var gSearchSession;
-var gCurrentFolder;
+var gMsgFolderSelected;
 
 var nsIMsgFolder = Components.interfaces.nsIMsgFolder;
 var nsIMsgWindow = Components.interfaces.nsIMsgWindow;
 var nsMsgSearchScope = Components.interfaces.nsMsgSearchScope;
 
 var gFolderDatasource;
 var gFolderPicker;
 var gStatusBar = null;
@@ -188,17 +188,17 @@ var gSearchNotificationListener =
         // update status text?
     },
 
     onSearchDone: function(status)
     {
         gSearchStopButton.setAttribute("label", gSearchBundle.getString("labelForSearchButton"));
         gSearchStopButton.setAttribute("accesskey", gSearchBundle.getString("labelForSearchButton.accesskey"));
         gStatusFeedback._stopMeteors();
-        SetAdvancedSearchStatusText(gSearchView.QueryInterface(Components.interfaces.nsITreeView).rowCount);
+        SetAdvancedSearchStatusText(gDBView.QueryInterface(Components.interfaces.nsITreeView).rowCount);
     },
 
     onNewSearch: function()
     {
       gSearchStopButton.setAttribute("label", gSearchBundle.getString("labelForStopButton"));
       gSearchStopButton.setAttribute("accesskey", gSearchBundle.getString("labelForStopButton.accesskey"));
       UpdateMailSearch("new-search");	
       gStatusFeedback._startMeteors();
@@ -292,19 +292,20 @@ function searchOnUnload()
     // unregister listeners
     gSearchSession.unregisterListener(gViewSearchListener);
     gSearchSession.unregisterListener(gSearchNotificationListener);
 
     Components.classes["@mozilla.org/messenger/services/session;1"]
               .getService(Components.interfaces.nsIMsgMailSession)
               .RemoveFolderListener(gFolderListener);
 	
-    if (gSearchView) {
-	gSearchView.close();
-	gSearchView = null;
+    if (gDBView)
+    {
+        gDBView.close();
+        gDBView = null;
     }
 
     top.controllers.removeController(nsSearchResultsController);
 
     // release this early because msgWindow holds a weak reference
     msgWindow.rootDocShell = null;
 }
 
@@ -355,27 +356,27 @@ function selectFolder(folder)
     updateSearchFolderPicker(folderURI);
 }
 
 function updateSearchFolderPicker(folderURI) 
 { 
     SetFolderPicker(folderURI, gFolderPicker.id);
 
     // use the URI to get the real folder
-    gCurrentFolder = GetMsgFolderFromUri(folderURI);
+    gMsgFolderSelected = GetMsgFolderFromUri(folderURI);
 
     var searchLocalSystem = document.getElementById("checkSearchLocalSystem");
     if (searchLocalSystem)
-        searchLocalSystem.disabled = gCurrentFolder.server.searchScope == nsMsgSearchScope.offlineMail;
-    setSearchScope(GetScopeForFolder(gCurrentFolder));
+        searchLocalSystem.disabled = gMsgFolderSelected.server.searchScope == nsMsgSearchScope.offlineMail;
+    setSearchScope(GetScopeForFolder(gMsgFolderSelected));
 }
 
 function updateSearchLocalSystem()
 {
-  setSearchScope(GetScopeForFolder(gCurrentFolder));
+  setSearchScope(GetScopeForFolder(gMsgFolderSelected));
 }
 
 function UpdateAfterCustomHeaderChange()
 {
   updateSearchAttributes();
 }
 
 function onChooseFolder(event) {
@@ -398,33 +399,33 @@ function onEnterInSearchTerm()
      onSearch();
   }
 }
 
 function onSearch()
 {
     // set the view.  do this on every search, to
     // allow the tree to reset itself
-    var treeView = gSearchView.QueryInterface(Components.interfaces.nsITreeView);
+    var treeView = gDBView.QueryInterface(Components.interfaces.nsITreeView);
     if (treeView)
     {
       var tree = GetThreadTree();
       tree.treeBoxObject.view = treeView;
     }
 
     gSearchSession.clearScopes();
     // tell the search session what the new scope is
-    if (!gCurrentFolder.isServer && !gCurrentFolder.noSelect)
-        gSearchSession.addScopeTerm(GetScopeForFolder(gCurrentFolder),
-                                    gCurrentFolder);
+    if (!gMsgFolderSelected.isServer && !gMsgFolderSelected.noSelect)
+        gSearchSession.addScopeTerm(GetScopeForFolder(gMsgFolderSelected),
+                                    gMsgFolderSelected);
 
     var searchSubfolders = document.getElementById("checkSearchSubFolders").checked;
-    if (gCurrentFolder && (searchSubfolders || gCurrentFolder.isServer || gCurrentFolder.noSelect))
+    if (gMsgFolderSelected && (searchSubfolders || gMsgFolderSelected.isServer || gMsgFolderSelected.noSelect))
     {
-        AddSubFolders(gCurrentFolder);
+        AddSubFolders(gMsgFolderSelected);
     }
     // reflect the search widgets back into the search session
     saveSearchTerms(gSearchSession.searchTerms, gSearchSession);
 
     try
     {
       gSearchSession.search(msgWindow);
     }
@@ -536,36 +537,37 @@ nsMsgSearchCommandUpdater.prototype =
         iid.equals(Components.interfaces.nsISupports))
       return this;
 
     throw Components.results.NS_NOINTERFACE;
   }
 }
 
 function setupDatasource() {
-    gSearchView = Components.classes["@mozilla.org/messenger/msgdbview;1?type=search"].createInstance(Components.interfaces.nsIMsgDBView);
+    gDBView = Components.classes["@mozilla.org/messenger/msgdbview;1?type=search"]
+                        .createInstance(Components.interfaces.nsIMsgDBView);
     var count = new Object;
     var cmdupdator = new nsMsgSearchCommandUpdater();
 
-    gSearchView.init(messenger, msgWindow, cmdupdator);
-    gSearchView.open(null, nsMsgViewSortType.byId, nsMsgViewSortOrder.ascending, nsMsgViewFlagsType.kNone, count);
+    gDBView.init(messenger, msgWindow, cmdupdator);
+    gDBView.open(null, nsMsgViewSortType.byId, nsMsgViewSortOrder.ascending, nsMsgViewFlagsType.kNone, count);
 
     // the thread pane needs to use the search datasource (to get the
     // actual list of messages) and the message datasource (to get any
     // attributes about each message)
     gSearchSession = Components.classes[searchSessionContractID].createInstance(Components.interfaces.nsIMsgSearchSession);
 
     var nsIFolderListener = Components.interfaces.nsIFolderListener;
     var notifyFlags = nsIFolderListener.event;
     Components.classes["@mozilla.org/messenger/services/session;1"]
               .getService(Components.interfaces.nsIMsgMailSession)
               .AddFolderListener(gFolderListener, notifyFlags);
 
     // the datasource is a listener on the search results
-    gViewSearchListener = gSearchView.QueryInterface(Components.interfaces.nsIMsgSearchNotify);
+    gViewSearchListener = gDBView.QueryInterface(Components.interfaces.nsIMsgSearchNotify);
     gSearchSession.registerListener(gViewSearchListener);
 }
 
 
 function setupSearchListener()
 {
     // Setup the javascript object as a listener on the search results
     gSearchSession.registerListener(gSearchNotificationListener);
@@ -594,49 +596,49 @@ function onSearchButton(event)
     else
         onSearchStop();
 }
 
 // threadPane.js will be needing this, too
 function GetNumSelectedMessages()
 {
    try {
-       return gSearchView.numSelected;
+       return gDBView.numSelected;
    }
    catch (ex) {
        return 0;
    }
 }
 
 function GetDBView()
 {
-    return gSearchView;
+    return gDBView;
 }
 
 function MsgDeleteSelectedMessages(aCommandType)
 {
     SetNextMessageAfterDelete();
-    gSearchView.doCommand(aCommandType);
+    gDBView.doCommand(aCommandType);
 }
 
 function SetNextMessageAfterDelete()
 {
-  gNextMessageViewIndexAfterDelete = gSearchView.msgToSelectAfterDelete;
+  gNextMessageViewIndexAfterDelete = gDBView.msgToSelectAfterDelete;
 }
 
 function HandleDeleteOrMoveMessageFailed(folder)
 {
-  gSearchView.onDeleteCompleted(false);
+  gDBView.onDeleteCompleted(false);
   gNextMessageViewIndexAfterDelete = -2;
 }
 
 function HandleDeleteOrMoveMessageCompleted(folder)
 {
-  gSearchView.onDeleteCompleted(true);
-  var treeView = gSearchView.QueryInterface(Components.interfaces.nsITreeView);
+  gDBView.onDeleteCompleted(true);
+  var treeView = gDBView.QueryInterface(Components.interfaces.nsITreeView);
   var treeSelection = treeView.selection;
   var viewSize = treeView.rowCount;
 
   if (gNextMessageViewIndexAfterDelete == -2) {
     // a move or delete can cause our selection can change underneath us.
     // this can happen when the user
     // deletes message from the stand alone msg window
     // or the three pane
@@ -735,43 +737,37 @@ function MoveMessageInSearch(destFolder)
         var destUri = destFolder.getAttribute('id');
         if (destUri.length == 0) { 
           destUri = destFolder.getAttribute('file-uri')
         }
 
         var destMsgFolder = GetMsgFolderFromUri(destUri).QueryInterface(Components.interfaces.nsIMsgFolder);
 
         SetNextMessageAfterDelete();
-        gSearchView.doCommandWithFolder(nsMsgViewCommandType.moveMessages, destMsgFolder);
+        gDBView.doCommandWithFolder(nsMsgViewCommandType.moveMessages, destMsgFolder);
     }
     catch (ex) {
         dump("MsgMoveMessage failed: " + ex + "\n");
     }   
 }
 
 function GoToFolder()
 {
-  var hdr = gSearchView.hdrForFirstSelectedMessage;
+  var hdr = gDBView.hdrForFirstSelectedMessage;
   MsgOpenNewWindowForFolder(hdr.folder.URI, hdr.messageKey);
 }
 
-function BeginDragThreadPane(event)
-{
-    // no search pane dnd yet
-    return false;
-}
-
 function saveAsVirtualFolder()
 {
   let searchFolderURIs = window.arguments[0].folder.URI;
 
   var searchSubfolders = document.getElementById("checkSearchSubFolders").checked;
-  if (gCurrentFolder && (searchSubfolders || gCurrentFolder.isServer || gCurrentFolder.noSelect))
+  if (gMsgFolderSelected && (searchSubfolders || gMsgFolderSelected.isServer || gMsgFolderSelected.noSelect))
   {
-    var subFolderURIs = AddSubFoldersToURI(gCurrentFolder);
+    var subFolderURIs = AddSubFoldersToURI(gMsgFolderSelected);
     if (subFolderURIs.length > 0)
       searchFolderURIs += '|' + subFolderURIs;
   }
 
   var dialog = window.openDialog("chrome://messenger/content/virtualFolderProperties.xul", "",
                                  "chrome,titlebar,modal,centerscreen",
                                  {folder:window.arguments[0].folder,
                                   searchTerms:gSearchSession.searchTerms,
--- a/suite/mailnews/search/SearchDialog.xul
+++ b/suite/mailnews/search/SearchDialog.xul
@@ -79,16 +79,20 @@
   <script type="application/javascript"
           src="chrome://messenger/content/commandglue.js"/>
   <script type="application/javascript"
           src="chrome://messenger/content/SearchDialog.js"/>
   <script type="application/javascript"
           src="chrome://messenger/content/messengerdnd.js"/>
   <script type="application/javascript"
           src="chrome://messenger/content/tabmail.js"/>
+  <script type="application/javascript"
+          src="chrome://messenger/content/folderDisplay.js"/>
+  <script type="application/javascript"
+          src="chrome://global/content/contentAreaUtils.js"/>
 
   <commands id="commands">
     <commandset id="mailSearchItems"
                 commandupdater="true"
                 events="mail-search"
                 oncommandupdate="goUpdateSearchItems(this)">
       <command id="cmd_open" oncommand="goDoCommand('cmd_open')" disabled="true"/>
       <command id="button_delete" oncommand="goDoCommand('button_delete')" disabled="true"/>