2010-02-20 08:08:40 -08:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
|
|
|
<?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?>
|
|
|
|
<!--
|
|
|
|
XUL Widget Test for tree using a custom nsITreeView
|
|
|
|
-->
|
|
|
|
<window title="Tree" onload="init()"
|
|
|
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
|
|
|
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
|
|
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
|
|
|
|
|
|
|
<script src="tree_shared.js"/>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
<![CDATA[
|
|
|
|
|
|
|
|
var treeData = [["Mary", "206 Garden Avenue"],
|
|
|
|
["Chris", "19 Marion Street"],
|
|
|
|
["Sarah", "702 Fern Avenue"],
|
|
|
|
["John", "99 Westminster Avenue"]];
|
|
|
|
|
|
|
|
// This is our custom view, based on the treeview interface
|
|
|
|
var view =
|
|
|
|
{
|
|
|
|
value: "",
|
|
|
|
rowCount: 8,
|
2010-08-27 16:15:08 -07:00
|
|
|
getCellText: function(row, column) { return ((typeof treeData) != "undefined") ? treeData[row % 4][column.index] : ""; },
|
2010-02-20 08:08:40 -08:00
|
|
|
getCellValue: function(row, column) { return this.value; },
|
2010-08-27 16:15:08 -07:00
|
|
|
setCellText: function(row, column, val) { if ((typeof treeData) != "undefined") treeData[row % 4][column.index] = val; },
|
2010-02-20 08:08:40 -08:00
|
|
|
setCellValue: function(row, column, val) { this.value = val; },
|
|
|
|
setTree: function(tree) { this.tree = tree; },
|
|
|
|
isContainer: function(row) { return false; },
|
|
|
|
isContainerOpen: function(row) { return false; },
|
|
|
|
isContainerEmpty: function(row) { return false; },
|
|
|
|
isSeparator: function(row) { return false; },
|
|
|
|
isSorted: function(row) { return false; },
|
|
|
|
isSelectable: function(row, column) { return true; },
|
|
|
|
isEditable: function(row, column) { return row != 2 || column.index != 1; },
|
2010-08-27 16:15:08 -07:00
|
|
|
getProgressMode: function(row, column) { return ((typeof Components) != "undefined") ? Components.interfaces.nsITreeView.PROGRESS_NORMAL : null; },
|
2010-02-20 08:08:40 -08:00
|
|
|
getParentIndex: function(row, column) { return -1; },
|
|
|
|
getLevel: function(row) { return 0; },
|
|
|
|
hasNextSibling: function(row, column) { return row != this.rowCount - 1; },
|
|
|
|
getImageSrc: function(row, column) { return ""; },
|
|
|
|
cycleHeader: function(column) { },
|
|
|
|
getRowProperties: function(row, props) { },
|
|
|
|
getCellProperties: function(row, column, props) { },
|
|
|
|
getColumnProperties: function(column, props)
|
|
|
|
{
|
2010-08-27 16:15:08 -07:00
|
|
|
if ((typeof netscape) == "undefined")
|
|
|
|
return;
|
|
|
|
|
2010-02-20 08:08:40 -08:00
|
|
|
if (!column.index) {
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
|
|
|
var atomService = Components.classes["@mozilla.org/atom-service;1"].
|
|
|
|
getService(Components.interfaces.nsIAtomService);
|
|
|
|
props.AppendElement(atomService.getAtom("one"));
|
|
|
|
props.AppendElement(atomService.getAtom("two"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function getCustomTreeViewCellInfo()
|
|
|
|
{
|
|
|
|
var obj = { rows: [] };
|
|
|
|
|
2010-08-27 16:15:08 -07:00
|
|
|
if ((typeof view) == "undefined" || (typeof treeData) == "undefined")
|
|
|
|
return;
|
|
|
|
|
2010-02-20 08:08:40 -08:00
|
|
|
for (var row = 0; row < view.rowCount; row++) {
|
|
|
|
var cellInfo = [ ];
|
|
|
|
for (var column = 0; column < 1; column++) {
|
|
|
|
cellInfo.push({ label: "" + treeData[row % 4][column],
|
|
|
|
value: "",
|
|
|
|
properties: "",
|
|
|
|
editable: row != 2 || column.index != 1,
|
|
|
|
selectable: true,
|
|
|
|
image: "",
|
|
|
|
mode: Components.interfaces.nsITreeView.PROGRESS_NORMAL });
|
|
|
|
}
|
|
|
|
|
|
|
|
obj.rows.push({ cells: cellInfo,
|
|
|
|
properties: "",
|
|
|
|
container: false,
|
|
|
|
separator: false,
|
|
|
|
children: null,
|
|
|
|
level: 0,
|
|
|
|
parent: -1 });
|
|
|
|
}
|
|
|
|
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
function init()
|
|
|
|
{
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
|
|
|
var tree = document.getElementById("tree-view");
|
|
|
|
tree.view = view;
|
|
|
|
tree.treeBoxObject.ensureRowIsVisible(0);
|
|
|
|
is(tree.treeBoxObject.getFirstVisibleRow(), 0, "first visible after ensureRowIsVisible on load");
|
|
|
|
tree.setAttribute("rows", "4");
|
|
|
|
|
|
|
|
setTimeout(testtag_tree, 0, "tree-view", "treechildren-view", "multiple", "simple", "tree view");
|
|
|
|
}
|
|
|
|
|
|
|
|
]]>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<tree id="tree-view">
|
|
|
|
<treecols>
|
|
|
|
<treecol id="name" label="Name" sort="label" flex="1"/>
|
|
|
|
<treecol id="address" label="Address" flex="1"/>
|
|
|
|
</treecols>
|
|
|
|
<treechildren id="treechildren-view"/>
|
|
|
|
</tree>
|
|
|
|
|
|
|
|
<!-- test results are displayed in the html:body -->
|
|
|
|
<body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
|
|
|
|
|
|
|
|
<!-- test code goes here -->
|
|
|
|
<script type="application/javascript"><![CDATA[
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
|
|
|
]]>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
</window>
|
|
|
|
|