| 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('click', this._refreshButtonClicked, th
is); | 102 this._refreshButton.addEventListener(UI.ToolbarButton.Events.Click, this._re
freshButtonClicked, this); |
| 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('click', this._clearButtonClicked, this); | 105 this._clearButton.addEventListener(UI.ToolbarButton.Events.Click, this._clea
rButtonClicked, 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('click', this._pageBackButtonClicked,
this); | 182 this._pageBackButton.addEventListener(UI.ToolbarButton.Events.Click, this._p
ageBackButtonClicked, 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('click', this._pageForwardButtonCli
cked, this); | 187 this._pageForwardButton.addEventListener(UI.ToolbarButton.Events.Click, this
._pageForwardButtonClicked, 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 _pageBackButtonClicked() { | 198 /** |
| 199 * @param {!Common.Event} event |
| 200 */ |
| 201 _pageBackButtonClicked(event) { |
| 199 this._skipCount = Math.max(0, this._skipCount - this._pageSize); | 202 this._skipCount = Math.max(0, this._skipCount - this._pageSize); |
| 200 this._updateData(false); | 203 this._updateData(false); |
| 201 } | 204 } |
| 202 | 205 |
| 203 _pageForwardButtonClicked() { | 206 /** |
| 207 * @param {!Common.Event} event |
| 208 */ |
| 209 _pageForwardButtonClicked(event) { |
| 204 this._skipCount = this._skipCount + this._pageSize; | 210 this._skipCount = this._skipCount + this._pageSize; |
| 205 this._updateData(false); | 211 this._updateData(false); |
| 206 } | 212 } |
| 207 | 213 |
| 208 _keyInputChanged() { | 214 _keyInputChanged() { |
| 209 window.setTimeout(this._updateData.bind(this, false), 0); | 215 window.setTimeout(this._updateData.bind(this, false), 0); |
| 210 } | 216 } |
| 211 | 217 |
| 212 /** | 218 /** |
| 213 * @param {!Resources.IndexedDBModel.ObjectStore} objectStore | 219 * @param {!Resources.IndexedDBModel.ObjectStore} objectStore |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 if (this._isIndex) { | 294 if (this._isIndex) { |
| 289 this._model.loadIndexData( | 295 this._model.loadIndexData( |
| 290 this._databaseId, this._objectStore.name, this._index.name, idbKeyRang
e, skipCount, pageSize, | 296 this._databaseId, this._objectStore.name, this._index.name, idbKeyRang
e, skipCount, pageSize, |
| 291 callback.bind(this)); | 297 callback.bind(this)); |
| 292 } else { | 298 } else { |
| 293 this._model.loadObjectStoreData( | 299 this._model.loadObjectStoreData( |
| 294 this._databaseId, this._objectStore.name, idbKeyRange, skipCount, page
Size, callback.bind(this)); | 300 this._databaseId, this._objectStore.name, idbKeyRange, skipCount, page
Size, callback.bind(this)); |
| 295 } | 301 } |
| 296 } | 302 } |
| 297 | 303 |
| 304 /** |
| 305 * @param {!Common.Event} event |
| 306 */ |
| 298 _refreshButtonClicked(event) { | 307 _refreshButtonClicked(event) { |
| 299 this._updateData(true); | 308 this._updateData(true); |
| 300 } | 309 } |
| 301 | 310 |
| 311 /** |
| 312 * @param {!Common.Event} event |
| 313 */ |
| 302 _clearButtonClicked(event) { | 314 _clearButtonClicked(event) { |
| 303 /** | 315 /** |
| 304 * @this {Resources.IDBDataView} | 316 * @this {Resources.IDBDataView} |
| 305 */ | 317 */ |
| 306 function cleared() { | 318 function cleared() { |
| 307 this._clearButton.setEnabled(true); | 319 this._clearButton.setEnabled(true); |
| 308 this._updateData(true); | 320 this._updateData(true); |
| 309 } | 321 } |
| 310 this._clearButton.setEnabled(false); | 322 this._clearButton.setEnabled(false); |
| 311 this._model.clearObjectStore(this._databaseId, this._objectStore.name, clear
ed.bind(this)); | 323 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... |
| 352 cell.removeChildren(); | 364 cell.removeChildren(); |
| 353 var objectElement = Components.ObjectPropertiesSection.defaultObjectPres
entation(value, undefined, true); | 365 var objectElement = Components.ObjectPropertiesSection.defaultObjectPres
entation(value, undefined, true); |
| 354 cell.appendChild(objectElement); | 366 cell.appendChild(objectElement); |
| 355 break; | 367 break; |
| 356 default: | 368 default: |
| 357 } | 369 } |
| 358 | 370 |
| 359 return cell; | 371 return cell; |
| 360 } | 372 } |
| 361 }; | 373 }; |
| OLD | NEW |