fix for #43911 - make double-clicking of messages in the search window open the target

message in a standalone message window - mostly moving files into threadPane.js and
abstracting out the folder datasource
r=putterman


git-svn-id: svn://10.0.0.236/trunk@73578 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
alecf%netscape.com 2000-06-30 06:02:30 +00:00
parent 8cc210d5a4
commit 9bcdb3ba49
12 changed files with 94 additions and 100 deletions

View File

@ -487,15 +487,12 @@ function GetSelectedFolderResource()
function SetFolderCharset(folderResource, aCharset)
{
var folderTree = GetFolderTree();
var db = folderTree.database;
var db2 = db.QueryInterface(Components.interfaces.nsIRDFDataSource);
var db = GetFolderDatasource();
var charsetResource = RDF.GetLiteral(aCharset);
var charsetProperty = RDF.GetResource("http://home.netscape.com/NC-rdf#Charset");
db2.Assert(folderResource, charsetProperty, charsetResource, true);
db.Assert(folderResource, charsetProperty, charsetResource, true);
}
@ -541,16 +538,6 @@ function OnClickThreadAndMessagePaneSplitter()
LoadSelectionIntoMessagePane();
}
//Called when selection changes in the thread pane.
function ThreadPaneSelectionChange()
{
var collapsed = IsThreadAndMessagePaneSplitterCollapsed();
if(!collapsed)
{
LoadSelectionIntoMessagePane();
}
}
//takes the selection from the thread pane and loads it into the message pane
function LoadSelectionIntoMessagePane()
@ -634,37 +621,10 @@ function OpenToFolder(item, folderURI)
return null;
}
function IsSpecialFolderSelected(folderName)
{
var selectedFolder = GetThreadTreeFolder();
var id = selectedFolder.getAttribute('ref');
var folderResource = RDF.GetResource(id);
if(!folderResource)
return false;
var folderTree = GetFolderTree();
var db = folderTree.database;
if (!db) return false;
db = db.QueryInterface(Components.interfaces.nsIRDFDataSource);
if (!db) return false;
var property =
RDF.GetResource('http://home.netscape.com/NC-rdf#SpecialFolder');
if (!property) return false;
var result = db.GetTarget(folderResource, property , true);
if (!result) return false;
result = result.QueryInterface(Components.interfaces.nsIRDFLiteral);
if (!result) return false;
if(result.Value == folderName)
return true;
return false;
}
function IsSpecialFolder(msgFolder, specialFolderName)
{
var folderTree = GetFolderTree();
var db = folderTree.database;
var db = GetFolderDatasource();
var folderResource = msgFolder.QueryInterface(Components.interfaces.nsIRDFResource);
if(folderResource)
{

View File

@ -265,7 +265,9 @@ function MsgOpenNewWindowForMessage(messageUri, folderUri)
if(!folderUri)
{
var folder = GetLoadedMsgFolder();
var message = RDF.GetResource(messageUri);
message = message.QueryInterface(Components.interfaces.nsIMessage);
var folder = message.msgFolder;
var folderResource = folder.QueryInterface(Components.interfaces.nsIRDFResource);
folderUri = folderResource.Value;
}

View File

@ -435,13 +435,21 @@ function OnLoadFolderPane(folderTree)
//Add folderDataSource and accountManagerDataSource to folderPane
accountManagerDataSource = accountManagerDataSource.QueryInterface(Components.interfaces.nsIRDFDataSource);
folderDataSource = folderDataSource.QueryInterface(Components.interfaces.nsIRDFDataSource);
var database = folderTree.database;
var database = GetFolderDatasource();
database.AddDataSource(accountManagerDataSource);
database.AddDataSource(folderDataSource);
folderTree.setAttribute('ref', 'msgaccounts:/');
}
function GetFolderDatasource()
{
var folderTree = GetFolderTree();
var db = folderTree.database;
if (!db) return false;
return db;
}
function OnLoadThreadPane(threadTree)
{
gThreadTree = threadTree;
@ -480,20 +488,6 @@ function FindInSidebar(currentWindow, id)
}
}
function GetThreadTree()
{
if (gThreadTree) return gThreadTree;
var threadTree = document.getElementById('threadTree');
gThreadTree = threadTree;
return threadTree;
}
function GetThreadTreeFolder()
{
var tree = GetThreadTree();
return tree;
}
function GetThreadAndMessagePaneSplitter()
{
if(gThreadAndMessagePaneSplitter) return gThreadAndMessagePaneSplitter;
@ -804,8 +798,7 @@ function GetCompositeDataSource(command)
if(command == "GetNewMessages" || command == "DeleteMessages" || command == "Copy" ||
command == "Move" || command == "NewFolder" || command == "MarkAllMessagesRead")
{
var folderTree = GetFolderTree();
return folderTree.database;
return GetFolderDatasource();
}
else if(command == "MarkMessageRead" ||
command == "MarkMessageFlagged" || command == "MarkThreadAsRead" ||

View File

@ -25,7 +25,7 @@ function ThreadPaneOnClick(event)
return;
var targetclass = event.target.getAttribute('class');
debug('targetclass = ' + targetclass + '\n');
dump('targetclass = ' + targetclass + '\n');
if (targetclass == 'tree-cell-twisty') {
// The twisty is nested three below the treeitem:
@ -169,3 +169,52 @@ function ChangeThreadView()
RefreshThreadTreeView();
}
}
function IsSpecialFolderSelected(folderName)
{
var selectedFolder = GetThreadTreeFolder();
var id = selectedFolder.getAttribute('ref');
var folderResource = RDF.GetResource(id);
if(!folderResource)
return false;
var db = GetFolderDatasource();
var property =
RDF.GetResource('http://home.netscape.com/NC-rdf#SpecialFolder');
if (!property) return false;
var result = db.GetTarget(folderResource, property , true);
if (!result) return false;
result = result.QueryInterface(Components.interfaces.nsIRDFLiteral);
if (!result) return false;
if(result.Value == folderName)
return true;
return false;
}
//Called when selection changes in the thread pane.
function ThreadPaneSelectionChange()
{
var collapsed = IsThreadAndMessagePaneSplitterCollapsed();
if(!collapsed)
{
LoadSelectionIntoMessagePane();
}
}
function GetThreadTree()
{
if (gThreadTree) return gThreadTree;
var threadTree = document.getElementById('threadTree');
gThreadTree = threadTree;
return threadTree;
}
function GetThreadTreeFolder()
{
var tree = GetThreadTree();
return tree;
}

View File

@ -99,7 +99,7 @@ function RenameFolder(name,uri)
if (uri && (uri != "") && name && (name != "")) {
var selectedFolder = GetResourceFromUri(uri);
folderTree.clearItemSelection();
messenger.RenameFolder(folderTree.database, selectedFolder, name);
messenger.RenameFolder(GetFolderDatasource(), selectedFolder, name);
}
else {
dump("no name or nothing selected\n");

View File

@ -149,7 +149,7 @@ function onEditFilter() {
var args = {filter: selectedFilter};
window.openDialog("chrome://messenger/content/FilterEditor.xul", "FilterEditor", "chrome,modal", args);
window.openDialog("chrome://messenger/content/FilterEditor.xul", "FilterEditor", "chrome,modal,resizable", args);
if (args.refresh)
refreshFilterList();
@ -160,7 +160,7 @@ function onNewFilter()
var curFilterList = currentFilterList();
var args = {filterList: curFilterList };
window.openDialog("chrome://messenger/content/FilterEditor.xul", "FilterEditor", "chrome,modal", args);
window.openDialog("chrome://messenger/content/FilterEditor.xul", "FilterEditor", "chrome,modal,resizable", args);
if (args.refresh) refreshFilterList();

View File

@ -21,12 +21,15 @@
var rdfDatasourcePrefix = "component://netscape/rdf/datasource?name=";
var rdfServiceProgID = "component://netscape/rdf/rdf-service";
var searchSessionProgID = "component://netscape/messenger/searchSession";
var folderDSProgID = rdfDatasourcePrefix + "mailnewsfolders";
var gSearchDatasource;
var nsIMsgFolder = Components.interfaces.nsIMsgFolder;
var nsMsgSearchScope = Components.interfaces.nsMsgSearchScope;
var gFolderDatasource;
var gFolderPicker;
var gThreadTree;
var gStatusFeedback = new nsMsgStatusFeedback;
var RDF;
@ -42,7 +45,7 @@ function searchOnLoad()
onMore(null);
gThreadTree = document.getElementById("threadTree");
}
function initializeSearchWindowWidgets()
@ -194,3 +197,17 @@ function testelement(element)
dump(element.id + ".searchScope = " + element.searchScope + "\n");
}
// stuff after this is implemented to make the thread pane work
function GetFolderDatasource()
{
if (!gFolderDatasource)
gFolderDatasource = Components.classes[folderDSProgID].createInstance(Components.interfaces.nsIRDFDataSource);
return gFolderDatasource;
}
// used to determine if we should try to load a message
function IsThreadAndMessagePaneSplitterCollapsed()
{
return true;
}

View File

@ -39,7 +39,6 @@ Rights Reserved.
<script src="chrome://global/content/strres.js"/>
<script src="chrome://messenger/content/mailWindow.js"/>
<script src="chrome://messenger/content/SearchDialog.js"/>
<text value="This dialog is a work in progress! Please don't file any bugs against it."/>
<box>
<text class="label" value="&searchHeading.label;"/>
<menulist id="searchableFolders" flex="2"
@ -56,7 +55,7 @@ Rights Reserved.
</box>
</box>
<tree id="threadTree" class="inset" flex="1" style="height:0px" context="threadPaneContext"/>
<tree id="threadTree" class="inset" flex="1" style="height: 50px" context="threadPaneContext"/>
<box>
<spring flex="100%"/>
<button value="&closeButton.label;" onclick="window.close()"/>

View File

@ -38,9 +38,9 @@
</radiogroup>
<spring class="spacer"/>
<box style="min-height:200px">
<box>
<box id="searchterms"/>
<tree class="inset" flex="1" id="searchTermTree">
<tree rows="5" class="inset" flex="1" id="searchTermTree">
<treecolgroup>
<treecol flex="1"/>
<treecol flex="4"/>

View File

@ -472,9 +472,8 @@ nsresult nsMsgFilter::SaveToTextFile(nsIOFileStream *stream)
nsresult nsMsgFilter::SaveRule()
{
nsresult err = NS_OK;
//char *relativePath = nsnull;
nsIMsgFilterList *filterList;
GetFilterList(&filterList);
nsCOMPtr<nsIMsgFilterList> filterList;
GetFilterList(getter_AddRefs(filterList));
nsCAutoString actionFilingStr;
GetActionFilingStr(m_action.m_type, actionFilingStr);

View File

@ -47,7 +47,8 @@ static const PRUnichar unicodeFormatter[] = {
};
nsMsgFilterList::nsMsgFilterList(nsIOFileStream *fileStream)
nsMsgFilterList::nsMsgFilterList(nsIOFileStream *fileStream) :
m_fileVersion(0)
{
m_fileStream = fileStream;
// I don't know how we're going to report this error if we failed to create the isupports array...

View File

@ -146,41 +146,15 @@ nsMsgSearchDataSource::HasAssertion(nsIRDFResource *aSource,
NS_ENSURE_ARG_POINTER(aResult);
if (!aTruthValue) return NS_RDF_NO_VALUE;
nsresult rv;
#ifdef DEBUG_alecf
nsXPIDLCString sourceVal;
aSource->GetValueConst(getter_Shares(sourceVal));
nsXPIDLCString propVal;
aProperty->GetValueConst(getter_Shares(propVal));
nsCOMPtr<nsIRDFResource> targetRes(do_QueryInterface(aTarget, &rv));
nsXPIDLCString targetVal;
if (NS_SUCCEEDED(rv))
targetRes->GetValueConst(getter_Shares(targetVal));
printf("HasAssertion(%s, %s, %s..)?\n",
(const char*)sourceVal,
(const char*)propVal,
(const char*)targetVal ? (const char*)targetVal : "(null)");
#endif
if (aSource == mSearchRoot.get() &&
aProperty == kNC_MessageChild.get()) {
#ifdef DEBUG_alecf
printf("I care about this one.\n");
#endif
PRInt32 indexOfResource;
mSearchResults->GetIndexOf(NS_STATIC_CAST(nsISupports*,aTarget),
&indexOfResource);
if (indexOfResource != -1) {
#ifdef DEBUG_alecf
printf("And it's a success!\n");
#endif
*aResult = PR_TRUE;
return NS_OK;
}