Scholar.CollectionTreeView = function() { this._treebox = null; this._dataItems = new Array(); this.rowCount = 0; this._showItem(new Scholar.ItemGroup('library',null),0,1); this._unregisterID = Scholar.Notifier.registerColumnTree(this); } /* * Unregisters itself from Scholar.Notifier (called on window close) */ Scholar.CollectionTreeView.prototype.unregister = function() { Scholar.Notifier.unregisterColumnTree(this._unregisterID); } /* * Is called by Scholar.Notifier on any changes to the data layer */ Scholar.CollectionTreeView.prototype.notify = function(action, type, ids) { ids = Scholar.flattenArguments(ids); var madeChanges = false; if(action == 'remove') { //Since a remove involves shifting of rows, we have to do it in order //sort the ids by row var rows = new Array(); for(var i=0, len=ids.length; i 0) { rows.sort(function(a,b) { return a-b }); for(var i=0, len=rows.length; i= 0; i--) if(this.getLevel(i) < thisLevel) return i; return -1; } Scholar.CollectionTreeView.prototype.hasNextSibling = function(row, afterIndex) { var thisLevel = this.getLevel(row); for(var i = afterIndex + 1; i < this.rowCount; i++) { var nextLevel = this.getLevel(i); if(nextLevel == thisLevel) return true; else if(nextLevel < thisLevel) return false; } } Scholar.CollectionTreeView.prototype.toggleOpenState = function(row) { var count = 0; //used to tell the tree how many rows were added/removed var thisLevel = this.getLevel(row); this._treebox.beginUpdateBatch(); if(this.isContainerOpen(row)) { while((row + 1 < this._dataItems.length) && (this.getLevel(row + 1) > thisLevel)) { this._hideItem(row+1); count--; //count is negative when closing a container because we are removing rows } } else { var newRows = Scholar.getCollections(this._getItemAtRow(row).ref.getID()); //Get children for(var i = 0; i < newRows.length; i++) { count++; this._showItem(new Scholar.ItemGroup('collection',newRows[i]), thisLevel+1, row+i+1); //insert new row } } this._dataItems[row][1] = !this._dataItems[row][1]; //toggle container open value this._treebox.rowCountChanged(row+1, count); //tell treebox to repaint these this._treebox.invalidateRow(row); this._treebox.endUpdateBatch(); this._refreshHashMap(); } Scholar.CollectionTreeView.prototype._showItem = function(item, level, beforeRow) { this._dataItems.splice(beforeRow, 0, [item, false, level]); this.rowCount++; } Scholar.CollectionTreeView.prototype._hideItem = function(row) { this._dataItems.splice(row,1); this.rowCount--; } Scholar.CollectionTreeView.prototype._getItemAtRow = function(row) { return this._dataItems[row][0]; } Scholar.CollectionTreeView.prototype.isSorted = function() { return false; } Scholar.CollectionTreeView.prototype.isSeparator = function(row) { return false; } Scholar.CollectionTreeView.prototype.isEditable = function(row, idx) { return false; } Scholar.CollectionTreeView.prototype.getRowProperties = function(row, prop) { } Scholar.CollectionTreeView.prototype.getColumnProperties = function(col, prop) { } Scholar.CollectionTreeView.prototype.getCellProperties = function(row, col, prop) { } Scholar.CollectionTreeView.prototype.getImageSrc = function(row, col) { } Scholar.CollectionTreeView.prototype.performAction = function(action) { } Scholar.CollectionTreeView.prototype.performActionOnCell = function(action, row, col) { } Scholar.CollectionTreeView.prototype.getProgressMode = function(row, col) { } Scholar.CollectionTreeView.prototype.cycleHeader = function(column) { } Scholar.CollectionTreeView.prototype.deleteSelection = function() { if(this.selection.count == 0) return; //collapse open collections for(var i=0; i