annotate content/collections.js @ 297:37187074a143

make unsubscribing work again
author Myk Melez <myk@mozilla.org>
date Mon, 29 Sep 2008 17:00:41 -0700
parents 26320193da70
children 328f40692bcf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
229
b324ba5e93f0 add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents: 225
diff changeset
1 /* ***** BEGIN LICENSE BLOCK *****
b324ba5e93f0 add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents: 225
diff changeset
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
b324ba5e93f0 add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents: 225
diff changeset
3 *
b324ba5e93f0 add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents: 225
diff changeset
4 * The contents of this file are subject to the Mozilla Public License Version
b324ba5e93f0 add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents: 225
diff changeset
5 * 1.1 (the "License"); you may not use this file except in compliance with
b324ba5e93f0 add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents: 225
diff changeset
6 * the License. You may obtain a copy of the License at
b324ba5e93f0 add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents: 225
diff changeset
7 * http://www.mozilla.org/MPL/
b324ba5e93f0 add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents: 225
diff changeset
8 *
b324ba5e93f0 add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents: 225
diff changeset
9 * Software distributed under the License is distributed on an "AS IS" basis,
b324ba5e93f0 add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents: 225
diff changeset
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
b324ba5e93f0 add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents: 225
diff changeset
11 * for the specific language governing rights and limitations under the
b324ba5e93f0 add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents: 225
diff changeset
12 * License.
b324ba5e93f0 add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents: 225
diff changeset
13 *
b324ba5e93f0 add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents: 225
diff changeset
14 * The Original Code is Snowl.
b324ba5e93f0 add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents: 225
diff changeset
15 *
b324ba5e93f0 add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents: 225
diff changeset
16 * The Initial Developer of the Original Code is Mozilla.
b324ba5e93f0 add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents: 225
diff changeset
17 * Portions created by the Initial Developer are Copyright (C) 2008
b324ba5e93f0 add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents: 225
diff changeset
18 * the Initial Developer. All Rights Reserved.
b324ba5e93f0 add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents: 225
diff changeset
19 *
b324ba5e93f0 add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents: 225
diff changeset
20 * Contributor(s):
b324ba5e93f0 add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents: 225
diff changeset
21 * Myk Melez <myk@mozilla.org>
b324ba5e93f0 add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents: 225
diff changeset
22 *
b324ba5e93f0 add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents: 225
diff changeset
23 * Alternatively, the contents of this file may be used under the terms of
b324ba5e93f0 add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents: 225
diff changeset
24 * either the GNU General Public License Version 2 or later (the "GPL"), or
b324ba5e93f0 add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents: 225
diff changeset
25 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
b324ba5e93f0 add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents: 225
diff changeset
26 * in which case the provisions of the GPL or the LGPL are applicable instead
b324ba5e93f0 add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents: 225
diff changeset
27 * of those above. If you wish to allow use of your version of this file only
b324ba5e93f0 add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents: 225
diff changeset
28 * under the terms of either the GPL or the LGPL, and not to allow others to
b324ba5e93f0 add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents: 225
diff changeset
29 * use your version of this file under the terms of the MPL, indicate your
b324ba5e93f0 add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents: 225
diff changeset
30 * decision by deleting the provisions above and replace them with the notice
b324ba5e93f0 add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents: 225
diff changeset
31 * and other provisions required by the GPL or the LGPL. If you do not delete
b324ba5e93f0 add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents: 225
diff changeset
32 * the provisions above, a recipient may use your version of this file under
b324ba5e93f0 add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents: 225
diff changeset
33 * the terms of any one of the MPL, the GPL or the LGPL.
b324ba5e93f0 add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents: 225
diff changeset
34 *
b324ba5e93f0 add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents: 225
diff changeset
35 * ***** END LICENSE BLOCK ***** */
b324ba5e93f0 add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents: 225
diff changeset
36
45
a3811857c5dc register the resource alias to the top-level directory rather than the modules directory for consistency with resource://gre/modules/ URLs and so we can use it to load resources from elsewhere in the extension later; this means converting chrome://snowl/module.js URLs into chrome://snowl/modules/module.js URLs
Myk Melez <myk@mozilla.org>
parents: 39
diff changeset
37 Cu.import("resource://snowl/modules/service.js");
a3811857c5dc register the resource alias to the top-level directory rather than the modules directory for consistency with resource://gre/modules/ URLs and so we can use it to load resources from elsewhere in the extension later; this means converting chrome://snowl/module.js URLs into chrome://snowl/modules/module.js URLs
Myk Melez <myk@mozilla.org>
parents: 39
diff changeset
38 Cu.import("resource://snowl/modules/datastore.js");
a3811857c5dc register the resource alias to the top-level directory rather than the modules directory for consistency with resource://gre/modules/ URLs and so we can use it to load resources from elsewhere in the extension later; this means converting chrome://snowl/module.js URLs into chrome://snowl/modules/module.js URLs
Myk Melez <myk@mozilla.org>
parents: 39
diff changeset
39 Cu.import("resource://snowl/modules/log4moz.js");
108
ec5e374be495 show favicons in the subscriptions sidebar
Myk Melez <myk@mozilla.org>
parents: 106
diff changeset
40 Cu.import("resource://snowl/modules/source.js");
106
2a08b4a82802 integrate OPML import into the sidebar
Myk Melez <myk@mozilla.org>
parents: 105
diff changeset
41 Cu.import("resource://snowl/modules/feed.js");
2a08b4a82802 integrate OPML import into the sidebar
Myk Melez <myk@mozilla.org>
parents: 105
diff changeset
42 Cu.import("resource://snowl/modules/URI.js");
165
91524ab2554c allow listing by person
Myk Melez <myk@mozilla.org>
parents: 138
diff changeset
43 Cu.import("resource://snowl/modules/identity.js");
169
d5cc6dfafc40 basic support for grouping in the collection object
Myk Melez <myk@mozilla.org>
parents: 167
diff changeset
44 Cu.import("resource://snowl/modules/collection.js");
275
5982695f4890 factor out OPML export code from the collections view
Myk Melez <myk@mozilla.org>
parents: 238
diff changeset
45 Cu.import("resource://snowl/modules/opml.js");
16
8efec269810d get rid of init.js and a bunch of unused code in snowl.js
Myk Melez <myk@mozilla.org>
parents: 12
diff changeset
46
194
bdb8643cbeab flatten the list of collections
Myk Melez <myk@mozilla.org>
parents: 187
diff changeset
47 // FIXME: make this configurable.
bdb8643cbeab flatten the list of collections
Myk Melez <myk@mozilla.org>
parents: 187
diff changeset
48 const SNOWL_COLLECTIONS_HIERARCHICAL = false;
bdb8643cbeab flatten the list of collections
Myk Melez <myk@mozilla.org>
parents: 187
diff changeset
49
187
dc76bd76b8bc make the collections view load into the river view even when query params have been altered
Myk Melez <myk@mozilla.org>
parents: 184
diff changeset
50 let SourcesView = {
21
df5025ed1a7b supress some log messages
Myk Melez <myk@mozilla.org>
parents: 16
diff changeset
51 _log: null,
df5025ed1a7b supress some log messages
Myk Melez <myk@mozilla.org>
parents: 16
diff changeset
52
10
64defcf896f1 update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents: 9
diff changeset
53 // Observer Service
64defcf896f1 update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents: 9
diff changeset
54 get _obsSvc() {
64defcf896f1 update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents: 9
diff changeset
55 let obsSvc = Cc["@mozilla.org/observer-service;1"].
64defcf896f1 update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents: 9
diff changeset
56 getService(Ci.nsIObserverService);
64defcf896f1 update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents: 9
diff changeset
57 delete this._obsSvc;
64defcf896f1 update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents: 9
diff changeset
58 this._obsSvc = obsSvc;
64defcf896f1 update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents: 9
diff changeset
59 return this._obsSvc;
64defcf896f1 update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents: 9
diff changeset
60 },
64defcf896f1 update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents: 9
diff changeset
61
8
87c6af76db52 add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff changeset
62 get _tree() {
87c6af76db52 add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff changeset
63 delete this._tree;
172
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
64 return this._tree = document.getElementById("sourcesView");
8
87c6af76db52 add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff changeset
65 },
87c6af76db52 add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff changeset
66
87c6af76db52 add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff changeset
67 get _children() {
87c6af76db52 add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff changeset
68 delete this._children;
172
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
69 return this._children = this._tree.getElementsByTagName("treechildren")[0];
8
87c6af76db52 add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff changeset
70 },
87c6af76db52 add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff changeset
71
106
2a08b4a82802 integrate OPML import into the sidebar
Myk Melez <myk@mozilla.org>
parents: 105
diff changeset
72
2a08b4a82802 integrate OPML import into the sidebar
Myk Melez <myk@mozilla.org>
parents: 105
diff changeset
73 //**************************************************************************//
2a08b4a82802 integrate OPML import into the sidebar
Myk Melez <myk@mozilla.org>
parents: 105
diff changeset
74 // Initialization & Destruction
2a08b4a82802 integrate OPML import into the sidebar
Myk Melez <myk@mozilla.org>
parents: 105
diff changeset
75
8
87c6af76db52 add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff changeset
76 init: function() {
21
df5025ed1a7b supress some log messages
Myk Melez <myk@mozilla.org>
parents: 16
diff changeset
77 this._log = Log4Moz.Service.getLogger("Snowl.Sidebar");
10
64defcf896f1 update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents: 9
diff changeset
78 this._obsSvc.addObserver(this, "sources:changed", true);
172
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
79 this._getCollections();
21
df5025ed1a7b supress some log messages
Myk Melez <myk@mozilla.org>
parents: 16
diff changeset
80 this._tree.view = this;
df5025ed1a7b supress some log messages
Myk Melez <myk@mozilla.org>
parents: 16
diff changeset
81
df5025ed1a7b supress some log messages
Myk Melez <myk@mozilla.org>
parents: 16
diff changeset
82 // Add a capturing click listener to the tree so we can find out if the user
df5025ed1a7b supress some log messages
Myk Melez <myk@mozilla.org>
parents: 16
diff changeset
83 // clicked on a row that is already selected (in which case we let them edit
172
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
84 // the collection name).
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
85 // FIXME: disable this for names that can't be changed.
21
df5025ed1a7b supress some log messages
Myk Melez <myk@mozilla.org>
parents: 16
diff changeset
86 this._tree.addEventListener("mousedown", function(aEvent) { SourcesView.onClick(aEvent) }, true);
212
cf89d5c676c0 persist collection and group in the URL, and delay loading content until the collections sidebar has loaded
Myk Melez <myk@mozilla.org>
parents: 211
diff changeset
87
276
53d67fb2a9dc make sure view has onCollectionsLoaded method before calling it
Myk Melez <myk@mozilla.org>
parents: 275
diff changeset
88 if (gMessageViewWindow.SnowlMessageView.onCollectionsLoaded)
53d67fb2a9dc make sure view has onCollectionsLoaded method before calling it
Myk Melez <myk@mozilla.org>
parents: 275
diff changeset
89 gMessageViewWindow.SnowlMessageView.onCollectionsLoaded();
21
df5025ed1a7b supress some log messages
Myk Melez <myk@mozilla.org>
parents: 16
diff changeset
90 },
df5025ed1a7b supress some log messages
Myk Melez <myk@mozilla.org>
parents: 16
diff changeset
91
df5025ed1a7b supress some log messages
Myk Melez <myk@mozilla.org>
parents: 16
diff changeset
92
df5025ed1a7b supress some log messages
Myk Melez <myk@mozilla.org>
parents: 16
diff changeset
93 //**************************************************************************//
df5025ed1a7b supress some log messages
Myk Melez <myk@mozilla.org>
parents: 16
diff changeset
94 // nsITreeView
df5025ed1a7b supress some log messages
Myk Melez <myk@mozilla.org>
parents: 16
diff changeset
95
172
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
96 selection: null,
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
97
108
ec5e374be495 show favicons in the subscriptions sidebar
Myk Melez <myk@mozilla.org>
parents: 106
diff changeset
98 get rowCount() {
172
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
99 return this._rows.length;
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
100 },
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
101
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
102 // FIXME: consolidate these two references.
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
103 _treebox: null,
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
104 setTree: function(treeBox) {
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
105 this._treeBox = treeBox;
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
106 },
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
107
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
108 getCellText : function(row, column) {
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
109 return this._rows[row].name;
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
110 },
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
111
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
112 isContainer: function(row) {
177
06a3197f71b1 make favicons work
Myk Melez <myk@mozilla.org>
parents: 176
diff changeset
113 //this._log.info("isContainer: " + (this._rows[row].groups ? true : false));
172
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
114 return (this._rows[row].groups ? true : false);
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
115 },
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
116 isContainerOpen: function(row) {
177
06a3197f71b1 make favicons work
Myk Melez <myk@mozilla.org>
parents: 176
diff changeset
117 //this._log.info("isContainerOpen: " + this._rows[row].isOpen);
172
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
118 return this._rows[row].isOpen;
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
119 },
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
120 isContainerEmpty: function(row) {
177
06a3197f71b1 make favicons work
Myk Melez <myk@mozilla.org>
parents: 176
diff changeset
121 //this._log.info("isContainerEmpty: " + row + " " + this._rows[row].groups.length + " " + (this._rows[row].groups.length == 0));
172
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
122 return (this._rows[row].groups.length == 0);
108
ec5e374be495 show favicons in the subscriptions sidebar
Myk Melez <myk@mozilla.org>
parents: 106
diff changeset
123 },
ec5e374be495 show favicons in the subscriptions sidebar
Myk Melez <myk@mozilla.org>
parents: 106
diff changeset
124
172
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
125 isSeparator: function(row) { return false },
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
126 isSorted: function() { return false },
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
127
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
128 // FIXME: make this return true for collection names that are editable,
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
129 // and then implement name editing on the new architecture.
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
130 isEditable: function(row, column) { return false },
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
131
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
132 getParentIndex: function(row) {
177
06a3197f71b1 make favicons work
Myk Melez <myk@mozilla.org>
parents: 176
diff changeset
133 //this._log.info("getParentIndex: " + row);
06a3197f71b1 make favicons work
Myk Melez <myk@mozilla.org>
parents: 176
diff changeset
134
179
ab9b528514e6 don't indent the All collection, and support more flexible hierarchy
Myk Melez <myk@mozilla.org>
parents: 178
diff changeset
135 let thisLevel = this.getLevel(row);
ab9b528514e6 don't indent the All collection, and support more flexible hierarchy
Myk Melez <myk@mozilla.org>
parents: 178
diff changeset
136
194
bdb8643cbeab flatten the list of collections
Myk Melez <myk@mozilla.org>
parents: 187
diff changeset
137 if (thisLevel == 0)
172
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
138 return -1;
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
139 for (let t = row - 1; t >= 0; t--)
179
ab9b528514e6 don't indent the All collection, and support more flexible hierarchy
Myk Melez <myk@mozilla.org>
parents: 178
diff changeset
140 if (this.getLevel(t) < thisLevel)
172
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
141 return t;
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
142
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
143 throw "getParentIndex: couldn't figure out parent index for row " + row;
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
144 },
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
145
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
146 getLevel: function(row) {
177
06a3197f71b1 make favicons work
Myk Melez <myk@mozilla.org>
parents: 176
diff changeset
147 //this._log.info("getLevel: " + row);
06a3197f71b1 make favicons work
Myk Melez <myk@mozilla.org>
parents: 176
diff changeset
148
194
bdb8643cbeab flatten the list of collections
Myk Melez <myk@mozilla.org>
parents: 187
diff changeset
149 if (!SNOWL_COLLECTIONS_HIERARCHICAL)
bdb8643cbeab flatten the list of collections
Myk Melez <myk@mozilla.org>
parents: 187
diff changeset
150 return 0;
bdb8643cbeab flatten the list of collections
Myk Melez <myk@mozilla.org>
parents: 187
diff changeset
151
179
ab9b528514e6 don't indent the All collection, and support more flexible hierarchy
Myk Melez <myk@mozilla.org>
parents: 178
diff changeset
152 return this._rows[row].level;
172
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
153 },
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
154
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
155 hasNextSibling: function(idx, after) {
177
06a3197f71b1 make favicons work
Myk Melez <myk@mozilla.org>
parents: 176
diff changeset
156 //this._log.info("hasNextSibling: " + idx + " " + after);
06a3197f71b1 make favicons work
Myk Melez <myk@mozilla.org>
parents: 176
diff changeset
157
172
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
158 let thisLevel = this.getLevel(idx);
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
159 for (let t = idx + 1; t < this._rows.length; t++) {
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
160 let nextLevel = this.getLevel(t);
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
161 if (nextLevel == thisLevel)
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
162 return true;
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
163 if (nextLevel < thisLevel)
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
164 return false;
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
165 }
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
166
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
167 return false;
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
168 },
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
169
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
170 getImageSrc: function(row, column) {
177
06a3197f71b1 make favicons work
Myk Melez <myk@mozilla.org>
parents: 176
diff changeset
171 if (column.id == "nameCol") {
211
9c5fdc76cb35 store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents: 202
diff changeset
172 let iconURL = this._rows[row].iconURL;
9c5fdc76cb35 store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents: 202
diff changeset
173 if (iconURL)
9c5fdc76cb35 store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents: 202
diff changeset
174 return iconURL.spec;
177
06a3197f71b1 make favicons work
Myk Melez <myk@mozilla.org>
parents: 176
diff changeset
175 }
06a3197f71b1 make favicons work
Myk Melez <myk@mozilla.org>
parents: 176
diff changeset
176
108
ec5e374be495 show favicons in the subscriptions sidebar
Myk Melez <myk@mozilla.org>
parents: 106
diff changeset
177 return null;
21
df5025ed1a7b supress some log messages
Myk Melez <myk@mozilla.org>
parents: 16
diff changeset
178 },
28
0d34d2108b49 use a custom view for the message pane
Myk Melez <myk@mozilla.org>
parents: 21
diff changeset
179
172
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
180 toggleOpenState: function(idx) {
177
06a3197f71b1 make favicons work
Myk Melez <myk@mozilla.org>
parents: 176
diff changeset
181 //this._log.info("toggleOpenState: " + idx);
06a3197f71b1 make favicons work
Myk Melez <myk@mozilla.org>
parents: 176
diff changeset
182
172
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
183 let item = this._rows[idx];
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
184 if (!item.groups)
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
185 return;
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
186
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
187 if (item.isOpen) {
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
188 item.isOpen = false;
28
0d34d2108b49 use a custom view for the message pane
Myk Melez <myk@mozilla.org>
parents: 21
diff changeset
189
172
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
190 let thisLevel = this.getLevel(idx);
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
191 let numToDelete = 0;
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
192 for (let t = idx + 1; t < this._rows.length; t++) {
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
193 if (this.getLevel(t) > thisLevel)
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
194 numToDelete++;
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
195 else
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
196 break;
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
197 }
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
198 if (numToDelete) {
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
199 this._rows.splice(idx + 1, numToDelete);
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
200 this._treeBox.rowCountChanged(idx + 1, -numToDelete);
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
201 }
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
202 }
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
203 else {
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
204 item.isOpen = true;
108
ec5e374be495 show favicons in the subscriptions sidebar
Myk Melez <myk@mozilla.org>
parents: 106
diff changeset
205
172
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
206 let groups = this._rows[idx].groups;
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
207 for (let i = 0; i < groups.length; i++)
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
208 this._rows.splice(idx + 1 + i, 0, groups[i]);
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
209 this._treeBox.rowCountChanged(idx + 1, groups.length);
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
210 }
108
ec5e374be495 show favicons in the subscriptions sidebar
Myk Melez <myk@mozilla.org>
parents: 106
diff changeset
211 },
ec5e374be495 show favicons in the subscriptions sidebar
Myk Melez <myk@mozilla.org>
parents: 106
diff changeset
212
195
1abed11b59f9 display icons for people
Myk Melez <myk@mozilla.org>
parents: 194
diff changeset
213 getRowProperties: function (row, properties) {},
1abed11b59f9 display icons for people
Myk Melez <myk@mozilla.org>
parents: 194
diff changeset
214 getCellProperties: function (row, column, properties) {},
1abed11b59f9 display icons for people
Myk Melez <myk@mozilla.org>
parents: 194
diff changeset
215 getColumnProperties: function(columnID, column, properties) {},
28
0d34d2108b49 use a custom view for the message pane
Myk Melez <myk@mozilla.org>
parents: 21
diff changeset
216
0d34d2108b49 use a custom view for the message pane
Myk Melez <myk@mozilla.org>
parents: 21
diff changeset
217 setCellText: function(aRow, aCol, aValue) {
75
877a7694445f update the sources table schema, changing the title column to name and differentiating between machine-processable and human-readable URIs
Myk Melez <myk@mozilla.org>
parents: 45
diff changeset
218 let statement = SnowlDatastore.createStatement("UPDATE sources SET name = :name WHERE id = :id");
172
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
219 statement.params.name = this._rows[aRow].name = aValue;
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
220 statement.params.id = this._rows[aRow].id;
21
df5025ed1a7b supress some log messages
Myk Melez <myk@mozilla.org>
parents: 16
diff changeset
221
df5025ed1a7b supress some log messages
Myk Melez <myk@mozilla.org>
parents: 16
diff changeset
222 try {
df5025ed1a7b supress some log messages
Myk Melez <myk@mozilla.org>
parents: 16
diff changeset
223 statement.execute();
df5025ed1a7b supress some log messages
Myk Melez <myk@mozilla.org>
parents: 16
diff changeset
224 }
df5025ed1a7b supress some log messages
Myk Melez <myk@mozilla.org>
parents: 16
diff changeset
225 finally {
df5025ed1a7b supress some log messages
Myk Melez <myk@mozilla.org>
parents: 16
diff changeset
226 statement.reset();
df5025ed1a7b supress some log messages
Myk Melez <myk@mozilla.org>
parents: 16
diff changeset
227 }
10
64defcf896f1 update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents: 9
diff changeset
228 },
64defcf896f1 update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents: 9
diff changeset
229
28
0d34d2108b49 use a custom view for the message pane
Myk Melez <myk@mozilla.org>
parents: 21
diff changeset
230
10
64defcf896f1 update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents: 9
diff changeset
231 //**************************************************************************//
21
df5025ed1a7b supress some log messages
Myk Melez <myk@mozilla.org>
parents: 16
diff changeset
232 // Misc XPCOM Interface Implementations
10
64defcf896f1 update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents: 9
diff changeset
233
64defcf896f1 update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents: 9
diff changeset
234 // nsISupports
64defcf896f1 update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents: 9
diff changeset
235 QueryInterface: function(aIID) {
64defcf896f1 update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents: 9
diff changeset
236 if (aIID.equals(Ci.nsIObserver) ||
64defcf896f1 update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents: 9
diff changeset
237 aIID.equals(Ci.nsISupportsWeakReference) ||
64defcf896f1 update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents: 9
diff changeset
238 aIID.equals(Ci.nsISupports))
64defcf896f1 update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents: 9
diff changeset
239 return this;
64defcf896f1 update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents: 9
diff changeset
240
64defcf896f1 update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents: 9
diff changeset
241 throw Cr.NS_ERROR_NO_INTERFACE;
64defcf896f1 update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents: 9
diff changeset
242 },
64defcf896f1 update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents: 9
diff changeset
243
64defcf896f1 update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents: 9
diff changeset
244 // nsIObserver
64defcf896f1 update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents: 9
diff changeset
245 observe: function(subject, topic, data) {
64defcf896f1 update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents: 9
diff changeset
246 switch (topic) {
64defcf896f1 update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents: 9
diff changeset
247 case "sources:changed":
172
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
248 this._getCollections();
105
cd3267665afd reinit the sidebar view when the number of rows changes
Myk Melez <myk@mozilla.org>
parents: 75
diff changeset
249 // Rebuild the view to reflect the new collection of messages.
cd3267665afd reinit the sidebar view when the number of rows changes
Myk Melez <myk@mozilla.org>
parents: 75
diff changeset
250 // Since the number of rows might have changed, we do this by reinitializing
cd3267665afd reinit the sidebar view when the number of rows changes
Myk Melez <myk@mozilla.org>
parents: 75
diff changeset
251 // the view instead of merely invalidating the box object (which doesn't
cd3267665afd reinit the sidebar view when the number of rows changes
Myk Melez <myk@mozilla.org>
parents: 75
diff changeset
252 // expect changes to the number of rows).
cd3267665afd reinit the sidebar view when the number of rows changes
Myk Melez <myk@mozilla.org>
parents: 75
diff changeset
253 this._tree.view = this;
10
64defcf896f1 update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents: 9
diff changeset
254 break;
64defcf896f1 update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents: 9
diff changeset
255 }
64defcf896f1 update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents: 9
diff changeset
256 },
64defcf896f1 update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents: 9
diff changeset
257
172
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
258 _collections: null,
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
259 _getCollections: function() {
178
1a27019af73e reimplement the 'All' collection on the new architecture
Myk Melez <myk@mozilla.org>
parents: 177
diff changeset
260 this._collections = [];
1a27019af73e reimplement the 'All' collection on the new architecture
Myk Melez <myk@mozilla.org>
parents: 177
diff changeset
261
211
9c5fdc76cb35 store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents: 202
diff changeset
262 let statement = SnowlDatastore.createStatement(
9c5fdc76cb35 store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents: 202
diff changeset
263 "SELECT id, name, iconURL, grouped, groupIDColumn, groupNameColumn, " +
9c5fdc76cb35 store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents: 202
diff changeset
264 "groupHomeURLColumn, groupIconURLColumn FROM collections ORDER BY orderKey"
9c5fdc76cb35 store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents: 202
diff changeset
265 );
9c5fdc76cb35 store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents: 202
diff changeset
266
9c5fdc76cb35 store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents: 202
diff changeset
267 statement.QueryInterface(Ci.mozIStorageStatementWrapper);
165
91524ab2554c allow listing by person
Myk Melez <myk@mozilla.org>
parents: 138
diff changeset
268
211
9c5fdc76cb35 store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents: 202
diff changeset
269 try {
9c5fdc76cb35 store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents: 202
diff changeset
270 while (statement.step()) {
9c5fdc76cb35 store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents: 202
diff changeset
271 this._collections.push(new SnowlCollection(statement.row.id,
9c5fdc76cb35 store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents: 202
diff changeset
272 statement.row.name,
9c5fdc76cb35 store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents: 202
diff changeset
273 URI.get(statement.row.iconURL),
9c5fdc76cb35 store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents: 202
diff changeset
274 null,
212
cf89d5c676c0 persist collection and group in the URL, and delay loading content until the collections sidebar has loaded
Myk Melez <myk@mozilla.org>
parents: 211
diff changeset
275 null,
211
9c5fdc76cb35 store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents: 202
diff changeset
276 statement.row.grouped ? true : false,
9c5fdc76cb35 store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents: 202
diff changeset
277 statement.row.groupIDColumn,
9c5fdc76cb35 store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents: 202
diff changeset
278 statement.row.groupNameColumn,
9c5fdc76cb35 store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents: 202
diff changeset
279 statement.row.groupHomeURLColumn,
9c5fdc76cb35 store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents: 202
diff changeset
280 statement.row.groupIconURLColumn));
9c5fdc76cb35 store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents: 202
diff changeset
281 }
175
5409a8759186 collection object rearch: encapsulate grouping info into grouping object
Myk Melez <myk@mozilla.org>
parents: 174
diff changeset
282 }
211
9c5fdc76cb35 store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents: 202
diff changeset
283 finally {
9c5fdc76cb35 store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents: 202
diff changeset
284 statement.reset();
180
33e517403dc8 add the people view
Myk Melez <myk@mozilla.org>
parents: 179
diff changeset
285 }
33e517403dc8 add the people view
Myk Melez <myk@mozilla.org>
parents: 179
diff changeset
286
172
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
287 // Build the list of rows in the tree. By default, all containers
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
288 // are closed, so this is the same as the list of collections, although
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
289 // in the future we might persist and restore the open state.
3ec4ba145105 support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents: 171
diff changeset
290 // XXX Should this work be in a separate function?
194
bdb8643cbeab flatten the list of collections
Myk Melez <myk@mozilla.org>
parents: 187
diff changeset
291 if (SNOWL_COLLECTIONS_HIERARCHICAL) {
bdb8643cbeab flatten the list of collections
Myk Melez <myk@mozilla.org>
parents: 187
diff changeset
292 this._rows = [collection for each (collection in this._collections)];
bdb8643cbeab flatten the list of collections
Myk Melez <myk@mozilla.org>
parents: 187
diff changeset
293 }
bdb8643cbeab flatten the list of collections
Myk Melez <myk@mozilla.org>
parents: 187
diff changeset
294 else {
bdb8643cbeab flatten the list of collections
Myk Melez <myk@mozilla.org>
parents: 187
diff changeset
295 this._rows = [];
bdb8643cbeab flatten the list of collections
Myk Melez <myk@mozilla.org>
parents: 187
diff changeset
296 for each (let collection in this._collections) {
211
9c5fdc76cb35 store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents: 202
diff changeset
297 if (collection.grouped)
194
bdb8643cbeab flatten the list of collections
Myk Melez <myk@mozilla.org>
parents: 187
diff changeset
298 for each (let group in collection.groups)
bdb8643cbeab flatten the list of collections
Myk Melez <myk@mozilla.org>
parents: 187
diff changeset
299 this._rows.push(group);
bdb8643cbeab flatten the list of collections
Myk Melez <myk@mozilla.org>
parents: 187
diff changeset
300 else
bdb8643cbeab flatten the list of collections
Myk Melez <myk@mozilla.org>
parents: 187
diff changeset
301 this._rows.push(collection);
bdb8643cbeab flatten the list of collections
Myk Melez <myk@mozilla.org>
parents: 187
diff changeset
302 }
bdb8643cbeab flatten the list of collections
Myk Melez <myk@mozilla.org>
parents: 187
diff changeset
303 }
21
df5025ed1a7b supress some log messages
Myk Melez <myk@mozilla.org>
parents: 16
diff changeset
304 },
df5025ed1a7b supress some log messages
Myk Melez <myk@mozilla.org>
parents: 16
diff changeset
305
8
87c6af76db52 add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff changeset
306 onSelect: function(aEvent) {
87c6af76db52 add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff changeset
307 if (this._tree.currentIndex == -1)
87c6af76db52 add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff changeset
308 return;
173
4d59aa183d57 get loading of a group into the list view working
Myk Melez <myk@mozilla.org>
parents: 172
diff changeset
309
4d59aa183d57 get loading of a group into the list view working
Myk Melez <myk@mozilla.org>
parents: 172
diff changeset
310 let collection = this._rows[this._tree.currentIndex];
184
e005621994a3 basic integration of collections view into river view, except that collection selections don't persist
Myk Melez <myk@mozilla.org>
parents: 183
diff changeset
311 gMessageViewWindow.SnowlMessageView.setCollection(collection);
9
d8abd85fc94d implement basic subscribe and unsubscribe
Myk Melez <myk@mozilla.org>
parents: 8
diff changeset
312 },
d8abd85fc94d implement basic subscribe and unsubscribe
Myk Melez <myk@mozilla.org>
parents: 8
diff changeset
313
21
df5025ed1a7b supress some log messages
Myk Melez <myk@mozilla.org>
parents: 16
diff changeset
314 onClick: function(aEvent) {
df5025ed1a7b supress some log messages
Myk Melez <myk@mozilla.org>
parents: 16
diff changeset
315 this._log.info("on click");
df5025ed1a7b supress some log messages
Myk Melez <myk@mozilla.org>
parents: 16
diff changeset
316 //this._log.info(Log4Moz.enumerateProperties(aEvent).join("\n"));
df5025ed1a7b supress some log messages
Myk Melez <myk@mozilla.org>
parents: 16
diff changeset
317 //this._log.info(aEvent.target.nodeName);
df5025ed1a7b supress some log messages
Myk Melez <myk@mozilla.org>
parents: 16
diff changeset
318
df5025ed1a7b supress some log messages
Myk Melez <myk@mozilla.org>
parents: 16
diff changeset
319 let row = {}, col = {}, child = {};
df5025ed1a7b supress some log messages
Myk Melez <myk@mozilla.org>
parents: 16
diff changeset
320 this._tree.treeBoxObject.getCellAt(aEvent.clientX, aEvent.clientY, row, col, child);
df5025ed1a7b supress some log messages
Myk Melez <myk@mozilla.org>
parents: 16
diff changeset
321 if (this._tree.view.selection.isSelected(row.value))
df5025ed1a7b supress some log messages
Myk Melez <myk@mozilla.org>
parents: 16
diff changeset
322 this._log.info(row.value + " is selected");
df5025ed1a7b supress some log messages
Myk Melez <myk@mozilla.org>
parents: 16
diff changeset
323 else
df5025ed1a7b supress some log messages
Myk Melez <myk@mozilla.org>
parents: 16
diff changeset
324 this._log.info(row.value + " is not selected");
297
37187074a143 make unsubscribing work again
Myk Melez <myk@mozilla.org>
parents: 294
diff changeset
325 },
37187074a143 make unsubscribing work again
Myk Melez <myk@mozilla.org>
parents: 294
diff changeset
326
37187074a143 make unsubscribing work again
Myk Melez <myk@mozilla.org>
parents: 294
diff changeset
327 unsubscribe: function() {
37187074a143 make unsubscribing work again
Myk Melez <myk@mozilla.org>
parents: 294
diff changeset
328 let collection = this._rows[this._tree.currentIndex];
37187074a143 make unsubscribing work again
Myk Melez <myk@mozilla.org>
parents: 294
diff changeset
329
37187074a143 make unsubscribing work again
Myk Melez <myk@mozilla.org>
parents: 294
diff changeset
330 if (!collection.parent || collection.parent.groupIDColumn != "sources.id")
37187074a143 make unsubscribing work again
Myk Melez <myk@mozilla.org>
parents: 294
diff changeset
331 return;
37187074a143 make unsubscribing work again
Myk Melez <myk@mozilla.org>
parents: 294
diff changeset
332
37187074a143 make unsubscribing work again
Myk Melez <myk@mozilla.org>
parents: 294
diff changeset
333 let sourceID = this._rows[this._tree.currentIndex].groupID;
37187074a143 make unsubscribing work again
Myk Melez <myk@mozilla.org>
parents: 294
diff changeset
334
37187074a143 make unsubscribing work again
Myk Melez <myk@mozilla.org>
parents: 294
diff changeset
335 SnowlDatastore.dbConnection.beginTransaction();
37187074a143 make unsubscribing work again
Myk Melez <myk@mozilla.org>
parents: 294
diff changeset
336 try {
37187074a143 make unsubscribing work again
Myk Melez <myk@mozilla.org>
parents: 294
diff changeset
337 SnowlDatastore.dbConnection.executeSimpleSQL("DELETE FROM metadata WHERE messageID IN (SELECT id FROM messages WHERE sourceID = " + sourceID + ")");
37187074a143 make unsubscribing work again
Myk Melez <myk@mozilla.org>
parents: 294
diff changeset
338 SnowlDatastore.dbConnection.executeSimpleSQL("DELETE FROM parts WHERE messageID IN (SELECT id FROM messages WHERE sourceID = " + sourceID + ")");
37187074a143 make unsubscribing work again
Myk Melez <myk@mozilla.org>
parents: 294
diff changeset
339 SnowlDatastore.dbConnection.executeSimpleSQL("DELETE FROM messages WHERE sourceID = " + sourceID);
37187074a143 make unsubscribing work again
Myk Melez <myk@mozilla.org>
parents: 294
diff changeset
340 SnowlDatastore.dbConnection.executeSimpleSQL("DELETE FROM sources WHERE id = " + sourceID);
37187074a143 make unsubscribing work again
Myk Melez <myk@mozilla.org>
parents: 294
diff changeset
341 SnowlDatastore.dbConnection.commitTransaction();
37187074a143 make unsubscribing work again
Myk Melez <myk@mozilla.org>
parents: 294
diff changeset
342 }
37187074a143 make unsubscribing work again
Myk Melez <myk@mozilla.org>
parents: 294
diff changeset
343 catch(ex) {
37187074a143 make unsubscribing work again
Myk Melez <myk@mozilla.org>
parents: 294
diff changeset
344 SnowlDatastore.dbConnection.rollbackTransaction();
37187074a143 make unsubscribing work again
Myk Melez <myk@mozilla.org>
parents: 294
diff changeset
345 throw ex;
37187074a143 make unsubscribing work again
Myk Melez <myk@mozilla.org>
parents: 294
diff changeset
346 }
37187074a143 make unsubscribing work again
Myk Melez <myk@mozilla.org>
parents: 294
diff changeset
347
37187074a143 make unsubscribing work again
Myk Melez <myk@mozilla.org>
parents: 294
diff changeset
348 this._obsSvc.notifyObservers(null, "sources:changed", null);
37187074a143 make unsubscribing work again
Myk Melez <myk@mozilla.org>
parents: 294
diff changeset
349 this._obsSvc.notifyObservers(null, "messages:changed", null);
8
87c6af76db52 add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff changeset
350 }
87c6af76db52 add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff changeset
351
87c6af76db52 add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff changeset
352 };
87c6af76db52 add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff changeset
353
187
dc76bd76b8bc make the collections view load into the river view even when query params have been altered
Myk Melez <myk@mozilla.org>
parents: 184
diff changeset
354 // We can't listen for load and initialize then because load has already
dc76bd76b8bc make the collections view load into the river view even when query params have been altered
Myk Melez <myk@mozilla.org>
parents: 184
diff changeset
355 // happened when we get overlaid onto the river view, so we just set a timeout
dc76bd76b8bc make the collections view load into the river view even when query params have been altered
Myk Melez <myk@mozilla.org>
parents: 184
diff changeset
356 // by which time we hope the overlay has been loaded enough for this to work.
dc76bd76b8bc make the collections view load into the river view even when query params have been altered
Myk Melez <myk@mozilla.org>
parents: 184
diff changeset
357 // FIXME: figure out a better solution here. In theory we should be able
dc76bd76b8bc make the collections view load into the river view even when query params have been altered
Myk Melez <myk@mozilla.org>
parents: 184
diff changeset
358 // to make the river view observe xul-overlay-merged and then initialize us,
dc76bd76b8bc make the collections view load into the river view even when query params have been altered
Myk Melez <myk@mozilla.org>
parents: 184
diff changeset
359 // but that doesn't work because of bug 392515.
dc76bd76b8bc make the collections view load into the river view even when query params have been altered
Myk Melez <myk@mozilla.org>
parents: 184
diff changeset
360 window.setTimeout(function() { SourcesView.init() }, 100);