commit 81a980e4db58fa0f4de4d79c949b6c304a946740
parent a663966c4f3cd1bc0ca34e99f9adadf2ed2ceeaa
Author: David Norton <david@nortoncrew.com>
Date: Fri, 28 Jul 2006 13:28:50 +0000
Fixes Select All on Windows. But more importantly, uses the correct command structure for Select All, Delete, and provides the structure for future commands.
Diffstat:
4 files changed, 76 insertions(+), 5 deletions(-)
diff --git a/chrome/chromeFiles/content/scholar/collectionTreeView.js b/chrome/chromeFiles/content/scholar/collectionTreeView.js
@@ -325,6 +325,39 @@ Scholar.CollectionTreeView.prototype._refreshHashMap = function()
////////////////////////////////////////////////////////////////////////////////
///
+/// 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)
+{
+
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
/// Drag-and-drop functions:
/// canDrop() and drop() are for nsITreeView
/// onDragStart(), getSupportedFlavours(), and onDrop() for nsDragAndDrop.js + nsTransferable.js
diff --git a/chrome/chromeFiles/content/scholar/itemTreeView.js b/chrome/chromeFiles/content/scholar/itemTreeView.js
@@ -548,6 +548,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:
/// for nsDragAndDrop.js + nsTransferable.js
///
diff --git 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
@@ -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">
<treecols>
<treecol
@@ -99,12 +99,11 @@
</hbox>
<tree
id="items-tree" context="scholar-itemmenu"
- enableColumnDrag="true" onkeypress="if(event.keyCode == event.DOM_VK_BACK_SPACE || event.keyCode == event.DOM_VK_DELETE){ ScholarPane.deleteSelectedItem(); return false; } if(event.charCode == 97) if(event.metaKey){ this.view.selection.selectAll(); return false;}"
+ enableColumnDrag="true" onkeypress="if(event.keyCode == event.DOM_VK_BACK_SPACE){ ScholarPane.deleteSelectedItem(); return false; }"
onselect="ScholarPane.itemSelected();"
ondraggesture="if (event.target.localName == 'treechildren') nsDragAndDrop.startDrag(event,ScholarPane.getItemsView());"
ondragover="nsDragAndDrop.dragOver(event,ScholarPane.getItemsView())"
ondragdrop="nsDragAndDrop.drop(event,ScholarPane.getItemsView())"
- ondblclick="document.getElementById('scholar-view-splitter').setAttribute('state','open');"
flex="1">
<treecols>
<treecol