Fix crash on customize. (bug #9435).

This commit is contained in:
slamm%netscape.com 1999-07-12 23:24:22 +00:00
parent 11d9156c66
commit 1c5128ed66
5 changed files with 123 additions and 198 deletions

View File

@ -116,43 +116,3 @@ function createOption() {
parent.frames[0].location.reload();
}
/*
function createOption() {
var selectedNode_Title = window.frames[0].selectedNode_Title;
var selectedNode_Content = window.frames[0].selectedNode_Content;
var selectedNode_Customize = window.frames[0].selectedNode_Customize;
var list = parent.frames[0].document.getElementById('selectList');
//dump(option_title + "\n");
var optionSelect = parent.frames[0].createOptionTitle(selectedNode_Title);
var option = parent.frames[0].document.createElement('html:option');
dump(option + "\n");
option.setAttribute('title', selectedNode_Title);
option.setAttribute('customize', selectedNode_Content);
option.setAttribute('content', selectedNode_Customize);
option.appendChild(optionSelect);
return option;
}
function createOptionTitle(titletext)
{
dump('create optionText');
var title = parent.frames[0].document.createElement('html:option');
var textOption = parent.frames[0].document.createTextNode(titletext);
//should be able to use title.add actaully
dump("TextOption:\n" + textOption + "\n");
title.appendChild(textOption);
return textOption;
}
*/

View File

@ -1,37 +1,43 @@
<?xml version="1.0"?>
<?xml-stylesheet href="resource:/res/rdf/sidebar.css" type="text/css"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://sidebar/skin/" 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:NC="http://home.netscape.com/NC-rdf#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<html:script src="dialog.js" />
<tree id="tree"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
align="vertical">
<html:script src="resource:/res/rdf/dialog.js" />
<tree id="tree" flex="100%"
datasources="resource:/res/rdf/sidebar-registry.rdf"
onclick="selected(event,event.target.parentNode)" >
<!-- The template we'll use to build rows in the content model. -->
<template containment="treeitem" rootcontainment="treebody" subcontainment="treechildren">
<treeitem uri="...">
<treecell>
<treeindentation />
<titledbutton />
<text rdf:resource="http://home.netscape.com/NC-rdf#title" />
</treecell>
</treeitem>
<template>
<rule rootcontainment="treechildren" subcontainment="treechildren">
<treeitem uri="...">
<treerow>
<treecell>
<treeindentation />
<titledbutton value="rdf:http://home.netscape.com/NC-rdf#title" align="right" />
</treecell>
</treerow>
</treeitem>
</rule>
</template>
<!-- The tree header: display some column info. -->
<treehead>
<treeitem>
<treerow>
<treecell>Title</treecell>
</treeitem>
</treerow>
</treehead>
<!-- The tree body: it's rooted at sitemap1.rdf's root -->
<treebody ref="NC:BrowserSidebarRoot" />
<treechildren ref="NC:BrowserSidebarRoot" open="true" />
</tree>
</window>

View File

@ -4,62 +4,48 @@
var RDF = Components.classes['component://netscape/rdf/rdf-service'].getService();
RDF = RDF.QueryInterface(Components.interfaces.nsIRDFService);
// the current profile directory
// XXX obviously, this shouldn't be hard-coded
var profiledir = 'resource:/res/rdf/';
var sidebar = new Object;
// the location of the flash registry.
var sidebardb = profiledir + 'sidebar-browser.rdf';
//var sidebardb = 'file:///C:/matt/rdf/sidebar-browser.rdf';
var sidebar_resource = 'NC:BrowserSidebarRoot';
function dumpTree(node, depth) {
var inde
nt = "| | | | | | | | | | | | | | | | | | | | | | | | | | | | | + ";
var kids = node.childNodes;
dump(indent.substr(indent.length - depth*2));
// Print your favorite attributes here
dump(node.nodeName)
dump(" "+node.getAttribute('id'));
dump("\n");
for (var ii=0; ii < kids.length; ii++) {
dumpTree(kids[ii], depth + 1);
}
}
function Init(sidebardb, sidebar_resource)
function Init()
{
dump("here we go \n");
// Initialize the Sidebar
sidebar.db = window.arguments[0];
sidebar.resource = window.arguments[1];
// Install all the datasources named in the Flash Registry into
// the tree control. Datasources are listed as members of the
// NC:FlashDataSources sequence, and are loaded in the order that
// they appear in that sequence.
var registry = RDF.GetDataSource(sidebardb);
dump("Sidebar Customize Init("+sidebar.db+",\n "+sidebar.resource+")\n");
var registry;
try {
// First try to construct a new one and load it
// synchronously. nsIRDFService::GetDataSource() loads RDF/XML
// asynchronously by default.
registry = Components.classes['component://netscape/rdf/datasource?name=xml-datasource'].createInstance();
registry = registry.QueryInterface(Components.interfaces.nsIRDFDataSource);
// Create a 'container' wrapper around the sidebar_resources
var remote = registry.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource);
remote.Init(sidebar.db); // this will throw if it's already been opened and registered.
// read it in synchronously.
remote.Refresh(true);
}
catch (ex) {
// if we get here, then the RDF/XML has been opened and read
// once. We just need to grab the datasource.
registry = RDF.GetDataSource(sidebar.db);
}
// Create a 'container' wrapper around the sidebar.resources
// resource so we can use some utility routines that make access a
// bit easier.
var sb_datasource = Components.classes['component://netscape/rdf/container'].createInstance();
sb_datasource = sb_datasource.QueryInterface(Components.interfaces.nsIRDFContainer);
sb_datasource.Init(registry, RDF.GetResource(sidebar_resource));
sb_datasource.Init(registry, RDF.GetResource(sidebar.resource));
var sideoption = document.getElementById('selectList');
// Now enumerate all of the flash datasources.
dump(sb_datasource.GetElements() + '\n');
var enumerator = sb_datasource.GetElements();
var count = 0;
var countTotal = sb_datasource.GetCount();
dump("Start Get:" + countTotal + "\n");
while (enumerator.HasMoreElements()) {
count = ++count;
dump(count + "\n");
var service = enumerator.GetNext();
service = service.QueryInterface(Components.interfaces.nsIRDFResource);
@ -156,16 +142,16 @@ function moveUp() {
}
function moveDown() {
var list = document.getElementById('selectList');
var listSelect = list.selectedIndex;
dump("list\n" + listSelect);
if (list.selectedIndex != -1) {
var listOption = list.childNodes.item(listSelect);
var listOptionBefore = list.childNodes.item(listSelect+1).cloneNode(true);
list.remove(listSelect+1);
list.insertBefore(listOptionBefore, listOption);
dump("\n" + listOption + "\n");
}
var list = document.getElementById('selectList');
var listSelect = list.selectedIndex;
dump("list\n" + listSelect);
if (list.selectedIndex != -1) {
var listOption = list.childNodes.item(listSelect);
var listOptionBefore = list.childNodes.item(listSelect+1).cloneNode(true);
list.remove(listSelect+1);
list.insertBefore(listOptionBefore, listOption);
dump("\n" + listOption + "\n");
}
}
function deleteOption()
@ -278,22 +264,3 @@ function writeRDF(title,content,customize,append)
datasource.Flush();
dump("wrote " + FileURL + " back to disk.\n");
}
// To get around "window.onload" not working in viewer.
function Boot()
{
var root = document.documentElement;
dump("booting \n");
if (root == null) {
setTimeout(Boot, 0);
}
else {
Init(sidebardb, sidebar_resource);
}
}
setTimeout('Boot()', 0);
dump("finished\n");

View File

@ -1,61 +1,84 @@
<?xml version="1.0"?>
<?xml-stylesheet href="resource:/res/samples/xul.css" type="text/css"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<!DOCTYPE window>
<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">
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="Init();">
<html:script src="dialogSidebar.js" />
<html:script src="resource://res/rdf/dialogSidebar.js" />
Current My Sidebar
<html:div>
<box align="horizontal">
<box align="vertical">
<html:div>
Current Panels
</html:div>
<html:form name="one">
<html:select name="two" id="selectList" size="10" multiple="true">
</html:select>
<box align="horizontal">
<box align="vertical">
<spring flex="50%"/>
<html:button onclick="moveUp()">
<html:div>Move Up</html:div>
</html:button>
<html:button onclick="moveDown()">
<html:div>Move Down</html:div>
</html:button>
<spring flex="50%"/>
</box>
</html:form>
<html:form name="one">
<html:select name="two" id="selectList" size="10">
</html:select>
</html:form>
<box align="vertical">
<spring flex="50%"/>
<html:button onclick="">
<html:div>Customize</html:div>
</html:button>
<html:button onclick="deleteOption()">
<html:div>Remove</html:div>
</html:button>
<spring flex="50%"/>
</box>
<box align="vertical">
<spring flex="100%"/>
<html:button style="width:144px; height:15px;" onclick="moveUp()">
<html:div>Move Up</html:div>
</html:button>
<spring style="width:15px"/>
<html:button style="width:108px; height:15px;" onclick="moveDown()">
<html:div>Move Down</html:div>
</html:button>
<html:button style="width:108px; height:15px;" onclick="dump('here');deleteOption()">
<html:div>Remove</html:div>
</html:button>
<spring style="width:15px"/>
<html:button style="width:108px; height:15px;" onclick="parent.frames[1].location.href = 'about:blank'">
<html:div>Customize</html:div>
</html:button>
<!-- <html:button style="width:108px; height:15px;" onclick="writeRDF('New Panel','http://foo.com/content.html','http://foo.com/customize.html',0)">
<html:div>Add</html:div>
</html:button>
<html:button style="width:108px; height:15px;" onclick="writeRDF('New Panel','http://foo.com/content.html','http://foo.com/customize.html',1)">
<html:div>Remove</html:div>
</html:button>
<html:button style="width:108px; height:15px;" onclick="DumpIt()">
<html:div>RemoveIt</html:div>
</html:button> -->
</box>
<html:hr/>
<html:div>
Select a Panel to Add
</html:div>
<box align="horizontal" height="100%">
<html:iframe id="dialog" scrolling="auto" resize="yes" height="90%" src="resource://res/rdf/dialog.xul"/>
<box align="vertical">
<spring flex="500%"/>
<html:button onclick="Addit()" flex="100%">
<html:div>Add</html:div>
</html:button>
<html:button onclick="" flex="100%">
<html:div>Preview ...</html:div>
</html:button>
<spring flex="50%"/>
</box>
</box>
<html:hr/>
<box align="horizontal">
<spring flex="100%"/>
<html:button onclick="Cancel();">Cancel</html:button>
<html:button onclick="Save();">Save</html:button>
</box>
</box>
</box>
</html:div>
</window>

View File

@ -1,31 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="resource:/res/samples/xul.css" type="text/css"?>
<!-- <?xml-stylesheet href="resource:/res/rdf/sidebar-browser.css" type="text/css"?> -->
<window
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<html:script src="dialog.js" />
<html:div>
Add to My Sidebar
<box align="horizontal" height="100%">
<html:iframe id="dialog" src="dialog.xul" scrolling="auto" resize="yes" height="90%"/>
<box align="vertical">
<html:button style="width:108px; height:15px;" onclick="Addit()">
<html:div>Add</html:div>
</html:button>
<html:button style="width:108px; height:15px;" onclick="">
<html:div>Preview ...</html:div>
</html:button>
</box>
</box>
</html:div>
</window>