Fix for bug 221619. Tree widget refactoring and enhancement. r=neil sr=bryner

This commit is contained in:
varga%nixcorp.com 2006-07-27 14:58:20 +00:00
parent 7d22a7236c
commit 8c243fa803
5 changed files with 48 additions and 42 deletions

View File

@ -247,9 +247,8 @@ function BeginDragTree (event)
try {
// determine which treeitem was dragged
var tree = document.getElementById("tree");
var row = {}, colId = {}, child = {};
tree.treeBoxObject.getCellAt(event.clientX, event.clientY, row, colId, child);
var item = tree.contentView.getItemAtIndex(row.value);
var row = tree.treeBoxObject.getRowAt(event.clientX, event.clientY);
var item = tree.contentView.getItemAtIndex(row);
// get information from treeitem for drag
var url = item.getAttributeNS(NC_NS, "url");

View File

@ -110,7 +110,7 @@ function HistoryCommonInit()
if (gHistoryStatus)
gHistoryTree.focus();
gHistoryTree.treeBoxObject.view.selection.select(0);
gHistoryTree.view.selection.select(0);
}
function HistoryPanelUnload()
@ -153,7 +153,8 @@ function historyOnSelect()
var match;
var currentIndex = gHistoryTree.currentIndex;
var rowIsContainer = currentIndex < 0 || (gHistoryGrouping != "none" && isContainer(gHistoryTree, currentIndex));
var url = rowIsContainer ? "" : gHistoryTree.treeBoxObject.view.getCellText(currentIndex, "URL");
var col = gHistoryTree.columns["URL"];
var url = rowIsContainer ? "" : gHistoryTree.view.getCellText(currentIndex, col);
if (url) {
if (!gIOService)
@ -247,8 +248,10 @@ var historyDNDObserver = {
var currentIndex = gHistoryTree.currentIndex;
if (isContainer(gHistoryTree, currentIndex))
return false;
var url = gHistoryTree.treeBoxObject.view.getCellText(currentIndex, "URL");
var title = gHistoryTree.treeBoxObject.view.getCellText(currentIndex, "Name");
var col = gHistoryTree.columns["URL"];
var url = gHistoryTree.view.getCellText(currentIndex, col);
col = gHistoryTree.columns["Name"];
var title = gHistoryTree.view.getCellText(currentIndex, col);
var htmlString = "<A HREF='" + url + "'>" + title + "</A>";
aXferData.data = new TransferData();
@ -297,7 +300,7 @@ function OpenURL(aTarget)
}
if (aTarget != "current") {
var count = gHistoryTree.treeBoxObject.view.selection.count;
var count = gHistoryTree.view.selection.count;
var URLArray = [];
if (count == 1) {
if (isContainer(gHistoryTree, currentIndex))
@ -307,13 +310,14 @@ function OpenURL(aTarget)
URLArray.push(url);
}
else {
var col = gHistoryTree.columns["URL"];
var min = new Object();
var max = new Object();
var rangeCount = gHistoryTree.treeBoxObject.view.selection.getRangeCount();
var rangeCount = gHistoryTree.view.selection.getRangeCount();
for (var i = 0; i < rangeCount; ++i) {
gHistoryTree.treeBoxObject.view.selection.getRangeAt(i, min, max);
gHistoryTree.view.selection.getRangeAt(i, min, max);
for (var k = max.value; k >= min.value; --k) {
url = gHistoryTree.treeBoxObject.view.getCellText(k, "URL");
url = gHistoryTree.view.getCellText(k, col);
URLArray.push(url);
}
}
@ -385,28 +389,31 @@ var groupObserver = {
function historyAddBookmarks()
{
var count = gHistoryTree.treeBoxObject.view.selection.count;
var urlCol = gHistoryTree.columns["URL"];
var titleCol = gHistoryTree.columns["Name"];
var count = gHistoryTree.view.selection.count;
var url;
var title;
if (count == 1) {
var currentIndex = gHistoryTree.currentIndex;
url = gHistoryTree.treeBoxObject.view.getCellText(currentIndex, "URL");
title = gHistoryTree.treeBoxObject.view.getCellText(currentIndex, "Name");
url = gHistoryTree.treeBoxObject.view.getCellText(currentIndex, urlCol);
title = gHistoryTree.treeBoxObject.view.getCellText(currentIndex, titleCol);
BookmarksUtils.addBookmark(url, title, null, true);
}
else if (count > 1) {
var min = new Object();
var max = new Object();
var rangeCount = gHistoryTree.treeBoxObject.view.selection.getRangeCount();
var rangeCount = gHistoryTree.view.selection.getRangeCount();
if (!BMSVC) {
initServices();
initBMService();
}
for (var i = 0; i < rangeCount; ++i) {
gHistoryTree.treeBoxObject.view.selection.getRangeAt(i, min, max);
gHistoryTree.view.selection.getRangeAt(i, min, max);
for (var k = max.value; k >= min.value; --k) {
url = gHistoryTree.treeBoxObject.view.getCellText(k, "URL");
title = gHistoryTree.treeBoxObject.view.getCellText(k, "Name");
url = gHistoryTree.view.getCellText(k, urlCol);
title = gHistoryTree.view.getCellText(k, titleCol);
BookmarksUtils.addBookmark(url, title, null, false);
}
}
@ -416,7 +423,7 @@ function historyAddBookmarks()
function updateItems()
{
var count = gHistoryTree.treeBoxObject.view.selection.count;
var count = gHistoryTree.view.selection.count;
var openItem = document.getElementById("miOpen");
var bookmarkItem = document.getElementById("miAddBookmark");
var copyLocationItem = document.getElementById("miCopyLinkLocation");
@ -430,9 +437,9 @@ function updateItems()
if (gHistoryGrouping != "none") {
var min = new Object();
var max = new Object();
var rangeCount = gHistoryTree.treeBoxObject.view.selection.getRangeCount();
var rangeCount = gHistoryTree.view.selection.getRangeCount();
for (var i = 0; i < rangeCount; ++i) {
gHistoryTree.treeBoxObject.view.selection.getRangeAt(i, min, max);
gHistoryTree.view.selection.getRangeAt(i, min, max);
for (var k = max.value; k >= min.value; --k) {
if (isContainer(gHistoryTree, k)) {
hasContainer = true;

View File

@ -170,7 +170,7 @@ var cookiesTreeView = {
getCellValue : function(row,column) {},
getCellText : function(row,column){
var rv="";
switch (column) {
switch (column.id) {
case "domainCol":
rv = cookies[row].rawHost;
break;
@ -189,10 +189,10 @@ var cookiesTreeView = {
isSeparator : function(index) {return false;},
isSorted: function() { return false; },
isContainer : function(index) {return false;},
cycleHeader : function(aColId, aElt) {},
getRowProperties : function(row,column,prop){},
getColumnProperties : function(column,columnElement,prop){},
getCellProperties : function(row,prop){}
cycleHeader : function(aCol) {},
getRowProperties : function(row,prop) {},
getColumnProperties : function(column,prop) {},
getCellProperties : function(row,column,prop) {}
};
var cookiesTree;
@ -468,9 +468,9 @@ var permissionsTreeView = {
getCellValue : function(row,column) {},
getCellText : function(row,column){
var rv="";
if (column=="siteCol") {
if (column.id=="siteCol") {
rv = permissions[row].rawHost;
} else if (column=="capabilityCol") {
} else if (column.id=="capabilityCol") {
rv = permissions[row].capability;
}
return rv;
@ -478,10 +478,10 @@ var permissionsTreeView = {
isSeparator : function(index) {return false;},
isSorted: function() { return false; },
isContainer : function(index) {return false;},
cycleHeader : function(aColId, aElt) {},
getRowProperties : function(row,column,prop){},
getColumnProperties : function(column,columnElement,prop){},
getCellProperties : function(row,prop){}
cycleHeader : function(aCol) {},
getRowProperties : function(row,prop) {},
getColumnProperties : function(column,prop) {},
getCellProperties : function(row,column,prop) {}
};
var permissionsTree;

View File

@ -47,10 +47,10 @@ var permissionsTreeView = {
isSeparator: function(index) { return false; },
isSorted: function() { return false; },
isContainer: function(index) { return false; },
cycleHeader: function(aColId, aElt) {},
getRowProperties: function(row, column,prop) {},
getColumnProperties: function(column, columnElement, prop) {},
getCellProperties: function(row, prop) {}
cycleHeader: function(column) {},
getRowProperties: function(row, column, prop) {},
getColumnProperties: function(column, prop) {},
getCellProperties: function(row, column, prop) {}
};
var permissionsTree;

View File

@ -44,7 +44,7 @@ function DeleteSelectedItemFromTree
(tree, view, table, deletedTable, removeButton, removeAllButton) {
// Turn off tree selection notifications during the deletion
tree.treeBoxObject.view.selection.selectEventsSuppressed = true;
tree.view.selection.selectEventsSuppressed = true;
// remove selected items from list (by setting them to null) and place in deleted list
var selections = GetTreeSelections(tree);
@ -72,7 +72,7 @@ function DeleteSelectedItemFromTree
// update selection
var nextSelection = (selections[0] < table.length) ? selections[0] : table.length-1;
tree.treeBoxObject.view.selection.select(nextSelection);
tree.view.selection.select(nextSelection);
tree.treeBoxObject.ensureRowIsVisible(nextSelection);
} else {
@ -83,12 +83,12 @@ function DeleteSelectedItemFromTree
}
tree.treeBoxObject.view.selection.selectEventsSuppressed = false;
tree.view.selection.selectEventsSuppressed = false;
}
function GetTreeSelections(tree) {
var selections = [];
var select = tree.treeBoxObject.selection;
var select = tree.view.selection;
if (select) {
var count = select.getRangeCount();
var min = new Object();
@ -143,8 +143,8 @@ function SortTree(tree, view, table, column, lastSortColumn, lastSortAscending,
if (table[s].number == selectedNumber) {
// update selection
// note: we need to deselect before reselecting in order to trigger ...Selected()
tree.treeBoxObject.view.selection.select(-1);
tree.treeBoxObject.view.selection.select(s);
tree.view.selection.select(-1);
tree.view.selection.select(s);
selectedRow = s;
break;
}