| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 | 51 |
| 52 function moveBackIfOutside() | 52 function moveBackIfOutside() |
| 53 { | 53 { |
| 54 if (!this.prompt.isCaretInsidePrompt() && window.getSelection().isCo
llapsed) | 54 if (!this.prompt.isCaretInsidePrompt() && window.getSelection().isCo
llapsed) |
| 55 this.prompt.moveCaretToEndOfPrompt(); | 55 this.prompt.moveCaretToEndOfPrompt(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 setTimeout(moveBackIfOutside.bind(this), 0); | 58 setTimeout(moveBackIfOutside.bind(this), 0); |
| 59 }, | 59 }, |
| 60 | 60 |
| 61 completions: function(wordRange, bestMatchOnly) | 61 completions: function(wordRange, bestMatchOnly, completionsReadyCallback) |
| 62 { | 62 { |
| 63 var prefix = wordRange.toString().toLowerCase(); | 63 var prefix = wordRange.toString().toLowerCase(); |
| 64 if (!prefix.length) | 64 if (!prefix.length) |
| 65 return; | 65 return; |
| 66 | 66 |
| 67 var results = []; | 67 var results = []; |
| 68 | 68 |
| 69 function accumulateMatches(textArray) | 69 function accumulateMatches(textArray) |
| 70 { | 70 { |
| 71 if (bestMatchOnly && results.length) | 71 if (bestMatchOnly && results.length) |
| 72 return; | 72 return; |
| 73 for (var i = 0; i < textArray.length; ++i) { | 73 for (var i = 0; i < textArray.length; ++i) { |
| 74 var text = textArray[i].toLowerCase(); | 74 var text = textArray[i].toLowerCase(); |
| 75 if (text.length < prefix.length) | 75 if (text.length < prefix.length) |
| 76 continue; | 76 continue; |
| 77 if (text.indexOf(prefix) !== 0) | 77 if (text.indexOf(prefix) !== 0) |
| 78 continue; | 78 continue; |
| 79 results.push(textArray[i]); | 79 results.push(textArray[i]); |
| 80 if (bestMatchOnly) | 80 if (bestMatchOnly) |
| 81 return; | 81 return; |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 | 84 |
| 85 accumulateMatches(this.database.tableNames.map(function(name) { return n
ame + " " })); | 85 accumulateMatches(this.database.tableNames.map(function(name) { return n
ame + " " })); |
| 86 accumulateMatches(["SELECT ", "FROM ", "WHERE ", "LIMIT ", "DELETE FROM
", "CREATE ", "DROP ", "TABLE ", "INDEX ", "UPDATE ", "INSERT INTO ", "VALUES ("
]); | 86 accumulateMatches(["SELECT ", "FROM ", "WHERE ", "LIMIT ", "DELETE FROM
", "CREATE ", "DROP ", "TABLE ", "INDEX ", "UPDATE ", "INSERT INTO ", "VALUES ("
]); |
| 87 | 87 |
| 88 return results; | 88 completionsReadyCallback(results); |
| 89 }, | 89 }, |
| 90 | 90 |
| 91 _promptKeyDown: function(event) | 91 _promptKeyDown: function(event) |
| 92 { | 92 { |
| 93 switch (event.keyIdentifier) { | 93 switch (event.keyIdentifier) { |
| 94 case "Enter": | 94 case "Enter": |
| 95 this._enterKeyPressed(event); | 95 this._enterKeyPressed(event); |
| 96 return; | 96 return; |
| 97 } | 97 } |
| 98 | 98 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 function queryTransaction(tx) | 135 function queryTransaction(tx) |
| 136 { | 136 { |
| 137 tx.executeSql(query, null, InspectorController.wrapCallback(this._qu
eryFinished.bind(this, query)), InspectorController.wrapCallback(this._executeSq
lError.bind(this, query))); | 137 tx.executeSql(query, null, InspectorController.wrapCallback(this._qu
eryFinished.bind(this, query)), InspectorController.wrapCallback(this._executeSq
lError.bind(this, query))); |
| 138 } | 138 } |
| 139 | 139 |
| 140 this.database.database.transaction(InspectorController.wrapCallback(quer
yTransaction.bind(this)), InspectorController.wrapCallback(this._queryError.bind
(this, query))); | 140 this.database.database.transaction(InspectorController.wrapCallback(quer
yTransaction.bind(this)), InspectorController.wrapCallback(this._queryError.bind
(this, query))); |
| 141 }, | 141 }, |
| 142 | 142 |
| 143 _queryFinished: function(query, tx, result) | 143 _queryFinished: function(query, tx, result) |
| 144 { | 144 { |
| 145 var dataGrid = WebInspector.panels.databases.dataGridForResult(result); | 145 var dataGrid = WebInspector.panels.storage.dataGridForResult(result); |
| 146 dataGrid.element.addStyleClass("inline"); | 146 dataGrid.element.addStyleClass("inline"); |
| 147 this._appendQueryResult(query, dataGrid.element); | 147 this._appendQueryResult(query, dataGrid.element); |
| 148 | 148 |
| 149 if (query.match(/^create /i) || query.match(/^drop table /i)) | 149 if (query.match(/^create /i) || query.match(/^drop table /i)) |
| 150 WebInspector.panels.databases.updateDatabaseTables(this.database); | 150 WebInspector.panels.storage.updateDatabaseTables(this.database); |
| 151 }, | 151 }, |
| 152 | 152 |
| 153 _queryError: function(query, error) | 153 _queryError: function(query, error) |
| 154 { | 154 { |
| 155 if (error.code == 1) | 155 if (error.code == 1) |
| 156 var message = error.message; | 156 var message = error.message; |
| 157 else if (error.code == 2) | 157 else if (error.code == 2) |
| 158 var message = WebInspector.UIString("Database no longer has expected
version."); | 158 var message = WebInspector.UIString("Database no longer has expected
version."); |
| 159 else | 159 else |
| 160 var message = WebInspector.UIString("An unexpected error %s occured.
", error.code); | 160 var message = WebInspector.UIString("An unexpected error %s occurred
.", error.code); |
| 161 | 161 |
| 162 this._appendQueryResult(query, message, "error"); | 162 this._appendQueryResult(query, message, "error"); |
| 163 }, | 163 }, |
| 164 | 164 |
| 165 _executeSqlError: function(query, tx, error) | 165 _executeSqlError: function(query, tx, error) |
| 166 { | 166 { |
| 167 this._queryError(query, error); | 167 this._queryError(query, error); |
| 168 }, | 168 }, |
| 169 | 169 |
| 170 _appendQueryResult: function(query, result, resultClassName) | 170 _appendQueryResult: function(query, result, resultClassName) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 190 | 190 |
| 191 if (resultElement.childNodes.length) | 191 if (resultElement.childNodes.length) |
| 192 element.appendChild(resultElement); | 192 element.appendChild(resultElement); |
| 193 | 193 |
| 194 this.element.insertBefore(element, this.promptElement); | 194 this.element.insertBefore(element, this.promptElement); |
| 195 this.promptElement.scrollIntoView(false); | 195 this.promptElement.scrollIntoView(false); |
| 196 } | 196 } |
| 197 } | 197 } |
| 198 | 198 |
| 199 WebInspector.DatabaseQueryView.prototype.__proto__ = WebInspector.View.prototype
; | 199 WebInspector.DatabaseQueryView.prototype.__proto__ = WebInspector.View.prototype
; |
| OLD | NEW |