浏览代码

Update setting editor.

Afshin Darian 8 年之前
父节点
当前提交
23f3d811d6
共有 2 个文件被更改,包括 33 次插入7 次删除
  1. 1 5
      packages/apputils-extension/src/index.ts
  2. 32 2
      packages/apputils-extension/src/settingeditor.ts

+ 1 - 5
packages/apputils-extension/src/index.ts

@@ -123,11 +123,7 @@ const settingEditorPlugin: JupyterLabPlugin<void> = {
  */
 const settingPlugin: JupyterLabPlugin<ISettingRegistry> = {
   id: 'jupyter.services.setting-registry',
-  requires: [IStateDB],
-  activate: (app: JupyterLab, state: IStateDB) => {
-    const registry = new SettingRegistry();
-    return registry;
-  },
+  activate: () => new SettingRegistry(),
   autoStart: true,
   provides: ISettingRegistry
 };

+ 32 - 2
packages/apputils-extension/src/settingeditor.ts

@@ -27,6 +27,19 @@ import {
  * An interface for modifying and saving application settings.
  */
 class SettingEditor extends Widget {
+  /**
+   * Create a new setting editor.
+   */
+  constructor(options: SettingEditor.IOptions) {
+    super();
+    this.settings = options.settings;
+  }
+
+  /**
+   * The setting registry modified by the editor.
+   */
+  readonly settings: ISettingRegistry;
+
   /**
    * Handle `'activate-request'` messages.
    */
@@ -37,6 +50,23 @@ class SettingEditor extends Widget {
 }
 
 
+/**
+ * A namespace for `SettingEditor` statics.
+ */
+namespace SettingEditor {
+  /**
+   * The instantiation options for a setting editor.
+   */
+  export
+  interface IOptions {
+    /**
+     * The setting registry the editor modifies.
+     */
+    settings: ISettingRegistry;
+  }
+}
+
+
 /**
  * The command IDs used by the setting editor.
  */
@@ -47,13 +77,13 @@ namespace CommandIDs {
 
 
 /**
- * Activate the command palette.
+ * Activate the setting editor.
  */
 export
 function activateSettingEditor(app: JupyterLab, restorer: ILayoutRestorer, settings: ISettingRegistry): void {
   const { commands, shell } = app;
   const namespace = 'setting-editor';
-  const editor = new SettingEditor();
+  const editor = new SettingEditor({ settings });
   const tracker = new InstanceTracker<SettingEditor>({ namespace });
 
   editor.id = namespace;