# -*- Mode: HTML; indent-tabs-mode: nil; -*- # ***** BEGIN LICENSE BLOCK ***** # Version: MPL 1.1/GPL 2.0/LGPL 2.1 # # The contents of this file are subject to the Mozilla Public License Version # 1.1 (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # http://www.mozilla.org/MPL/ # # Software distributed under the License is distributed on an "AS IS" basis, # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License # for the specific language governing rights and limitations under the # License. # # The Original Code is mozilla.org code. # # The Initial Developer of the Original Code is # Netscape Communications Corporation. # Portions created by the Initial Developer are Copyright (C) 1998 # the Initial Developer. All Rights Reserved. # # Contributor(s): # Ben Goodger (Original Author) # Blake Ross # Pierre Chanial (v 2.0) # Joey Minta # # Alternatively, the contents of this file may be used under the terms of # either the GNU General Public License Version 2 or later (the "GPL"), or # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), # in which case the provisions of the GPL or the LGPL are applicable instead # of those above. If you wish to allow use of your version of this file only # under the terms of either the GPL or the LGPL, and not to allow others to # use your version of this file under the terms of the MPL, indicate your # decision by deleting the provisions above and replace them with the notice # and other provisions required by the GPL or the LGPL. If you do not delete # the provisions above, a recipient may use your version of this file under # the terms of any one of the MPL, the GPL or the LGPL. # # ***** END LICENSE BLOCK ***** %bookmarksDTD; ]> false this.tree.focus(); null null 0) for (var k = 0; k < rangeCount; ++k) { var rangeMin = {}; var rangeMax = {}; this.treeBoxObject.view.selection.getRangeAt(k, rangeMin, rangeMax); for (var i = rangeMin.value; i <= rangeMax.value; ++i) { var selectedItem = this.getRowResource(i); var selectedParent = this.getParentResource(i); var isExpanded = this.treeBoxObject.view.isContainerOpen(i); selection.item .push(selectedItem); selection.parent.push(selectedParent); selection.isExpanded.push(isExpanded); } } selection.length = selection.item.length; BookmarksUtils.checkSelection(selection); return selection; ]]> # This function saves the current selection state before the tree is rebuilt # following a command execution. This allows us to remember which item(s) # was/were selected so that the user does not need to constantly refocus the # tree to perform a sequence of commands. [] # This function restores the selection appropriately after a command executes. # This is necessary because most commands trigger a rebuild of the tree which # destroys the selection. The restoration of selection is handled in three # different ways depending on the type of command that has been executed: # 1) Commands that remove rows: # The row immediately after the first range in the selection is selected, # if there is no row immediately after the first range the item before it # is selected # 2) Commands that insert rows: # The newly inserted rows are selected # 3) Commands that do not change the row count # The row(s) that was/were operated on remain selected. # # The calls to save/restore are placed in the doCommand method and thus all # commands must pass through this gate. The result is that this method becomes # the POLICY CENTER FOR POST-VIEW/EDIT SELECTION CHANGES. = maxCount) nextRow = maxCount-1; if (nextRow >= 0) newRanges.push({min: nextRow, max: nextRow}); break; // [Category 2] - Commands that insert rows case "cmd_paste": case "cmd_bm_import": case "cmd_bm_movebookmark": case "cmd_bm_newbookmark": case "cmd_bm_newfolder": case "cmd_bm_newseparator": case "cmd_undo": //XXXpch: doesn't work for insert case "cmd_redo": //XXXpch: doesn't work for remove // All items inserted will be selected. The implementation of this model // is left to |preUpdateTreeSelection|, called when an insert transaction is // executed, and |updateTreeSelection| called here. this.updateTreeSelection(); break; // [Category 3] - Commands that do not alter the row count case "cmd_copy": case "cmd_bm_properties": case "cmd_bm_rename": case "cmd_bm_setpersonaltoolbarfolder": case "cmd_bm_export": default: // The selection is unchanged. return; } var newSelection = this.treeBoxObject.view.selection; for (i = 0; i < newRanges.length; ++i) newSelection.rangedSelect(newRanges[i].min, newRanges[i].max, true); ]]> [] // keep track of the items that we will select // because we can not select rows during a batch. 0) this.mOuter.updateTreeSelection(); // use of a timer to speedup var This = this.mOuter; setTimeout( function (){This.treeBoxObject.view.selection.selectEventsSuppressed = false}, 100) //dump("DND time:"+(Date.now()-date)+"\n") }, onToggleOpenState: function (aRow) { // update the open attribute of the selection var selection = this.mOuter._selection; if (!selection) return; var resource = this.mOuter.getRowResource(aRow); for (var i=0; i // Adding the transaction listener var bkmkTxnSvc = Components.classes["@mozilla.org/bookmarks/transactionmanager;1"] .getService(Components.interfaces.nsIBookmarkTransactionManager); bkmkTxnSvc.transactionManager.AddListener(this.bookmarkTreeTransactionListener); var bkmkTxnSvc = Components.classes["@mozilla.org/bookmarks/transactionmanager;1"] .getService(Components.interfaces.nsIBookmarkTransactionManager); bkmkTxnSvc.transactionManager.RemoveListener(this.bookmarkTreeTransactionListener); 2 1 2