diff --git a/chrome/chromeFiles/content/scholar/itemPane.xul b/chrome/chromeFiles/content/scholar/itemPane.xul
index 2384ba33d..662460b27 100644
--- a/chrome/chromeFiles/content/scholar/itemPane.xul
+++ b/chrome/chromeFiles/content/scholar/itemPane.xul
@@ -39,10 +39,10 @@
diff --git a/chrome/chromeFiles/content/scholar/itemTreeView.js b/chrome/chromeFiles/content/scholar/itemTreeView.js
index c49d138fd..0cfa33dc0 100644
--- a/chrome/chromeFiles/content/scholar/itemTreeView.js
+++ b/chrome/chromeFiles/content/scholar/itemTreeView.js
@@ -141,8 +141,7 @@ Scholar.ItemTreeView.prototype.notify = function(action, type, ids)
if(action == 'add')
{
- this.selection.select(this._itemRowMap[item.getID()]);
- this._treebox.ensureRowIsVisible(this._itemRowMap[item.getID()]);
+ this.selectItem(this._itemRowMap[item.getID()]);
}
else
{
@@ -415,10 +414,27 @@ Scholar.ItemTreeView.prototype.sort = function()
///
////////////////////////////////////////////////////////////////////////////////
+/*
+ * Select an item
+ */
+Scholar.ItemTreeView.prototype.selectItem = function(id)
+{
+ var item = Scholar.Items.get(id);
+ var row = this._itemRowMap[item.getID()];
+ if(row == null)
+ {
+ this.toggleOpenState(this._itemRowMap[item.getSource()]); //opens the parent of the item
+ row = this._itemRowMap[item.getID()];
+ }
+
+ this.selection.select(row);
+ this._treebox.ensureRowIsVisible(row);
+}
+
/*
* Delete the selection
*/
-Scholar.ItemTreeView.prototype.deleteSelection = function()
+Scholar.ItemTreeView.prototype.deleteSelection = function(eraseChildren)
{
if(this.selection.count == 0)
return;
@@ -445,7 +461,7 @@ Scholar.ItemTreeView.prototype.deleteSelection = function()
for (var i=0; i 0 && confirm(Scholar.getString('pane.items.delete')))
- itemsView.deleteSelection();
+ if(itemsView && itemsView.selection.count > 0)
+ {
+ var eraseChildren = {};
+ var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Components.interfaces.nsIPromptService);
+
+ if(promptService.confirmCheck(window, 'Delete Item', Scholar.getString('pane.items.delete'), 'Erase attached notes and files', eraseChildren))
+ itemsView.deleteSelection(eraseChildren.value);
+ }
}
function deleteSelectedCollection()
@@ -257,6 +269,28 @@ var ScholarPane = new function()
return itemsView;
}
+ function selectItem(id)
+ {
+ if(itemsView)
+ {
+ if(!itemsView._itemGroup.isLibrary())
+ {
+ //select the Library if the item is not in the current collection
+
+ var item = Scholar.Items.get(id);
+ var collectionID = itemsView._itemGroup.ref.getID();
+ if(!item.isRegularItem())
+ {
+ if(!Scholar.Items.get(item.getSource()).inCollection(collectionID))
+ collectionsView.selection.select(0);
+ }
+ else if(!item.inCollection(collectionID))
+ collectionsView.selection.select(0);
+ }
+ itemsView.selectItem(id);
+ }
+ }
+
function getSelectedCollection()
{
if(collectionsView.selection.count > 0 && collectionsView.selection.currentIndex != -1)
@@ -358,19 +392,35 @@ var ScholarPane = new function()
if(fp.show() == nsIFilePicker.returnOK)
{
+ var fileID;
if(link)
- Scholar.Files.linkFromFile(fp.file, id);
+ fileID = Scholar.Files.linkFromFile(fp.file, id);
else
- Scholar.Files.importFromFile(fp.file, id);
+ fileID = Scholar.Files.importFromFile(fp.file, id);
+
+ if(fileID && !id)
+ {
+ var c = getSelectedCollection();
+ if(c)
+ c.addItem(fileID);
+ }
}
}
function addFileFromPage(link, id)
{
+ var fileID;
if(link)
- Scholar.Files.linkFromDocument(window.content.document, id);
+ fileID = Scholar.Files.linkFromDocument(window.content.document, id);
else
- Scholar.Files.importFromDocument(window.content.document, id);
+ fileID = Scholar.Files.importFromDocument(window.content.document, id);
+
+ if(fileID && !id)
+ {
+ var c = getSelectedCollection();
+ if(c)
+ c.addItem(fileID);
+ }
}
}
diff --git a/chrome/chromeFiles/content/scholar/overlay.xul b/chrome/chromeFiles/content/scholar/overlay.xul
index 58764ede5..77b8d6c5a 100644
--- a/chrome/chromeFiles/content/scholar/overlay.xul
+++ b/chrome/chromeFiles/content/scholar/overlay.xul
@@ -180,7 +180,7 @@
-
+