fix for #44350 - clear the search results pane each time a search starts.

r=bienvenu
This commit is contained in:
alecf%netscape.com 2000-07-11 23:12:35 +00:00
parent 3ddf6e8910
commit 2dd2724e78
6 changed files with 55 additions and 37 deletions

View File

@ -25,6 +25,8 @@ var folderDSProgID = rdfDatasourcePrefix + "mailnewsfolders";
var gSearchDatasource;
var nsIMsgFolder = Components.interfaces.nsIMsgFolder;
var nsIMsgWindow = Components.interfaces.nsIMsgWindow;
var nsIMsgRDFDataSource = Components.interfaces.nsIMsgRDFDataSource;
var nsMsgSearchScope = Components.interfaces.nsMsgSearchScope;
var gFolderDatasource;
@ -45,16 +47,16 @@ function searchOnLoad()
onMore(null);
gThreadTree = document.getElementById("threadTree");
}
function initializeSearchWindowWidgets()
{
gFolderPicker = document.getElementById("searchableFolders");
gResultsTree = document.getElementById("threadTree");
gThreadTree = document.getElementById("threadTree");
msgWindow = Components.classes[msgWindowProgID].createInstance(Components.interfaces.nsIMsgWindow);
msgWindow = Components.classes[msgWindowProgID].createInstance(nsIMsgWindow);
msgWindow.statusFeedback = gStatusFeedback;
msgWindow.SetDOMWindow(window);
}
@ -132,10 +134,14 @@ function onSearch(event)
// tell the search session what the new scope is
gSearchSession.addScopeTerm(GetScopeForFolder(gCurrentFolder),
gCurrentFolder);
// reflect the search widgets back into the search session
saveSearchTerms(gSearchSession.searchTerms, gSearchSession);
gSearchSession.search(msgWindow);
// refresh the tree after the search starts, because initiating the
// search will cause the datasource to clear itself
gThreadTree.setAttribute("ref", gThreadTree.getAttribute("ref"));
}
@ -153,17 +159,20 @@ function setupDatasource() {
gSearchDatasource = Components.classes[rdfDatasourcePrefix + "msgsearch"].createInstance(Components.interfaces.nsIRDFDataSource);
dump("The root is " + gSearchDatasource.URI + "\n");
gResultsTree.setAttribute("ref", gSearchDatasource.URI);
gThreadTree.setAttribute("ref", gSearchDatasource.URI);
// 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[searchSessionProgID].createInstance(Components.interfaces.nsIMsgSearchSession);
gResultsTree.database.AddDataSource(gSearchDatasource);
setMsgDatasourceWindow(gSearchDatasource, msgWindow);
gThreadTree.database.AddDataSource(gSearchDatasource);
var messageDatasource = Components.classes[rdfDatasourcePrefix + "mailnewsmessages"].createInstance(Components.interfaces.nsIRDFDataSource);
gResultsTree.database.AddDataSource(messageDatasource);
setMsgDatasourceWindow(messageDatasource, msgWindow);
gThreadTree.database.AddDataSource(messageDatasource);
// the datasource is a listener on the search results
searchListener = gSearchDatasource.QueryInterface(Components.interfaces.nsIMsgSearchNotify);
@ -211,3 +220,13 @@ function IsThreadAndMessagePaneSplitterCollapsed()
{
return true;
}
function setMsgDatasourceWindow(ds, msgwindow)
{
try {
var msgDatasource = ds.QueryInterface(nsIMsgRDFDataSource);
msgDatasource.window = msgwindow;
} catch (ex) {
dump("error setting DS on " + ds + ": " + ex + "\n");
}
}

View File

@ -44,7 +44,9 @@ Rights Reserved.
<menulist id="searchableFolders" flex="2"
oncommand="onChooseFolder(event)"/>
<spring flex="1"/>
<!--
<checkbox value="&searchSubfolders.label;"/>
-->
</box>
<box>

View File

@ -111,6 +111,9 @@ nsMsgSearchDataSource::OnSearchDone(nsresult status)
NS_IMETHODIMP
nsMsgSearchDataSource::OnNewSearch()
{
// we could individually unassert each of the arcs in the array,
// but as a speed optimization, we're going to let the front end
// handle that, probably by rerooting the tree
mSearchResults->Clear();
return NS_OK;
}
@ -131,7 +134,12 @@ nsMsgSearchDataSource::GetTargets(nsIRDFResource *aSource,
PRBool aTruthValue,
nsISimpleEnumerator **aResult)
{
return NS_NewArrayEnumerator(aResult, mSearchResults);
PRUint32 count;
mSearchResults->Count(&count);
if (count == 0)
return NS_NewEmptyEnumerator(aResult);
else
return NS_NewArrayEnumerator(aResult, mSearchResults);
}

View File

@ -60,19 +60,7 @@ nsresult
nsMessengerBootstrap::Initialize(nsIAppShellService*,
nsICmdLineService*)
{
#if 0
// not needed?
nsresult rv;
nsCOMPtr<nsISupports> bootstrapper;
rv = this->QueryInterface(kISupportsIID, getter_AddRefs(bootstrapper));
if (NS_SUCCEEDED(rv) && bootstrapper) {
rv = nsServiceManager::RegisterService(NS_MESSENGERBOOTSTRAP_PROGID, bootstrapper);
}
return rv;
#else
return NS_OK;
#endif
}
nsresult

View File

@ -486,16 +486,16 @@ NS_IMETHODIMP nsMsgMessageDataSource::GetTargets(nsIRDFResource* source,
{
nsCOMPtr<nsIMessageView> messageView;
rv = GetMessageView(getter_AddRefs(messageView));
if(NS_FAILED(rv))
return rv;
if (NS_SUCCEEDED(rv) && messageView) {
rv = messageView->GetMessages(source, mWindow, targets);
if(NS_FAILED(rv))
return rv;
//if we don't have any targets, we will have to continue.
if(NS_SUCCEEDED(rv) && *targets)
return rv;
}
rv = messageView->GetMessages(source, mWindow, targets);
if(NS_FAILED(rv))
return rv;
//if we don't have any targets, we will have to continue.
if(NS_SUCCEEDED(rv) && *targets)
return rv;
}
}
nsCOMPtr<nsIMessage> message(do_QueryInterface(source, &rv));
if (NS_SUCCEEDED(rv)) {
@ -964,20 +964,16 @@ nsresult nsMsgMessageDataSource::OnChangeStatusString(nsIRDFResource *resource,
nsCOMPtr<nsIRDFNode> newNode;
rv = createStatusNodeFromFlag(newFlag, getter_AddRefs(newNode), PR_FALSE);
if(NS_FAILED(rv))
return rv;
NS_ENSURE_SUCCESS(rv, rv);
rv = NotifyPropertyChanged(resource, kNC_Status, newNode);
if(NS_FAILED(rv))
return rv;
NS_ENSURE_SUCCESS(rv, rv);
rv = createStatusNodeFromFlag(newFlag, getter_AddRefs(newNode), PR_TRUE);
if(NS_FAILED(rv))
return rv;
NS_ENSURE_TRUE(rv, rv);
rv = NotifyPropertyChanged(resource, kNC_StatusString, newNode);
NS_ENSURE_TRUE(rv, rv);
return rv;
}

View File

@ -298,7 +298,12 @@ nsMsgRDFDataSource::GetIsThreaded(PRBool *threaded)
rv = GetMessageView(getter_AddRefs(messageView));
if (NS_FAILED(rv)) return rv;
if (messageView)
return messageView->GetShowThreads(threaded);
else
*threaded = PR_FALSE;
return NS_OK;
}
nsresult