Fixes Select All on Windows. But more importantly, uses the correct command structure for Select All, Delete, and provides the structure for future commands.
This commit is contained in:
parent
a663966c4f
commit
81a980e4db
4 changed files with 76 additions and 5 deletions
|
@ -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)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue