OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 | 92 |
93 this._model = model; | 93 this._model = model; |
94 this._databaseId = databaseId; | 94 this._databaseId = databaseId; |
95 this._isIndex = !!index; | 95 this._isIndex = !!index; |
96 | 96 |
97 this.element.classList.add('indexed-db-data-view'); | 97 this.element.classList.add('indexed-db-data-view'); |
98 | 98 |
99 this._createEditorToolbar(); | 99 this._createEditorToolbar(); |
100 | 100 |
101 this._refreshButton = new UI.ToolbarButton(Common.UIString('Refresh'), 'larg
eicon-refresh'); | 101 this._refreshButton = new UI.ToolbarButton(Common.UIString('Refresh'), 'larg
eicon-refresh'); |
102 this._refreshButton.addEventListener(UI.ToolbarButton.Events.Click, this._re
freshButtonClicked, this); | 102 this._refreshButton.addEventListener('click', this._refreshButtonClicked, th
is); |
103 | 103 |
104 this._clearButton = new UI.ToolbarButton(Common.UIString('Clear object store
'), 'largeicon-clear'); | 104 this._clearButton = new UI.ToolbarButton(Common.UIString('Clear object store
'), 'largeicon-clear'); |
105 this._clearButton.addEventListener(UI.ToolbarButton.Events.Click, this._clea
rButtonClicked, this); | 105 this._clearButton.addEventListener('click', this._clearButtonClicked, this); |
106 | 106 |
107 this._pageSize = 50; | 107 this._pageSize = 50; |
108 this._skipCount = 0; | 108 this._skipCount = 0; |
109 | 109 |
110 this.update(objectStore, index); | 110 this.update(objectStore, index); |
111 this._entries = []; | 111 this._entries = []; |
112 } | 112 } |
113 | 113 |
114 /** | 114 /** |
115 * @return {!UI.DataGrid} | 115 * @return {!UI.DataGrid} |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 var keyPathSpan = keyPathStringFragment.createChild('span', 'source-code ind
exed-db-key-path'); | 172 var keyPathSpan = keyPathStringFragment.createChild('span', 'source-code ind
exed-db-key-path'); |
173 keyPathSpan.textContent = keyPathString; | 173 keyPathSpan.textContent = keyPathString; |
174 keyPathStringFragment.createTextChild('"'); | 174 keyPathStringFragment.createTextChild('"'); |
175 return keyPathStringFragment; | 175 return keyPathStringFragment; |
176 } | 176 } |
177 | 177 |
178 _createEditorToolbar() { | 178 _createEditorToolbar() { |
179 var editorToolbar = new UI.Toolbar('data-view-toolbar', this.element); | 179 var editorToolbar = new UI.Toolbar('data-view-toolbar', this.element); |
180 | 180 |
181 this._pageBackButton = new UI.ToolbarButton(Common.UIString('Show previous p
age'), 'largeicon-play-back'); | 181 this._pageBackButton = new UI.ToolbarButton(Common.UIString('Show previous p
age'), 'largeicon-play-back'); |
182 this._pageBackButton.addEventListener(UI.ToolbarButton.Events.Click, this._p
ageBackButtonClicked, this); | 182 this._pageBackButton.addEventListener('click', this._pageBackButtonClicked,
this); |
183 editorToolbar.appendToolbarItem(this._pageBackButton); | 183 editorToolbar.appendToolbarItem(this._pageBackButton); |
184 | 184 |
185 this._pageForwardButton = new UI.ToolbarButton(Common.UIString('Show next pa
ge'), 'largeicon-play'); | 185 this._pageForwardButton = new UI.ToolbarButton(Common.UIString('Show next pa
ge'), 'largeicon-play'); |
186 this._pageForwardButton.setEnabled(false); | 186 this._pageForwardButton.setEnabled(false); |
187 this._pageForwardButton.addEventListener(UI.ToolbarButton.Events.Click, this
._pageForwardButtonClicked, this); | 187 this._pageForwardButton.addEventListener('click', this._pageForwardButtonCli
cked, this); |
188 editorToolbar.appendToolbarItem(this._pageForwardButton); | 188 editorToolbar.appendToolbarItem(this._pageForwardButton); |
189 | 189 |
190 this._keyInputElement = editorToolbar.element.createChild('input', 'key-inpu
t'); | 190 this._keyInputElement = editorToolbar.element.createChild('input', 'key-inpu
t'); |
191 this._keyInputElement.placeholder = Common.UIString('Start from key'); | 191 this._keyInputElement.placeholder = Common.UIString('Start from key'); |
192 this._keyInputElement.addEventListener('paste', this._keyInputChanged.bind(t
his), false); | 192 this._keyInputElement.addEventListener('paste', this._keyInputChanged.bind(t
his), false); |
193 this._keyInputElement.addEventListener('cut', this._keyInputChanged.bind(thi
s), false); | 193 this._keyInputElement.addEventListener('cut', this._keyInputChanged.bind(thi
s), false); |
194 this._keyInputElement.addEventListener('keypress', this._keyInputChanged.bin
d(this), false); | 194 this._keyInputElement.addEventListener('keypress', this._keyInputChanged.bin
d(this), false); |
195 this._keyInputElement.addEventListener('keydown', this._keyInputChanged.bind
(this), false); | 195 this._keyInputElement.addEventListener('keydown', this._keyInputChanged.bind
(this), false); |
196 } | 196 } |
197 | 197 |
198 /** | 198 _pageBackButtonClicked() { |
199 * @param {!Common.Event} event | |
200 */ | |
201 _pageBackButtonClicked(event) { | |
202 this._skipCount = Math.max(0, this._skipCount - this._pageSize); | 199 this._skipCount = Math.max(0, this._skipCount - this._pageSize); |
203 this._updateData(false); | 200 this._updateData(false); |
204 } | 201 } |
205 | 202 |
206 /** | 203 _pageForwardButtonClicked() { |
207 * @param {!Common.Event} event | |
208 */ | |
209 _pageForwardButtonClicked(event) { | |
210 this._skipCount = this._skipCount + this._pageSize; | 204 this._skipCount = this._skipCount + this._pageSize; |
211 this._updateData(false); | 205 this._updateData(false); |
212 } | 206 } |
213 | 207 |
214 _keyInputChanged() { | 208 _keyInputChanged() { |
215 window.setTimeout(this._updateData.bind(this, false), 0); | 209 window.setTimeout(this._updateData.bind(this, false), 0); |
216 } | 210 } |
217 | 211 |
218 /** | 212 /** |
219 * @param {!Resources.IndexedDBModel.ObjectStore} objectStore | 213 * @param {!Resources.IndexedDBModel.ObjectStore} objectStore |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 if (this._isIndex) { | 288 if (this._isIndex) { |
295 this._model.loadIndexData( | 289 this._model.loadIndexData( |
296 this._databaseId, this._objectStore.name, this._index.name, idbKeyRang
e, skipCount, pageSize, | 290 this._databaseId, this._objectStore.name, this._index.name, idbKeyRang
e, skipCount, pageSize, |
297 callback.bind(this)); | 291 callback.bind(this)); |
298 } else { | 292 } else { |
299 this._model.loadObjectStoreData( | 293 this._model.loadObjectStoreData( |
300 this._databaseId, this._objectStore.name, idbKeyRange, skipCount, page
Size, callback.bind(this)); | 294 this._databaseId, this._objectStore.name, idbKeyRange, skipCount, page
Size, callback.bind(this)); |
301 } | 295 } |
302 } | 296 } |
303 | 297 |
304 /** | |
305 * @param {!Common.Event} event | |
306 */ | |
307 _refreshButtonClicked(event) { | 298 _refreshButtonClicked(event) { |
308 this._updateData(true); | 299 this._updateData(true); |
309 } | 300 } |
310 | 301 |
311 /** | |
312 * @param {!Common.Event} event | |
313 */ | |
314 _clearButtonClicked(event) { | 302 _clearButtonClicked(event) { |
315 /** | 303 /** |
316 * @this {Resources.IDBDataView} | 304 * @this {Resources.IDBDataView} |
317 */ | 305 */ |
318 function cleared() { | 306 function cleared() { |
319 this._clearButton.setEnabled(true); | 307 this._clearButton.setEnabled(true); |
320 this._updateData(true); | 308 this._updateData(true); |
321 } | 309 } |
322 this._clearButton.setEnabled(false); | 310 this._clearButton.setEnabled(false); |
323 this._model.clearObjectStore(this._databaseId, this._objectStore.name, clear
ed.bind(this)); | 311 this._model.clearObjectStore(this._databaseId, this._objectStore.name, clear
ed.bind(this)); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 cell.removeChildren(); | 352 cell.removeChildren(); |
365 var objectElement = Components.ObjectPropertiesSection.defaultObjectPres
entation(value, undefined, true); | 353 var objectElement = Components.ObjectPropertiesSection.defaultObjectPres
entation(value, undefined, true); |
366 cell.appendChild(objectElement); | 354 cell.appendChild(objectElement); |
367 break; | 355 break; |
368 default: | 356 default: |
369 } | 357 } |
370 | 358 |
371 return cell; | 359 return cell; |
372 } | 360 } |
373 }; | 361 }; |
OLD | NEW |