Changed all references of 'folder' to 'collection' in code to correspond to database / dataacess nomenclature.

This commit is contained in:
David Norton 2006-06-05 18:01:53 +00:00
parent 560864ad6b
commit 3796741911
5 changed files with 49 additions and 53 deletions

View File

@ -1,4 +1,4 @@
Scholar.FolderTreeView = function() Scholar.CollectionTreeView = function()
{ {
this._treebox = null; this._treebox = null;
this._dataItems = new Array(); this._dataItems = new Array();
@ -10,7 +10,7 @@ Scholar.FolderTreeView = function()
/* /*
* Unregisters itself from Scholar.Notifier (called on window close) * Unregisters itself from Scholar.Notifier (called on window close)
*/ */
Scholar.FolderTreeView.prototype.unregister = function() Scholar.CollectionTreeView.prototype.unregister = function()
{ {
Scholar.Notifier.unregisterColumnTree(this._unregisterID); Scholar.Notifier.unregisterColumnTree(this._unregisterID);
} }
@ -18,7 +18,7 @@ Scholar.FolderTreeView.prototype.unregister = function()
/* /*
* Is called by Scholar.Notifier on any changes to the data layer * Is called by Scholar.Notifier on any changes to the data layer
*/ */
Scholar.FolderTreeView.prototype.notify = function(action, type, ids) Scholar.CollectionTreeView.prototype.notify = function(action, type, ids)
{ {
ids = Scholar.flattenArguments(ids); ids = Scholar.flattenArguments(ids);
var madeChanges = false; var madeChanges = false;
@ -75,7 +75,7 @@ Scholar.FolderTreeView.prototype.notify = function(action, type, ids)
this._refreshHashMap(); this._refreshHashMap();
} }
Scholar.FolderTreeView.prototype.setTree = function(treebox) Scholar.CollectionTreeView.prototype.setTree = function(treebox)
{ {
if(this._treebox) if(this._treebox)
return; return;
@ -88,7 +88,7 @@ Scholar.FolderTreeView.prototype.setTree = function(treebox)
this._refreshHashMap(); this._refreshHashMap();
} }
Scholar.FolderTreeView.prototype.getCellText = function(row, column) Scholar.CollectionTreeView.prototype.getCellText = function(row, column)
{ {
var obj = this._getItemAtRow(row); var obj = this._getItemAtRow(row);
@ -98,17 +98,17 @@ Scholar.FolderTreeView.prototype.getCellText = function(row, column)
return ""; return "";
} }
Scholar.FolderTreeView.prototype.isContainer = function(row) Scholar.CollectionTreeView.prototype.isContainer = function(row)
{ {
return this._getItemAtRow(row).isCollection(); return this._getItemAtRow(row).isCollection();
} }
Scholar.FolderTreeView.prototype.isContainerOpen = function(row) Scholar.CollectionTreeView.prototype.isContainerOpen = function(row)
{ {
return this._dataItems[row][1]; return this._dataItems[row][1];
} }
Scholar.FolderTreeView.prototype.isContainerEmpty = function(row) Scholar.CollectionTreeView.prototype.isContainerEmpty = function(row)
{ {
var itemGroup = this._getItemAtRow(row); var itemGroup = this._getItemAtRow(row);
if(itemGroup.isCollection()) if(itemGroup.isCollection())
@ -117,9 +117,9 @@ Scholar.FolderTreeView.prototype.isContainerEmpty = function(row)
return true; return true;
} }
Scholar.FolderTreeView.prototype.getLevel = function(row) { return this._dataItems[row][2]; } Scholar.CollectionTreeView.prototype.getLevel = function(row) { return this._dataItems[row][2]; }
Scholar.FolderTreeView.prototype.getParentIndex = function(row) Scholar.CollectionTreeView.prototype.getParentIndex = function(row)
{ {
var thisLevel = this.getLevel(row); var thisLevel = this.getLevel(row);
if(thisLevel == 0) return -1; if(thisLevel == 0) return -1;
@ -129,7 +129,7 @@ Scholar.FolderTreeView.prototype.getParentIndex = function(row)
return -1; return -1;
} }
Scholar.FolderTreeView.prototype.hasNextSibling = function(row, afterIndex) Scholar.CollectionTreeView.prototype.hasNextSibling = function(row, afterIndex)
{ {
var thisLevel = this.getLevel(row); var thisLevel = this.getLevel(row);
for(var i = afterIndex + 1; i < this.rowCount; i++) for(var i = afterIndex + 1; i < this.rowCount; i++)
@ -140,7 +140,7 @@ Scholar.FolderTreeView.prototype.hasNextSibling = function(row, afterIndex)
} }
} }
Scholar.FolderTreeView.prototype.toggleOpenState = function(row) Scholar.CollectionTreeView.prototype.toggleOpenState = function(row)
{ {
var count = 0; //used to tell the tree how many rows were added/removed var count = 0; //used to tell the tree how many rows were added/removed
var thisLevel = this.getLevel(row); var thisLevel = this.getLevel(row);
@ -172,24 +172,24 @@ Scholar.FolderTreeView.prototype.toggleOpenState = function(row)
this._refreshHashMap(); this._refreshHashMap();
} }
Scholar.FolderTreeView.prototype._showItem = function(item, level, beforeRow) { this._dataItems.splice(beforeRow, 0, [item, false, level]); this.rowCount++; } Scholar.CollectionTreeView.prototype._showItem = function(item, level, beforeRow) { this._dataItems.splice(beforeRow, 0, [item, false, level]); this.rowCount++; }
Scholar.FolderTreeView.prototype._hideItem = function(row) { this._dataItems.splice(row,1); this.rowCount--; } Scholar.CollectionTreeView.prototype._hideItem = function(row) { this._dataItems.splice(row,1); this.rowCount--; }
Scholar.FolderTreeView.prototype._getItemAtRow = function(row) { return this._dataItems[row][0]; } Scholar.CollectionTreeView.prototype._getItemAtRow = function(row) { return this._dataItems[row][0]; }
Scholar.FolderTreeView.prototype.isSorted = function() { return false; } Scholar.CollectionTreeView.prototype.isSorted = function() { return false; }
Scholar.FolderTreeView.prototype.isSeparator = function(row) { return false; } Scholar.CollectionTreeView.prototype.isSeparator = function(row) { return false; }
Scholar.FolderTreeView.prototype.isEditable = function(row, idx) { return false; } Scholar.CollectionTreeView.prototype.isEditable = function(row, idx) { return false; }
Scholar.FolderTreeView.prototype.getRowProperties = function(row, prop) { } Scholar.CollectionTreeView.prototype.getRowProperties = function(row, prop) { }
Scholar.FolderTreeView.prototype.getColumnProperties = function(col, prop) { } Scholar.CollectionTreeView.prototype.getColumnProperties = function(col, prop) { }
Scholar.FolderTreeView.prototype.getCellProperties = function(row, col, prop) { } Scholar.CollectionTreeView.prototype.getCellProperties = function(row, col, prop) { }
Scholar.FolderTreeView.prototype.getImageSrc = function(row, col) { } Scholar.CollectionTreeView.prototype.getImageSrc = function(row, col) { }
Scholar.FolderTreeView.prototype.performAction = function(action) { } Scholar.CollectionTreeView.prototype.performAction = function(action) { }
Scholar.FolderTreeView.prototype.performActionOnCell = function(action, row, col) { } Scholar.CollectionTreeView.prototype.performActionOnCell = function(action, row, col) { }
Scholar.FolderTreeView.prototype.getProgressMode = function(row, col) { } Scholar.CollectionTreeView.prototype.getProgressMode = function(row, col) { }
Scholar.FolderTreeView.prototype.cycleHeader = function(column) { } Scholar.CollectionTreeView.prototype.cycleHeader = function(column) { }
Scholar.FolderTreeView.prototype.deleteSelection = function() Scholar.CollectionTreeView.prototype.deleteSelection = function()
{ {
if(this.selection.count == 0) if(this.selection.count == 0)
return; return;
@ -227,7 +227,7 @@ Scholar.FolderTreeView.prototype.deleteSelection = function()
this.selection.select(this.rowCount-1); this.selection.select(this.rowCount-1);
} }
Scholar.FolderTreeView.prototype._refreshHashMap = function() Scholar.CollectionTreeView.prototype._refreshHashMap = function()
{ {
// Create hash map of collection and object ids to row indexes // Create hash map of collection and object ids to row indexes
@ -241,7 +241,7 @@ Scholar.FolderTreeView.prototype._refreshHashMap = function()
//Scholar.debug(Scholar.varDump(this.objectRowMap)); //Scholar.debug(Scholar.varDump(this.objectRowMap));
} }
Scholar.FolderTreeView.prototype.canDrop = function(row, orient) Scholar.CollectionTreeView.prototype.canDrop = function(row, orient)
{ {
if(orient == this.DROP_ON && this._getItemAtRow(row).isCollection()) if(orient == this.DROP_ON && this._getItemAtRow(row).isCollection())
return true; return true;
@ -250,7 +250,7 @@ Scholar.FolderTreeView.prototype.canDrop = function(row, orient)
} }
Scholar.FolderTreeView.prototype.drop = function(row, orient) Scholar.CollectionTreeView.prototype.drop = function(row, orient)
{ {
//you can't really do anything here, look to overlay.js - ScholarCollectionsDragObserver //you can't really do anything here, look to overlay.js - ScholarCollectionsDragObserver
} }

View File

@ -178,15 +178,11 @@ Scholar.ItemTreeView.prototype.searchText = function(search)
Scholar.ItemTreeView.prototype._refreshHashMap = function() Scholar.ItemTreeView.prototype._refreshHashMap = function()
{ {
// Create hash map of folder and object ids to row indexes // Create hash map of item ids to row indexes
this._itemRowMap = new Array(); this._itemRowMap = new Array();
for(var i=0; i < this.rowCount; i++) for(var i=0; i < this.rowCount; i++)
this._itemRowMap[this._getItemAtRow(i).getID()] = i; this._itemRowMap[this._getItemAtRow(i).getID()] = i;
//Scholar.debug(Scholar.varDump(this.folderRowMap));
//Scholar.debug(Scholar.varDump(this.objectRowMap));
} }
Scholar.ItemTreeView.prototype.getCollectionID = function() Scholar.ItemTreeView.prototype.getCollectionID = function()

View File

@ -3,7 +3,7 @@
*/ */
var ScholarPane = new function() var ScholarPane = new function()
{ {
var foldersView; var collectionsView;
var itemsView; var itemsView;
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService); var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
@ -13,7 +13,7 @@ var ScholarPane = new function()
this.toggleDisplay = toggleDisplay; this.toggleDisplay = toggleDisplay;
this.newItem = newItem; this.newItem = newItem;
this.newCollection = newCollection; this.newCollection = newCollection;
this.folderSelected = folderSelected; this.onCollectionSelected = onCollectionSelected;
this.itemSelected = itemSelected; this.itemSelected = itemSelected;
this.deleteItemSelection = deleteItemSelection; this.deleteItemSelection = deleteItemSelection;
this.deleteCollectionSelection = deleteCollectionSelection; this.deleteCollectionSelection = deleteCollectionSelection;
@ -26,12 +26,12 @@ var ScholarPane = new function()
*/ */
function onLoad() function onLoad()
{ {
//Initialize folders view //Initialize collections view
foldersView = new Scholar.FolderTreeView(); collectionsView = new Scholar.CollectionTreeView();
document.getElementById('folders-tree').view = foldersView; document.getElementById('collections-tree').view = collectionsView;
//select Library //select Library
foldersView.selection.select(0); collectionsView.selection.select(0);
//Create the add menu with each item type //Create the add menu with each item type
var addMenu = document.getElementById('tb-add').firstChild; var addMenu = document.getElementById('tb-add').firstChild;
@ -52,7 +52,7 @@ var ScholarPane = new function()
*/ */
function onUnload() function onUnload()
{ {
foldersView.unregister(); collectionsView.unregister();
if(itemsView) if(itemsView)
itemsView.unregister(); itemsView.unregister();
} }
@ -84,14 +84,14 @@ var ScholarPane = new function()
Scholar.Collections.add(Scholar.getString('pane.collections.untitled')); Scholar.Collections.add(Scholar.getString('pane.collections.untitled'));
} }
function folderSelected() function onCollectionSelected()
{ {
if(itemsView) if(itemsView)
itemsView.unregister(); itemsView.unregister();
if(foldersView.selection.count == 1 && foldersView.selection.currentIndex != -1) if(collectionsView.selection.count == 1 && collectionsView.selection.currentIndex != -1)
{ {
var collection = foldersView._getItemAtRow(foldersView.selection.currentIndex); var collection = collectionsView._getItemAtRow(collectionsView.selection.currentIndex);
itemsView = new Scholar.ItemTreeView(collection); itemsView = new Scholar.ItemTreeView(collection);
document.getElementById('items-tree').view = itemsView; document.getElementById('items-tree').view = itemsView;
@ -137,15 +137,15 @@ var ScholarPane = new function()
function deleteCollectionSelection() function deleteCollectionSelection()
{ {
if(foldersView.selection.count > 0 && confirm(Scholar.getString('pane.collections.delete'))) if(collectionsView.selection.count > 0 && confirm(Scholar.getString('pane.collections.delete')))
foldersView.deleteSelection(); collectionsView.deleteSelection();
} }
function renameSelectedCollection() function renameSelectedCollection()
{ {
if(foldersView.selection.count > 0) if(collectionsView.selection.count > 0)
{ {
collection = foldersView._getItemAtRow(foldersView.selection.currentIndex); collection = collectionsView._getItemAtRow(collectionsView.selection.currentIndex);
var newName = prompt(Scholar.getString('pane.collections.rename'),collection.getName()); var newName = prompt(Scholar.getString('pane.collections.rename'),collection.getName());
if(newName) if(newName)

View File

@ -11,7 +11,7 @@
<script src="overlay.js"/> <script src="overlay.js"/>
<script src="itemTreeView.js"/> <script src="itemTreeView.js"/>
<script src="folderTreeView.js"/> <script src="collectionTreeView.js"/>
<commandset id="mainCommandSet"> <commandset id="mainCommandSet">
<command id="cmd_scholar_newItem" oncommand="ScholarPane.newItem(1);"/> <command id="cmd_scholar_newItem" oncommand="ScholarPane.newItem(1);"/>
@ -46,8 +46,8 @@
<toolbarbutton label="&toolbar.newCollection.label;" command="cmd_scholar_newCollection"/> <toolbarbutton label="&toolbar.newCollection.label;" command="cmd_scholar_newCollection"/>
<toolbarbutton id="tb-rename" label="&toolbar.renameCollection.label;" oncommand="ScholarPane.renameSelectedCollection();" disabled="true"/> <toolbarbutton id="tb-rename" label="&toolbar.renameCollection.label;" oncommand="ScholarPane.renameSelectedCollection();" disabled="true"/>
</toolbar> </toolbar>
<tree id="folders-tree" hidecolumnpicker="true" <tree id="collections-tree" hidecolumnpicker="true"
onselect="ScholarPane.folderSelected();" seltype="single" onselect="ScholarPane.onCollectionSelected();" seltype="single"
ondragover="nsDragAndDrop.dragOver(event,ScholarCollectionsDragObserver)" ondragdrop="nsDragAndDrop.drop(event,ScholarCollectionsDragObserver)" ondragover="nsDragAndDrop.dragOver(event,ScholarCollectionsDragObserver)" ondragdrop="nsDragAndDrop.drop(event,ScholarCollectionsDragObserver)"
onkeypress="if(event.keyCode == event.DOM_VK_BACK_SPACE || event.keyCode == event.DOM_VK_DELETE){ ScholarPane.deleteCollectionSelection(); return false; }" onkeypress="if(event.keyCode == event.DOM_VK_BACK_SPACE || event.keyCode == event.DOM_VK_DELETE){ ScholarPane.deleteCollectionSelection(); return false; }"
flex="1"> flex="1">

View File

@ -5,7 +5,7 @@ vbox #scholar-pane
padding: 4px; padding: 4px;
} }
tree #folders-tree tree #collections-tree
{ {
min-width: 100px; min-width: 100px;
max-width: 200px; max-width: 200px;