Proof of concept for SoftwareUpdate sidebar.

This commit is contained in:
dougt%netscape.com 1999-05-27 22:14:10 +00:00
parent 6f61c81c3b
commit c9c7acd487
6 changed files with 244 additions and 0 deletions

View File

@ -0,0 +1,27 @@
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:NC="http://home.netscape.com/NC-rdf#">
<RDF:Bag ID="NC:SoftwareUpdateRoot">
<RDF:li>
<RDF:Description ID="AimUpdate344">
<NC:type resource="http://home.netscape.com/NC-rdf#SoftwarePackage" />
<NC:title>AOL AIM</NC:title>
<NC:description>An Instant Message Client</NC:description>
<NC:version>3.4.1.12</NC:version>
<NC:registryKey>/AOL/AIM/</NC:registryKey>
<NC:url>http://home.netscape.com/index.html</NC:url>
</RDF:Description>
</RDF:li>
<RDF:li>
<RDF:Description ID="PGPPlugin345">
<NC:type resource="http://home.netscape.com/NC-rdf#SoftwarePackage" />
<NC:title>PGP Plugin For Mozilla</NC:title>
<NC:description>A high grade encryption plugin</NC:description>
<NC:version>1.1.2.0</NC:version>
<NC:registryKey>/PGP/ROCKS/</NC:registryKey>
<NC:url>http://home.netscape.com/index.html</NC:url>
</RDF:Description>
</RDF:li>
</RDF:Bag>
</RDF:RDF>

View File

@ -0,0 +1,57 @@
window {
display: block;
}
tree {
display: table;
background-color: #FFFFFF;
border: none;
border-spacing: 0px;
width: 100%;
}
treecol {
display: table-column;
width: 200px;
}
treeitem {
display: table-row;
}
treehead {
display: table-header-group;
}
treebody {
display: table-row-group;
}
treecell {
display: table-cell;
font-family: Verdana, Sans-Serif;
font-size: 8pt;
}
treecell[selectedcell] {
background-color: yellow;
}
treehead treeitem treecell {
background-color: #c0c0c0;
border: outset 1px;
border-color: white #707070 #707070 white;
padding-left: 4px;
}
treeitem[type="http://home.netscape.com/NC-rdf#SoftwarePackage"] > treecell > titledbutton {
list-style-image: url("resource:/res/rdf/SoftwareUpdatePackage.gif");
}
treeitem[type="http://home.netscape.com/NC-rdf#Folder"] > treecell > titledbutton {
list-style-image: url("resource:/res/rdf/bookmark-folder-closed.gif");
treeitem[type="http://home.netscape.com/NC-rdf#Folder"][open="true"] > treecell > titledbutton {
list-style-image: url("resource:/res/rdf/bookmark-folder-open.gif");
}

View File

@ -0,0 +1,123 @@
// the rdf service
var RDF = Components.classes['component://netscape/rdf/rdf-service'].getService();
RDF = RDF.QueryInterface(Components.interfaces.nsIRDFService);
function getAttr(registry,service,attr_name)
{
var attr = registry.GetTarget(service,
RDF.GetResource('http://home.netscape.com/NC-rdf#' + attr_name),
true);
if (attr)
attr = attr.QueryInterface(Components.interfaces.nsIRDFLiteral);
if (attr)
attr = attr.Value;
return attr;
}
function Init()
{
// this is the main rdf file.
var mainRegistry = RDF.GetDataSource('resource://res/rdf/SoftwareUpdates.rdf');
var mainContainer = Components.classes['component://netscape/rdf/container'].createInstance();
mainContainer = mainContainer.QueryInterface(Components.interfaces.nsIRDFContainer);
mainContainer.Init(mainRegistry, RDF.GetResource('NC:SoftwareUpdateDataSources'));
// Now enumerate all of the softwareupdate datasources.
var mainEnumerator = mainContainer.GetElements();
while (mainEnumerator.HasMoreElements())
{
var aDistributor = mainEnumerator.GetNext();
aDistributor = aDistributor.QueryInterface(Components.interfaces.nsIRDFResource);
var distributorContainer = Components.classes['component://netscape/rdf/container'].createInstance();
distributorContainer = distributorContainer.QueryInterface(Components.interfaces.nsIRDFContainer);
var distributorRegistry = RDF.GetDataSource(aDistributor.Value);
var distributorResource = RDF.GetResource('NC:SoftwareUpdateRoot');
distributorContainer.Init(distributorRegistry, distributorResource);
// Now enumerate all of the distributorContainer's packages.
var distributorEnumerator = distributorContainer.GetElements();
while (distributorEnumerator.HasMoreElements())
{
var aPackage = distributorEnumerator.GetNext();
aPackage = aPackage.QueryInterface(Components.interfaces.nsIRDFResource);
// remove any that we do not want.
if (getAttr(distributorRegistry, aPackage, 'title') == "AOL AIM")
{
//distributorContainer.RemoveElement(aPackage, true);
}
}
var tree = document.getElementById('tree');
// Add it to the tree control's composite datasource.
tree.database.AddDataSource(distributorRegistry);
}
// Install all of the stylesheets in the softwareupdate Registry into the
// panel.
// TODO
// XXX hack to force the tree to rebuild
var treebody = document.getElementById('NC:SoftwareUpdateRoot');
treebody.setAttribute('id', 'NC:SoftwareUpdateRoot');
}
function OpenURL(event, node)
{
if (node.getAttribute('type') == "http://home.netscape.com/NC-rdf#SoftwarePackage")
{
url = node.getAttribute('url');
/*window.open(url,'bookmarks');*/
var toolkitCore = XPAppCoresManager.Find("ToolkitCore");
if (!toolkitCore)
{
toolkitCore = new ToolkitCore();
if (toolkitCore)
{
toolkitCore.Init("ToolkitCore");
}
}
if (toolkitCore)
{
toolkitCore.ShowWindow(url,window);
}
dump("OpenURL(" + url + ")\n");
return true;
}
return false;
}
// To get around "window.onload" not working in viewer.
function Boot()
{
var tree = document.getElementById('tree');
if (tree == null) {
setTimeout(Boot, 0);
}
else {
Init();
}
}
setTimeout('Boot()', 0);

View File

@ -0,0 +1,30 @@
<?xml version="1.0"?>
<?xml-stylesheet href="resource:/res/rdf/sidebar.css" type="text/css"?>
<?xml-stylesheet href="resource:/res/rdf/SoftwareUpdate.css" type="text/css"?>
<window
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<html:script src="SoftwareUpdate.js"/>
<tree id="tree"
flex="100%"
datasources="rdf:softwareupdates"
ondblclick="return OpenURL(event, event.target.parentNode);">
<treecol rdf:resource="http://home.netscape.com/NC-rdf#title" />
<treecol rdf:resource="http://home.netscape.com/NC-rdf#description" />
<treecol rdf:resource="http://home.netscape.com/NC-rdf#version" />
<treehead>
<treeitem>
<treecell>Title</treecell>
<treecell>Description</treecell>
<treecell>Version</treecell>
</treeitem>
</treehead>
<treebody id="NC:SoftwareUpdateRoot" rdf:containment="http://home.netscape.com/NC-rdf#child" />
</tree>
</window>

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 B

View File

@ -0,0 +1,7 @@
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:NC="http://home.netscape.com/softwareupdate-schema#">
<RDF:Bag ID="NC:SoftwareUpdateDataSources">
<RDF:li resource="resource:/res/rdf/SoftwareUpdate-Source-1.rdf" />
</RDF:Bag>
</RDF:RDF>