Bug 869984 - Add sorting and searching to Scratchpad VariablesView, r=vporof
authorBrandon Benvie <bbenvie@mozilla.com>
Mon, 17 Jun 2013 14:55:25 -0700
changeset 147491 5b90583b9739417547cb430c0b5c533243e609cd
parent 147490 1663fa5bc540ea068db35ed76aec5ed5d67b4340
child 147492 c94e2d611affb0e9cde6cd6f31e6342a0c198b2d
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvporof
bugs869984
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 869984 - Add sorting and searching to Scratchpad VariablesView, r=vporof
browser/devtools/scratchpad/scratchpad.js
browser/devtools/shared/widgets/VariablesView.jsm
browser/locales/en-US/chrome/browser/devtools/scratchpad.properties
--- a/browser/devtools/scratchpad/scratchpad.js
+++ b/browser/devtools/scratchpad/scratchpad.js
@@ -268,17 +268,17 @@ var Scratchpad = {
 
 
   /**
    * Sidebar that contains the VariablesView for object inspection.
    */
   get sidebar()
   {
     if (!this._sidebar) {
-      this._sidebar = new ScratchpadSidebar();
+      this._sidebar = new ScratchpadSidebar(this);
     }
     return this._sidebar;
   },
 
   /**
    * Get the Cu.Sandbox object for the active tab content window object. Note
    * that the returned object is cached for later reuse. The cached object is
    * kept only for the current location in the current tab of the current
@@ -470,17 +470,17 @@ var Scratchpad = {
         this.writeAsComment(aResult);
         resolve();
       }
       else {
         this.deselect();
         this.sidebar.open(aString, aResult).then(resolve, reject);
       }
     }, reject);
-    
+
     return deferred.promise;
   },
 
   /**
    * Reload the current page and execute the entire editor content when
    * the page finishes loading. Note that this operation should be available
    * only in the content context.
    *
@@ -877,17 +877,17 @@ var Scratchpad = {
                               GetStringFromName("clearRecentMenuItems.label"));
       clearItems.setAttribute("command", "sp-cmd-clearRecentFiles");
       recentFilesPopup.appendChild(clearItems);
     }
   },
 
   /**
    * Clear a range of files from the list.
-   * 
+   *
    * @param integer aIndex
    *        Index of file in menu to remove.
    * @param integer aLength
    *        Number of files from the index 'aIndex' to remove.
    */
   clearFiles: function SP_clearFile(aIndex, aLength)
   {
     let filePaths = this.getRecentFiles();
@@ -1476,21 +1476,22 @@ var Scratchpad = {
   },
 };
 
 
 /**
  * Encapsulates management of the sidebar containing the VariablesView for
  * object inspection.
  */
-function ScratchpadSidebar()
+function ScratchpadSidebar(aScratchpad)
 {
   let ToolSidebar = devtools.require("devtools/framework/sidebar").ToolSidebar;
   let tabbox = document.querySelector("#scratchpad-sidebar");
   this._sidebar = new ToolSidebar(tabbox, this);
+  this._scratchpad = aScratchpad;
 }
 
 ScratchpadSidebar.prototype = {
   /*
    * The ToolSidebar for this sidebar.
    */
   _sidebar: null,
 
@@ -1520,17 +1521,21 @@ ScratchpadSidebar.prototype = {
     this.show();
 
     let deferred = Promise.defer();
 
     let onTabReady = () => {
       if (!this.variablesView) {
         let window = this._sidebar.getWindowForTab("variablesview");
         let container = window.document.querySelector("#variables");
-        this.variablesView = new VariablesView(container);
+        this.variablesView = new VariablesView(container, {
+          searchEnabled: true,
+          searchPlaceholder: this._scratchpad.strings
+                             .GetStringFromName("propertiesFilterPlaceholder")
+        });
       }
       this._update(aObject).then(() => deferred.resolve());
     };
 
     if (this._sidebar.getCurrentTabID() == "variablesview") {
       onTabReady();
     }
     else {
--- a/browser/devtools/shared/widgets/VariablesView.jsm
+++ b/browser/devtools/shared/widgets/VariablesView.jsm
@@ -79,23 +79,23 @@ this.VariablesView = function VariablesV
 
   EventEmitter.decorate(this);
 };
 
 VariablesView.prototype = {
   /**
    * Helper setter for populating this container with a raw object.
    *
-   * @param object aData
+   * @param object aObject
    *        The raw object to display. You can only provide this object
    *        if you want the variables view to work in sync mode.
    */
   set rawObject(aObject) {
     this.empty();
-    this.addScope().addItem().populate(aObject);
+    this.addScope().addItem().populate(aObject, { sorted: true });
   },
 
   /**
    * Adds a scope to contain any inspected variables.
    *
    * @param string aName
    *        The scope's name (e.g. "Local", "Global" etc.).
    * @return Scope
--- a/browser/locales/en-US/chrome/browser/devtools/scratchpad.properties
+++ b/browser/locales/en-US/chrome/browser/devtools/scratchpad.properties
@@ -76,8 +76,12 @@ browserContext.notification=This scratch
 
 # LOCALIZATION NOTE (help.openDocumentationPage): This returns a localized link with
 # documentation for Scratchpad on MDN.
 help.openDocumentationPage=https://developer.mozilla.org/en/Tools/Scratchpad
 
 # LOCALIZATION NOTE (fileExists.notification): This is the message displayed
 # over the top of the the editor when a file does not exist.
 fileNoLongerExists.notification=This file no longer exists.
+
+# LOCALIZATION NOTE (propertiesFilterPlaceholder): this is the text that
+# appears in the filter text box for the properties view container.
+propertiesFilterPlaceholder=Filter properties