Browse Source

Support passing in factory to open command.

Afshin Darian 8 years ago
parent
commit
a0adbd7baf
2 changed files with 5 additions and 3 deletions
  1. 3 2
      src/csvwidget/plugin.ts
  2. 2 1
      src/filebrowser/plugin.ts

+ 3 - 2
src/csvwidget/plugin.ts

@@ -43,8 +43,9 @@ const csvHandlerExtension: JupyterLabPlugin<void> = {
  * Activate the table widget extension.
  */
 function activateCSVWidget(app: JupyterLab, registry: IDocumentRegistry, state: IStateDB): void {
+  const factoryName = 'Table';
   const factory = new CSVWidgetFactory({
-    name: 'Table',
+    name: factoryName,
     fileExtensions: ['.csv'],
     defaultFor: ['.csv']
   });
@@ -52,7 +53,7 @@ function activateCSVWidget(app: JupyterLab, registry: IDocumentRegistry, state:
     restore: {
       state,
       command: 'file-operations:open',
-      args: widget => ({ path: widget.context.path }),
+      args: widget => ({ path: widget.context.path, factory: factoryName }),
       name: widget => widget.context.path,
       namespace: 'csvwidgets',
       when: app.started,

+ 2 - 1
src/filebrowser/plugin.ts

@@ -278,7 +278,8 @@ function addCommands(app: JupyterLab, fbWidget: FileBrowser, docManager: Documen
   commands.addCommand(cmdIds.open, {
     execute: args => {
       let path = args['path'] as string;
-      return fbWidget.openPath(path);
+      let factory = args['factory'] as string || void 0;
+      return fbWidget.openPath(path, factory);
     }
   });