# ***** 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 the Places Tree View. # # The Initial Developer of the Original Code is Google Inc. # Portions created by the Initial Developer are Copyright (C) 2005-2006 # the Initial Developer. All Rights Reserved. # # Contributor(s): # Ben Goodger # Annie Sullivan # # 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 ***** null = 0; --i) { var index = resultview.treeIndexForNode(parents[i]); if (view.isContainer(index) && !view.isContainerOpen(index)) view.toggleOpenState(index); } // Select the specified node... index = resultview.treeIndexForNode(node); view.selection.select(index); // ... and ensure it's visible, not scrolled off somewhere. this.treeBoxObject.ensureRowIsVisible(index); ]]> = 1; ]]> = 0; i--) { if (PlacesController.nodeIsReadOnly(nodes[i].parent)) nodes.splice(i, 1); } return nodes; ]]> 0 ViewConfig.GENERIC_DROP_TYPES ViewConfig.GENERIC_DROP_TYPES false false false 0); child++) { var childNode = node.getChild(child); if (!PlacesController.nodeIsFolder(childNode)) continue; var childFolder = asFolder(childNode); // See if child matches an ID we wanted; add to results. if (childFolder.folderId in indexes) { nodes[childFolder.folderId] = childFolder; delete indexes[childFolder.folderId]; } // Search down that child's subtree. findNodes(childFolder, indexes, nodes); } // If we didn't find any additional matches in this node's // subtree, revert the node to its previous openness. if (len(nodes) == previousMatches) node.containerOpen = previousOpenness; } var indexes = {}; // Set of folder IDs to search for. var nodes = {}; // Dictionary of found IDs to found nodes. // Initialize input set for (var i = 0; i < ids.length; i++) indexes[ids[i]] = true; var root = this._getRootNode(); if (!root) { NS_ASSERT(root, "Couldn't select folders because no root node was available."); return; } findNodes(root, indexes, nodes); // For all the nodes we've found, highlight the corresponding // index in the tree. var resultview = this.getResultView(); var selection = this.view.selection; selection.clearSelection(); for(idx in nodes) { var index = resultview.treeIndexForNode(nodes[idx]); selection.rangedSelect(index, index, true); } ]]> = folder.childCount) index = folder.childCount - 1; NS_ASSERT(index < folder.childCount, "index out of range: " + index + " > " + folder); var insertionNode = index > -1 ? folder.getChild(index) : null; // Now close the folder again, if it was before. folder.containerOpen = folderWasOpen; return insertionNode; ]]> index) break; if (max.value >= index) selectionAbove += index - min.value; else selectionAbove += max.value - min.value + 1; } insertionPoint.index -= selectionAbove; }, /** * @returns the view where the drag was initiated. */ _getSourceView: function VO__getSourceView() { var session = this._getCurrentSession(); var sourceView = session.sourceNode; while (sourceView && sourceView.localName != "tree") sourceView = sourceView.parentNode; return sourceView; }, /** * @returns the current drag session. */ _getCurrentSession: function VO__getCurrentSession() { var dragService = Cc["@mozilla.org/widget/dragservice;1"]. getService(Ci.nsIDragService); return dragService.getCurrentSession(); }, /** * Handles a drop operation on this view * @param index * The index at which content was dropped * @param orientation * The orientation relative to the drop index where content * should be inserted. */ onDrop: function VO_onDrop(index, orientation) { LOG("VO: onDrop: " + index + ", orientation: " + orientation); if (!this.canDrop(index, orientation)) return; var sourceView = this._getSourceView(); // We are responsible for translating the |index| and |orientation| // parameters into a container id and index within the container, // since this information is specific to the tree view. var ip = this._self._getInsertionPoint(index, orientation); if (!ip) throw Cr.NS_ERROR_NOT_AVAILABLE; if (sourceView == this._self) { // We are moving nodes within the same view, we need to adjust the // insertion point to take into account the fact that rows may // disappear above it, causing its index to be incorrect. this._adjustInsertionPoint(ip); } PlacesControllerDragHelper.onDrop(sourceView, this._self, ip); }, onToggleOpenState: function VO_onToggleOpenState(index) { }, onSelectionChanged: function VO_onSelectionChanged() { }, onCycleHeader: function VO_onCycleHeader(column) { }, onCycleCell: function VO_onCycleCell(row, column) { }, onPerformAction: function VO_onPerformAction(action) { }, onPerformActionOnRow: function VO_onPerformActionOnRow(action, row) { }, onPerformActionOnCell: function VO_onPerformActionOnCell(action, row, column) { } })]]> [] 0 1 2 -1 && range.max > -1) this.view.selection.rangedSelect(range.min, range.max, true); } ]]>