more changes for the new subscribe dialog. not turned on yet.

This commit is contained in:
sspitzer%netscape.com 2000-04-01 01:56:16 +00:00
Родитель e065b12714
Коммит 872492417a
2 изменённых файлов: 86 добавлений и 85 удалений

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

@ -3,38 +3,19 @@ var gCurrentServer = null;
var okCallback = null;
var gChangeTable = {};
var gServerURI = null;
var RDF = null;
var SubscribeDS = null;
var gCurrentServerURI = null;
function AddItem(children,cells)
function SetUpTree()
{
var kids = document.getElementById(children);
var item = document.createElement("treeitem");
var row = document.createElement("treerow");
var nntpService = Components.classes['component://netscape/messenger/nntpservice'].getService(Components.interfaces.nsINntpService);
nntpService = nntpService.QueryInterface(Components.interfaces.nsINntpService);
nntpService.buildSubscribeDatasource(gCurrentServer);
for(var i = 0; i < cells.length; i++) {
var cell = document.createElement("treecell");
cell.setAttribute("value", cells[i])
cell.setAttribute("id", cells[0] + "#" + i)
row.appendChild(cell);
}
item.appendChild(row);
item.setAttribute("id",cells[0]);
kids.appendChild(item);
}
var SubscribeDialogListener = {
AddItem: function(name, subscribed, count) {
dump(name + "," + subscribed + "," + count + "\n");
AddItem("folders",[name,subscribed,count]);
}
};
function SetUpTree(server)
{
dump("SetUpTree("+ server.hostname + ")\n");
var master = server.QueryInterface(Components.interfaces.nsISubscribeDialogMaster);
master.populateSubscribeDialog(SubscribeDialogListener);
gCurrentServerURI = "news://" + gCurrentServer.hostName;
dump("root subscribe tree at: "+gCurrentServerURI+"\n");
gSubscribeTree.setAttribute('ref',gCurrentServerURI);
}
function SubscribeOnLoad()
@ -42,7 +23,6 @@ function SubscribeOnLoad()
dump("SubscribeOnLoad()\n");
gSubscribeTree = document.getElementById('subscribetree');
gCurrentServer = document.getElementById('currentserver');
doSetOKCancel(subscribeOK,subscribeCancel);
@ -57,33 +37,17 @@ function SubscribeOnLoad()
}
}
// pre select the folderPicker, based on what they selected in the folder pane
if (window.arguments[0].preselectedURI) {
gServerURI = window.arguments[0].preselectedURI;
var folder = GetMsgFolderFromUri(window.arguments[0].preselectedURI);
var server = folder.server;
folder = GetMsgFolderFromUri(window.arguments[0].preselectedURI);
gCurrentServer = folder.server;
SetUpTree();
RDF = Components.classes["component://netscape/rdf/rdf-service"].getService();
RDF = RDF.QueryInterface(Components.interfaces.nsIRDFService);
gCurrentServer.value = server.hostName; // use gServer.prettyName?
SetUpTree(server);
dump("for each child of " + server.hostName + " set subscribed to true in the datasource\n");
var folders = folder.GetSubFolders();
if (folders) {
try {
while (true) {
var i = folders.currentItem();
var f = i.QueryInterface(Components.interfaces.nsIMsgFolder);
SetState(f.name, null, 'true');
folders.next();
}
}
catch (ex) {
dump("no more subfolders\n");
}
}
SubscribeDS = RDF.GetDataSource("rdf:subscribe");
}
}
@ -102,18 +66,20 @@ function subscribeCancel()
return true;
}
function SetState(uri, element, state)
function SetState(uri, state)
{
var subCell = element;
dump("SetState: " + uri + "," + element + "," + state + "\n");
if (!subCell) {
subCell = document.getElementById(uri + "#1");
dump("subCell =" + subCell + "\n");
}
dump("SetState(" + uri +"," + state + ")\n");
if (!uri || !state) return;
if (subCell) {
subCell.setAttribute("value",state);
try {
var src = RDF.GetResource(uri, true);
var prop = RDF.GetResource("http://home.netscape.com/NC-rdf#Subscribed", true);
var oldLiteral = SubscribeDS.GetTarget(src, prop, true);
var newLiteral = RDF.GetLiteral(state);
SubscribeDS.Change(src, prop, oldLiteral, newLiteral);
}
catch (ex) {
dump("failed: " + ex + "\n");
}
}
@ -135,6 +101,9 @@ function StateChanged(uri,state)
function SetSubscribeState(state)
{
dump("SetSubscribedState()\n");
try {
dump("subscribe button clicked\n");
var groupList = gSubscribeTree.selectedItems;
@ -142,12 +111,13 @@ function SetSubscribeState(state)
group = groupList[i];
uri = group.getAttribute('id');
dump(uri + "\n");
var cells = group.getElementsByAttribute("id",uri + "#1");
dump("cell=" + cells[0] + "\n");
SetState(uri, cells[0], state);
SetState(uri, state);
StateChanged(uri,state);
}
}
catch (ex) {
dump("SetSubscribedState failed: " + ex + "\n");
}
}
function SubscribeOnClick(event)

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

@ -31,7 +31,7 @@ Rights Reserved.
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:NC="http://home.netscape.com/NC-rdf#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
align="vertical"
orient="vertical"
class="dialog"
height="300"
width="600"
@ -43,40 +43,71 @@ Rights Reserved.
<keyset id="keyset"/>
<box align="horizontal" flex="100%">
<box align="vertical" flex="100%">
<box align="horizontal" flex="100%">
<html:div>&server.label;</html:div>
<titledbutton id="currentserver" value="..."/>
<box orient="horizontal" flex="100%">
<box orient="vertical" flex="100%">
<box orient="horizontal" flex="100%">
<text class="label" value="&server.label;" for="currentserver"/>
<menulist id="currentserver" value="...">
<menupopup>
<menuitem value="news.mozilla.org" uri="news://news.mozilla.org" />
<menuitem value="news.fresmeat.net" uri="news://news.freshmeant.net" />
<menuitem value="news.mcom.com" uri="news://news.mcom.com" />
<!--
<menupopup datasources="rdf:msgaccountmanager" ref="msgaccounts:/">
<template>
<rule>
<menuitem value="..."/>
</rule>
</template>
-->
</menupopup>
</menulist>
</box>
<box align="horizontal" flex="100%">
<html:div>&folders.label;</html:div>
<html:input tabindex="0" type="text" id="name"
style="width:100%"/>
<box orient="horizontal" flex="100%">
<text class="label" value="&folders.label;" for="name"/>
<textfield id="name"/>
</box>
</box>
</box>
<box align="horizontal" flex="100%">
<box align="vertical" flex="100%">
<box orient="horizontal" flex="100%">
<box orient="vertical" flex="100%">
<tree style="width:100px;" flex="100%"
class="inset"
id="subscribetree"
datasources="rdf:subscribe"
onclick="SubscribeOnClick(event);">
<template>
<rule>
<treechildren>
<treeitem uri="...">
<treerow>
<treecell value="rdf:http://home.netscape.com/NC-rdf#Name"/>
<treecell value="rdf:http://home.netscape.com/NC-rdf#Subscribed"/>
<treecell value="rdf:http://home.netscape.com/NC-rdf#Count"/>
</treerow>
</treeitem>
</treechildren>
</rule>
</template>
<treecolgroup id="theSubscribeColumns">
<treecol width="8*" id="NameColumn" rdf:resource="http://home.netscape.com/NC-rdf#Name"/>
<treecol width="1*" id="SubscribedColumn" rdf:resource="http://home.netscape.com/NC-rdf#Subscribed"/>
<treecol width="1*" id="CountColumn" rdf:resource="http://home.netscape.com/NC-rdf#Count"/>
</treecolgroup>
<treehead>
<treerow id="headRow">
<treecell value="&foldersHeader.label;"/>
<treecell value="&foldersHeader.label;" />
<treecell value="&subscribedHeader.label;"/>
<treecell value="&messagesHeader.label;"/>
</treerow>
</treehead>
<treechildren>
<treeitem id="folders"/>
</treechildren>
</tree>
</box>
<box align="vertical" flex="20%">
<box orient="vertical" flex="20%">
<spring flex="100%"/>
<titledbutton id="subscribe" class="push" value="&subscribeButton.label;" onclick="SetSubscribeState('true')"/>
<titledbutton id="unsubscribe" class="push" value="&unsubscribeButton.label;" onclick="SetSubscribeState('false')"/>