Web Inspector: Add DirectoryContentView for FileSystemView
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Jul 2012 12:07:51 +0000 (12:07 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Jul 2012 12:07:51 +0000 (12:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=89961

Patch by Taiju Tsuiki <tzik@chromium.org> on 2012-07-02
Reviewed by Vsevolod Vlasov.

* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* inspector/compile-front-end.py:
* inspector/front-end/DirectoryContentView.js: Added.
* inspector/front-end/FileSystemView.js:
(WebInspector.FileSystemView):
(WebInspector.FileSystemView.EntryTreeElement.prototype.onattach):
(WebInspector.FileSystemView.EntryTreeElement.prototype.onselect):
(WebInspector.FileSystemView.EntryTreeElement.prototype._directoryContentReceived):
* inspector/front-end/WebKit.qrc:
* inspector/front-end/inspector.html:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@121671 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/inspector/compile-front-end.py
Source/WebCore/inspector/front-end/DirectoryContentView.js [new file with mode: 0644]
Source/WebCore/inspector/front-end/FileSystemView.js
Source/WebCore/inspector/front-end/WebKit.qrc
Source/WebCore/inspector/front-end/inspector.html

index 521ddb7..9655aef 100644 (file)
@@ -1,3 +1,22 @@
+2012-07-02  Taiju Tsuiki  <tzik@chromium.org>
+
+        Web Inspector: Add DirectoryContentView for FileSystemView
+        https://bugs.webkit.org/show_bug.cgi?id=89961
+
+        Reviewed by Vsevolod Vlasov.
+
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * inspector/compile-front-end.py:
+        * inspector/front-end/DirectoryContentView.js: Added.
+        * inspector/front-end/FileSystemView.js:
+        (WebInspector.FileSystemView):
+        (WebInspector.FileSystemView.EntryTreeElement.prototype.onattach):
+        (WebInspector.FileSystemView.EntryTreeElement.prototype.onselect):
+        (WebInspector.FileSystemView.EntryTreeElement.prototype._directoryContentReceived):
+        * inspector/front-end/WebKit.qrc:
+        * inspector/front-end/inspector.html:
+
 2012-07-02  Christophe Dumez  <christophe.dumez@intel.com>
 
         [EFL] Fix compilation error in GamepadsEfl.cpp in debug mode
index fe4a095..1be3022 100644 (file)
             'inspector/front-end/DebuggerResourceBinding.js',
             'inspector/front-end/DebuggerScriptMapping.js',
             'inspector/front-end/Dialog.js',
+            'inspector/front-end/DirectoryContentView.js',
             'inspector/front-end/DOMAgent.js',
             'inspector/front-end/DOMBreakpointsSidebarPane.js',
             'inspector/front-end/DOMExtension.js',
index 7296663..e776c49 100755 (executable)
                                        >
                                </File>
                                <File
+                                       RelativePath="..\inspector\front-end\DirectoryContentView.js"
+                                       >
+                               </File>
+                               <File
                                        RelativePath="..\inspector\front-end\DOMAgent.js"
                                        >
                                </File>
index 0217848..525638d 100755 (executable)
@@ -210,6 +210,7 @@ modules = [
             "CookieItemsView.js",
             "DatabaseQueryView.js",
             "DatabaseTableView.js",
+            "DirectoryContentView.js",
             "DOMStorageItemsView.js",
             "FileSystemView.js",
             "IndexedDBViews.js",
diff --git a/Source/WebCore/inspector/front-end/DirectoryContentView.js b/Source/WebCore/inspector/front-end/DirectoryContentView.js
new file mode 100644 (file)
index 0000000..f98f0ac
--- /dev/null
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @constructor
+ * @extends {WebInspector.DataGrid}
+ */
+WebInspector.DirectoryContentView = function()
+{
+    const indexes = WebInspector.DirectoryContentView.columnIndexes;
+    var columns = {};
+    columns[indexes.Name] = {};
+    columns[indexes.Name].title = WebInspector.UIString("Name");
+    columns[indexes.Name].width = "20%";
+    columns[indexes.URL] = {};
+    columns[indexes.URL].title = WebInspector.UIString("URL");
+    columns[indexes.URL].width = "20%";
+    columns[indexes.Type] = {};
+    columns[indexes.Type].title = WebInspector.UIString("Type");
+    columns[indexes.Type].width = "15%";
+    columns[indexes.Size] = {};
+    columns[indexes.Size].title = WebInspector.UIString("Size");
+    columns[indexes.Size].width = "10%";
+    columns[indexes.ModificationTime] = {};
+    columns[indexes.ModificationTime].title = WebInspector.UIString("Modification Time");
+    columns[indexes.ModificationTime].width = "25%";
+
+    WebInspector.DataGrid.call(this, columns);
+}
+
+WebInspector.DirectoryContentView.columnIndexes = {
+    Name: "0",
+    URL: "1",
+    Type: "2",
+    Size: "3",
+    ModificationTime: "4"
+}
+
+WebInspector.DirectoryContentView.prototype = {
+    /**
+     * @param {Array.<WebInspector.FileSystemModel.Directory>} entries
+     */
+    showEntries: function(entries)
+    {
+        const indexes = WebInspector.DirectoryContentView.columnIndexes;
+        this.rootNode().removeChildren();
+        for (var i = 0; i < entries.length; ++i)
+            this.rootNode().appendChild(new WebInspector.DirectoryContentView.Node(entries[i]));
+    }
+}
+
+WebInspector.DirectoryContentView.prototype.__proto__ = WebInspector.DataGrid.prototype;
+
+/**
+ * @constructor
+ * @extends {WebInspector.DataGridNode}
+ * @param {WebInspector.FileSystemModel.Entry} entry
+ */
+WebInspector.DirectoryContentView.Node = function(entry)
+{
+    const indexes = WebInspector.DirectoryContentView.columnIndexes;
+    var data = {};
+    data[indexes.Name] = entry.name;
+    data[indexes.URL] = entry.url;
+    data[indexes.Type] = entry.isDirectory ? WebInspector.UIString("Directory") : entry.mimeType;
+    data[indexes.Size] = "";
+    data[indexes.ModificationTime] = "";
+
+    WebInspector.DataGridNode.call(this, data);
+    this._entry = entry;
+    this._metadata = null;
+
+    this._entry.requestMetadata(this._metadataReceived.bind(this));
+}
+
+WebInspector.DirectoryContentView.Node.prototype = {
+    /**
+     * @param {number} errorCode
+     * @param {FileSystemAgent.Metadata} metadata
+     */
+    _metadataReceived: function(errorCode, metadata)
+    {
+        const indexes = WebInspector.DirectoryContentView.columnIndexes;
+        if (errorCode !== 0)
+            return;
+
+        this._metadata = metadata;
+        var data = this.data;
+        if ("size" in metadata)
+            data[indexes.Size] = Number.bytesToString(metadata.size);
+        data[indexes.ModificationTime] = new Date(metadata.modificationTime).toGMTString();
+        this.data = data;
+    }
+}
+
+WebInspector.DirectoryContentView.Node.prototype.__proto__ = WebInspector.DataGridNode.prototype;
index 76f4c7a..bd3b37a 100644 (file)
@@ -37,6 +37,7 @@ WebInspector.FileSystemView = function(fileSystem)
 {
     WebInspector.SplitView.call(this, WebInspector.SplitView.SidebarPosition.Left, "FileSystemViewSidebarWidth");
     this.element.addStyleClass("file-system-view");
+    this.element.addStyleClass("storage-view");
 
     var directoryTreeElement = this.element.createChild("ol", "filesystem-directory-tree");
     this.directoryTree = new TreeOutline(directoryTreeElement);
@@ -86,23 +87,23 @@ WebInspector.FileSystemView.EntryTreeElement.prototype = {
     {
         var selection = this.listItemElement.createChild("div", "selection");
         this.listItemElement.insertBefore(selection, this.listItemElement.firstChild);
-
-        this.listItemElement.addEventListener("contextmenu", this._handleContextMenuEvent.bind(this), true);
     },
 
-    onpopulate: function()
+    onselect: function()
     {
+        if (!this._view) {
+            if (this._entry.isDirectory)
+                this._view = new WebInspector.DirectoryContentView();
+            else
+                return;
+        }
+        this._fileSystemView.showView(this._view);
         this.refresh();
     },
 
-    _handleContextMenuEvent: function(event)
+    onpopulate: function()
     {
-        if (!this._entry.isDirectory)
-            return;
-
-        var contextMenu = new WebInspector.ContextMenu();
-        contextMenu.appendItem(WebInspector.UIString("Refresh"), this.refresh.bind(this));
-        contextMenu.show(event);
+        this.refresh();
     },
 
     /**
@@ -123,6 +124,9 @@ WebInspector.FileSystemView.EntryTreeElement.prototype = {
         }
 
         entries.sort(WebInspector.FileSystemModel.Entry.compare);
+        if (this._view)
+            this._view.showEntries(entries);
+
         var oldChildren = this.children.slice(0);
 
         var newEntryIndex = 0;
index d41d398..66fb301 100644 (file)
@@ -40,6 +40,7 @@
     <file>DebuggerResourceBinding.js</file>
     <file>DebuggerScriptMapping.js</file>
     <file>Dialog.js</file>
+    <file>DirectoryContentView.js</file>
     <file>DOMAgent.js</file>
     <file>DOMBreakpointsSidebarPane.js</file>
     <file>DOMExtension.js</file>
index 47058ca..8df5f20 100644 (file)
@@ -161,6 +161,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     <script type="text/javascript" src="SourceCSSTokenizer.js"></script>
     <script type="text/javascript" src="SourceHTMLTokenizer.js"></script>
     <script type="text/javascript" src="SourceJavaScriptTokenizer.js"></script>
+    <script type="text/javascript" src="DirectoryContentView.js"></script>
     <script type="text/javascript" src="FileSystemModel.js"></script>
     <script type="text/javascript" src="FileSystemView.js"></script>
     <script type="text/javascript" src="FontView.js"></script>