Sfoglia il codice sorgente

Expose a widgets iterator for the application shell's areas.

Afshin Darian 8 anni fa
parent
commit
043d92f922
1 ha cambiato i file con 19 aggiunte e 1 eliminazioni
  1. 19 1
      packages/application/src/shell.ts

+ 19 - 1
packages/application/src/shell.ts

@@ -2,7 +2,7 @@
 // Distributed under the terms of the Modified BSD License.
 
 import {
-  ArrayExt, each, find, toArray
+  ArrayExt, each, find, IIterator, iter, toArray
 } from '@phosphor/algorithm';
 
 import {
@@ -402,6 +402,24 @@ class ApplicationShell extends Widget {
     this._rightHandler.sideBar.currentChanged.connect(this._save, this);
   }
 
+  /**
+   * Returns the widgets for an application area.
+   */
+  widgets(area: ApplicationShell.Area): IIterator<Widget> {
+    switch (area) {
+      case 'main':
+        return this._dockPanel.widgets();
+      case 'left':
+        return iter(this._leftHandler.sideBar.titles.map(t => t.owner));
+      case 'right':
+        return iter(this._rightHandler.sideBar.titles.map(t => t.owner));
+      case 'top':
+        return this._topPanel.children();
+      default:
+        break;
+    }
+  }
+
   /*
    * Return the TabBar that has the currently active Widget or null.
    */