www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 0632cbf5e406314baad7d29e75c59597cb974be9
parent 426b839e5f898c8b447cba973e6a8a49f22f7c26
Author: David Norton <david@nortoncrew.com>
Date:   Mon, 31 Jul 2006 19:14:06 +0000

Closes #91, Add dialog to delete child notes when a source is deleted
Closes #146, ScholarPane.selectItem(id)
Closes #147, "Edit in a Separate Window" on a note should select the note's parent item.
Addresses #143, Scholar toolbar button to save current page as an independent file in the selected project.
 - Standalone Files are now added to the current Project.
Files added to an item are now actually attached to the item.

Diffstat:
Mchrome/chromeFiles/content/scholar/itemPane.xul | 8++++----
Mchrome/chromeFiles/content/scholar/itemTreeView.js | 24++++++++++++++++++++----
Mchrome/chromeFiles/content/scholar/overlay.js | 62++++++++++++++++++++++++++++++++++++++++++++++++++++++++------
Mchrome/chromeFiles/content/scholar/overlay.xul | 2+-
4 files changed, 81 insertions(+), 15 deletions(-)

diff --git a/chrome/chromeFiles/content/scholar/itemPane.xul b/chrome/chromeFiles/content/scholar/itemPane.xul @@ -39,10 +39,10 @@ <label id="editpane-files-label"/> <button id="tb-item-files-add" type="menu" label="Add"> <menupopup> - <menuitem class="menuitem-iconic" id="tb-item-files-file" label="Add File..." oncommand="ScholarPane.addFileFromDialog();"/> - <menuitem class="menuitem-iconic" id="tb-item-files-link" label="Add Linked File..." oncommand="ScholarPane.addFileFromDialog(true);"/> - <menuitem class="menuitem-iconic" id="tb-item-files-snapshot" label="Snapshot Current Page" oncommand="ScholarPane.addFileFromPage();"/> - <menuitem class="menuitem-iconic" id="tb-item-files-web-link" label="Link to Current Page" oncommand="ScholarPane.addFileFromPage(true);"/> + <menuitem class="menuitem-iconic" id="tb-item-files-file" label="Add File..." oncommand="ScholarItemPane.addFileFromDialog();"/> + <menuitem class="menuitem-iconic" id="tb-item-files-link" label="Add Linked File..." oncommand="ScholarItemPane.addFileFromDialog(true);"/> + <menuitem class="menuitem-iconic" id="tb-item-files-snapshot" label="Snapshot Current Page" oncommand="ScholarItemPane.addFileFromPage();"/> + <menuitem class="menuitem-iconic" id="tb-item-files-web-link" label="Link to Current Page" oncommand="ScholarItemPane.addFileFromPage(true);"/> </menupopup> </button> </hbox> diff --git 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 { @@ -416,9 +415,26 @@ 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<items.length; i++) { if(this._itemGroup.isLibrary() || !items[i].isRegularItem()) //erase item from DB - items[i].ref.erase(); + items[i].ref.erase(eraseChildren); else if(this._itemGroup.isCollection()) this._itemGroup.ref.removeItem(items[i].ref.getID()); } diff --git a/chrome/chromeFiles/content/scholar/overlay.js b/chrome/chromeFiles/content/scholar/overlay.js @@ -21,6 +21,7 @@ var ScholarPane = new function() this.search = search; this.getCollectionsView = getCollectionsView; this.getItemsView = getItemsView; + this.selectItem = selectItem; this.getSelectedCollection = getSelectedCollection; this.getSelectedItems = getSelectedItems; this.buildCollectionContextMenu = buildCollectionContextMenu; @@ -180,6 +181,10 @@ var ScholarPane = new function() noteEditor.item = null; noteEditor.note = item.ref; document.getElementById('scholar-view-note').lastChild.setAttribute('noteID',item.ref.getID()); + if(item.ref.getSource() != null) + document.getElementById('scholar-view-note').lastChild.setAttribute('sourceID',item.ref.getSource()); + else + document.getElementById('scholar-view-note').lastChild.removeAttribute('sourceID'); document.getElementById('item-pane').selectedIndex = 2; } else if(item.isFile()) @@ -210,8 +215,15 @@ var ScholarPane = new function() function deleteSelectedItem() { - if(itemsView && itemsView.selection.count > 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 @@ -180,7 +180,7 @@ <deck id="scholar-view-item" flex="1"/> <vbox id="scholar-view-note" flex="1"> <noteeditor id="scholar-note-editor" flex="1"/> - <button label="Edit in a separate window" oncommand="ScholarPane.openNoteWindow(this.getAttribute('noteID'));"/> + <button label="Edit in a separate window" oncommand="ScholarPane.openNoteWindow(this.getAttribute('noteID')); if(this.hasAttribute('sourceID')) ScholarPane.selectItem(this.getAttribute('sourceID'));"/> </vbox> <vbox id="scholar-view-file" flex="1"> <label id="scholar-file-label"/>