From 8c243fa803bde69afe6104182b63c098b4c96007 Mon Sep 17 00:00:00 2001 From: "varga%nixcorp.com" Date: Thu, 27 Jul 2006 14:58:20 +0000 Subject: [PATCH] Fix for bug 221619. Tree widget refactoring and enhancement. r=neil sr=bryner --- suite/common/directory/directory.js | 5 +-- suite/common/history/history.js | 43 +++++++++++-------- suite/common/permissions/cookieViewer.js | 22 +++++----- .../common/permissions/permissionsManager.js | 8 ++-- suite/common/permissions/treeUtils.js | 12 +++--- 5 files changed, 48 insertions(+), 42 deletions(-) diff --git a/suite/common/directory/directory.js b/suite/common/directory/directory.js index 3f193395caa9..dfcf6a456397 100644 --- a/suite/common/directory/directory.js +++ b/suite/common/directory/directory.js @@ -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"); diff --git a/suite/common/history/history.js b/suite/common/history/history.js index dca8929268be..cfd82f86e852 100644 --- a/suite/common/history/history.js +++ b/suite/common/history/history.js @@ -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 = "" + title + ""; 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; diff --git a/suite/common/permissions/cookieViewer.js b/suite/common/permissions/cookieViewer.js index 714a2bbd9172..8a2b0219bd00 100644 --- a/suite/common/permissions/cookieViewer.js +++ b/suite/common/permissions/cookieViewer.js @@ -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; diff --git a/suite/common/permissions/permissionsManager.js b/suite/common/permissions/permissionsManager.js index ef0802c28f96..7a4f9f1b54e0 100644 --- a/suite/common/permissions/permissionsManager.js +++ b/suite/common/permissions/permissionsManager.js @@ -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; diff --git a/suite/common/permissions/treeUtils.js b/suite/common/permissions/treeUtils.js index 20e56086d814..b2441ca611ba 100644 --- a/suite/common/permissions/treeUtils.js +++ b/suite/common/permissions/treeUtils.js @@ -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; }