| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 */ | 28 */ |
| 29 Resources.DatabaseQueryView = class extends UI.VBox { | 29 Resources.DatabaseQueryView = class extends UI.VBox { |
| 30 constructor(database) { | 30 constructor(database) { |
| 31 super(); | 31 super(); |
| 32 | 32 |
| 33 this.database = database; | 33 this.database = database; |
| 34 | 34 |
| 35 this.element.classList.add('storage-view', 'query', 'monospace'); | 35 this.element.classList.add('storage-view', 'query', 'monospace'); |
| 36 this.element.addEventListener('selectstart', this._selectStart.bind(this), f
alse); | 36 this.element.addEventListener('selectstart', this._selectStart.bind(this), f
alse); |
| 37 | 37 |
| 38 this._promptIcon = UI.Icon.create('smallicon-text-prompt', 'prompt-icon'); |
| 38 this._promptElement = createElement('div'); | 39 this._promptElement = createElement('div'); |
| 40 this._promptElement.appendChild(this._promptIcon); |
| 39 this._promptElement.className = 'database-query-prompt'; | 41 this._promptElement.className = 'database-query-prompt'; |
| 40 this._promptElement.appendChild(createElement('br')); | 42 this._promptElement.appendChild(createElement('br')); |
| 41 this._promptElement.addEventListener('keydown', this._promptKeyDown.bind(thi
s), true); | 43 this._promptElement.addEventListener('keydown', this._promptKeyDown.bind(thi
s), true); |
| 42 this.element.appendChild(this._promptElement); | 44 this.element.appendChild(this._promptElement); |
| 43 | 45 |
| 44 this._prompt = new UI.TextPrompt(); | 46 this._prompt = new UI.TextPrompt(); |
| 45 this._prompt.initialize(this.completions.bind(this), ' '); | 47 this._prompt.initialize(this.completions.bind(this), ' '); |
| 46 this._proxyElement = this._prompt.attach(this._promptElement); | 48 this._proxyElement = this._prompt.attach(this._promptElement); |
| 47 | 49 |
| 48 this.element.addEventListener('click', this._messagesClicked.bind(this), tru
e); | 50 this.element.addEventListener('click', this._messagesClicked.bind(this), tru
e); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 _enterKeyPressed(event) { | 124 _enterKeyPressed(event) { |
| 123 event.consume(true); | 125 event.consume(true); |
| 124 | 126 |
| 125 this._prompt.clearAutocomplete(); | 127 this._prompt.clearAutocomplete(); |
| 126 | 128 |
| 127 var query = this._prompt.text(); | 129 var query = this._prompt.text(); |
| 128 if (!query.length) | 130 if (!query.length) |
| 129 return; | 131 return; |
| 130 | 132 |
| 131 this._prompt.setText(''); | 133 this._prompt.setText(''); |
| 134 this._promptElement.insertBefore(this._promptIcon, this._promptElement.first
Child); |
| 132 | 135 |
| 133 this.database.executeSql(query, this._queryFinished.bind(this, query), this.
_queryError.bind(this, query)); | 136 this.database.executeSql(query, this._queryFinished.bind(this, query), this.
_queryError.bind(this, query)); |
| 134 } | 137 } |
| 135 | 138 |
| 136 _queryFinished(query, columnNames, values) { | 139 _queryFinished(query, columnNames, values) { |
| 137 var dataGrid = UI.SortableDataGrid.create(columnNames, values); | 140 var dataGrid = UI.SortableDataGrid.create(columnNames, values); |
| 138 var trimmedQuery = query.trim(); | 141 var trimmedQuery = query.trim(); |
| 139 | 142 |
| 140 if (dataGrid) { | 143 if (dataGrid) { |
| 141 dataGrid.renderInline(); | 144 dataGrid.renderInline(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 161 this._promptElement.scrollIntoView(false); | 164 this._promptElement.scrollIntoView(false); |
| 162 } | 165 } |
| 163 | 166 |
| 164 /** | 167 /** |
| 165 * @param {string} query | 168 * @param {string} query |
| 166 * @param {string} errorText | 169 * @param {string} errorText |
| 167 */ | 170 */ |
| 168 _appendErrorQueryResult(query, errorText) { | 171 _appendErrorQueryResult(query, errorText) { |
| 169 var resultElement = this._appendQueryResult(query); | 172 var resultElement = this._appendQueryResult(query); |
| 170 resultElement.classList.add('error'); | 173 resultElement.classList.add('error'); |
| 171 resultElement.textContent = errorText; | 174 resultElement.appendChild(UI.Icon.create('smallicon-error', 'prompt-icon')); |
| 175 resultElement.createTextChild(errorText); |
| 172 | 176 |
| 173 this._promptElement.scrollIntoView(false); | 177 this._promptElement.scrollIntoView(false); |
| 174 } | 178 } |
| 175 | 179 |
| 180 /** |
| 181 * @param {string} query |
| 182 */ |
| 176 _appendQueryResult(query) { | 183 _appendQueryResult(query) { |
| 177 var element = createElement('div'); | 184 var element = createElement('div'); |
| 178 element.className = 'database-user-query'; | 185 element.className = 'database-user-query'; |
| 186 element.appendChild(UI.Icon.create('smallicon-user-command', 'prompt-icon'))
; |
| 179 this.element.insertBefore(element, this._proxyElement); | 187 this.element.insertBefore(element, this._proxyElement); |
| 180 | 188 |
| 181 var commandTextElement = createElement('span'); | 189 var commandTextElement = createElement('span'); |
| 182 commandTextElement.className = 'database-query-text'; | 190 commandTextElement.className = 'database-query-text'; |
| 183 commandTextElement.textContent = query; | 191 commandTextElement.textContent = query; |
| 184 element.appendChild(commandTextElement); | 192 element.appendChild(commandTextElement); |
| 185 | 193 |
| 186 var resultElement = createElement('div'); | 194 var resultElement = createElement('div'); |
| 187 resultElement.className = 'database-query-result'; | 195 resultElement.className = 'database-query-result'; |
| 188 element.appendChild(resultElement); | 196 element.appendChild(resultElement); |
| 189 return resultElement; | 197 return resultElement; |
| 190 } | 198 } |
| 191 }; | 199 }; |
| 192 | 200 |
| 193 /** @enum {symbol} */ | 201 /** @enum {symbol} */ |
| 194 Resources.DatabaseQueryView.Events = { | 202 Resources.DatabaseQueryView.Events = { |
| 195 SchemaUpdated: Symbol('SchemaUpdated') | 203 SchemaUpdated: Symbol('SchemaUpdated') |
| 196 }; | 204 }; |
| OLD | NEW |