Browse Source

Merge pull request #940 from ellisonbg/move-inspector

Move the inspector to the main area and add a command to open it...
Steven Silvester 8 years ago
parent
commit
72ecfa274c
1 changed files with 29 additions and 5 deletions
  1. 29 5
      src/inspector/plugin.ts

+ 29 - 5
src/inspector/plugin.ts

@@ -1,10 +1,15 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
+
 import {
   JupyterLab, JupyterLabPlugin
 } from '../application';
 
+import {
+  ICommandPalette
+} from '../commandpalette';
+
 import {
   IInspector, Inspector
 } from './';
@@ -18,6 +23,7 @@ export
 const inspectorProvider: JupyterLabPlugin<IInspector> = {
   id: 'jupyter.services.inspector',
   provides: IInspector,
+  requires: [ICommandPalette],
   activate: activateInspector
 };
 
@@ -25,18 +31,36 @@ const inspectorProvider: JupyterLabPlugin<IInspector> = {
 /**
  * Activate the console extension.
  */
-function activateInspector(app: JupyterLab): IInspector {
+function activateInspector(app: JupyterLab, palette: ICommandPalette): IInspector {
   let inspector = new Inspector({ items: Private.defaultInspectorItems });
+  let openInspectorCommand = 'inspector:open';
+  let opened = false;
+
   inspector.id = 'jp-inspector';
   inspector.title.label = 'Inspector';
 
-  // Rank has been chosen somewhat arbitrarily to guarantee the inspector is
-  // at least not the first item in the application sidebar.
-  app.shell.addToRightArea(inspector, { rank: 20 });
+  function openInspector(): void {
+    if (!opened) {
+      app.shell.addToMainArea(inspector);
+      opened = true;
+    } else {
+      app.shell.activateMain(inspector.id);
+    }
+  }
+
+  app.commands.addCommand(openInspectorCommand, {
+    execute: openInspector,
+    label: "Open Inspector"
+  });
+
+  palette.addItem({
+    command: openInspectorCommand,
+    category: 'Inspector'
+  });
 
   return inspector;
 }
-
+ 
 
 /**
  * A namespace for private data.