WebInspector: View throughs the exception when a child view are removed by removeChil...
[WebKit-https.git] / Source / WebCore / inspector / front-end / DatabaseTableView.js
index 1a886ff66307336229eb43c90c3228ee22bbba62..c7b87a20d235cefac7baa20b0c4045e80acc1604 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+/**
+ * @constructor
+ * @extends {WebInspector.View}
+ */
 WebInspector.DatabaseTableView = function(database, tableName)
 {
     WebInspector.View.call(this);
@@ -34,13 +38,12 @@ WebInspector.DatabaseTableView = function(database, tableName)
     this.element.addStyleClass("table");
 
     this.refreshButton = new WebInspector.StatusBarButton(WebInspector.UIString("Refresh"), "refresh-storage-status-bar-item");
-    this.refreshButton.addEventListener("click", this._refreshButtonClicked.bind(this), false);
+    this.refreshButton.addEventListener("click", this._refreshButtonClicked, this);
 }
 
 WebInspector.DatabaseTableView.prototype = {
-    show: function(parentElement)
+    wasShown: function()
     {
-        WebInspector.View.prototype.show.call(this, parentElement);
         this.update();
     },
 
@@ -56,23 +59,22 @@ WebInspector.DatabaseTableView.prototype = {
 
     _queryFinished: function(columnNames, values)
     {
+        this.detachChildViews();
         this.element.removeChildren();
 
-        var dataGrid = WebInspector.panels.resources.dataGridForResult(columnNames, values);
+        var dataGrid = WebInspector.DataGrid.createSortableDataGrid(columnNames, values);
         if (!dataGrid) {
-            var emptyMsgElement = document.createElement("div");
-            emptyMsgElement.className = "storage-empty-view";
-            emptyMsgElement.textContent = WebInspector.UIString("The ā€œ%sā€\ntable is empty.", this.tableName);
-            this.element.appendChild(emptyMsgElement);
+            this._emptyView = new WebInspector.EmptyView(WebInspector.UIString("The ā€œ%sā€\ntable is empty.", this.tableName));
+            this._emptyView.show(this.element);
             return;
         }
-
-        this.element.appendChild(dataGrid.element);
+        dataGrid.show(this.element);
         dataGrid.autoSizeColumns(5);
     },
 
     _queryError: function(error)
     {
+        this.detachChildViews();
         this.element.removeChildren();
 
         var errorMsgElement = document.createElement("div");