diff --git a/chrome/chromeFiles/content/scholar/collectionTreeView.js b/chrome/chromeFiles/content/scholar/collectionTreeView.js index 868a342a8b..69417bd05d 100644 --- a/chrome/chromeFiles/content/scholar/collectionTreeView.js +++ b/chrome/chromeFiles/content/scholar/collectionTreeView.js @@ -321,6 +321,39 @@ Scholar.CollectionTreeView.prototype._refreshHashMap = function() this._collectionRowMap[this._getItemAtRow(i).ref.getID()] = i; +} + +//////////////////////////////////////////////////////////////////////////////// +/// +/// Command Controller: +/// for Select All, etc. +/// +//////////////////////////////////////////////////////////////////////////////// + +Scholar.CollectionTreeCommandController = function(tree) +{ + this.tree = tree; +} + +Scholar.CollectionTreeCommandController.prototype.supportsCommand = function(cmd) +{ + return (cmd == 'cmd_delete'); +} + +Scholar.CollectionTreeCommandController.prototype.isCommandEnabled = function(cmd) +{ + return (cmd == 'cmd_delete' && this.tree.view.selection.count > 0); +} + +Scholar.CollectionTreeCommandController.prototype.doCommand = function(cmd) +{ + if(cmd == 'cmd_delete') + ScholarPane.deleteSelectedCollection(); +} + +Scholar.CollectionTreeCommandController.prototype.onEvent = function(evt) +{ + } //////////////////////////////////////////////////////////////////////////////// diff --git a/chrome/chromeFiles/content/scholar/itemTreeView.js b/chrome/chromeFiles/content/scholar/itemTreeView.js index f7859075aa..c49d138fd7 100644 --- a/chrome/chromeFiles/content/scholar/itemTreeView.js +++ b/chrome/chromeFiles/content/scholar/itemTreeView.js @@ -546,6 +546,41 @@ Scholar.ItemTreeView.prototype.rememberSelection = function() } } +//////////////////////////////////////////////////////////////////////////////// +/// +/// Command Controller: +/// for Select All, etc. +/// +//////////////////////////////////////////////////////////////////////////////// + +Scholar.ItemTreeCommandController = function(tree) +{ + this.tree = tree; +} + +Scholar.ItemTreeCommandController.prototype.supportsCommand = function(cmd) +{ + return (cmd == 'cmd_selectAll' || cmd == 'cmd_delete'); +} + +Scholar.ItemTreeCommandController.prototype.isCommandEnabled = function(cmd) +{ + return (cmd == 'cmd_selectAll' || (cmd == 'cmd_delete' && this.tree.view.selection.count > 0)); +} + +Scholar.ItemTreeCommandController.prototype.doCommand = function(cmd) +{ + if(cmd == 'cmd_selectAll') + this.tree.view.selection.selectAll(); + else if(cmd == 'cmd_delete') + ScholarPane.deleteSelectedItem(); +} + +Scholar.ItemTreeCommandController.prototype.onEvent = function(evt) +{ + +} + //////////////////////////////////////////////////////////////////////////////// /// /// Drag-and-drop functions: diff --git a/chrome/chromeFiles/content/scholar/overlay.js b/chrome/chromeFiles/content/scholar/overlay.js index 9836336ff6..066dfface7 100644 --- a/chrome/chromeFiles/content/scholar/overlay.js +++ b/chrome/chromeFiles/content/scholar/overlay.js @@ -5,7 +5,6 @@ var ScholarPane = new function() { var collectionsView; var itemsView; - var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService); //Privileged methods this.onLoad = onLoad; @@ -61,7 +60,12 @@ var ScholarPane = new function() //Initialize collections view collectionsView = new Scholar.CollectionTreeView(); - document.getElementById('collections-tree').view = collectionsView; + var collectionsTree = document.getElementById('collections-tree'); + collectionsTree.view = collectionsView; + collectionsTree.controllers.appendController(new Scholar.CollectionTreeCommandController(collectionsTree)); + + var itemsTree = document.getElementById('items-tree'); + itemsTree.controllers.appendController(new Scholar.ItemTreeCommandController(itemsTree)); //Create the add menu with each item type var addMenu = document.getElementById('tb-add').firstChild; diff --git a/chrome/chromeFiles/content/scholar/overlay.xul b/chrome/chromeFiles/content/scholar/overlay.xul index 99ed9c1a5c..f26a12b136 100644 --- a/chrome/chromeFiles/content/scholar/overlay.xul +++ b/chrome/chromeFiles/content/scholar/overlay.xul @@ -63,7 +63,7 @@ onselect="ScholarPane.onCollectionSelected();" seltype="single" ondragdrop="nsDragAndDrop.drop(event,ScholarPane.getCollectionsView())" ondraggesture="if (event.target.localName == 'treechildren') nsDragAndDrop.startDrag(event,ScholarPane.getCollectionsView());" - onkeypress="if(event.keyCode == event.DOM_VK_BACK_SPACE || event.keyCode == event.DOM_VK_DELETE){ ScholarPane.deleteSelectedCollection(); return false; }" + onkeypress="if(event.keyCode == event.DOM_VK_BACK_SPACE){ ScholarPane.deleteSelectedCollection(); return false; }" flex="1">