Steven Silvester 8 лет назад
Родитель
Сommit
84d09f32cd
2 измененных файлов с 22 добавлено и 16 удалено
  1. 1 16
      src/csvwidget/plugin.ts
  2. 21 0
      src/csvwidget/widget.ts

+ 1 - 16
src/csvwidget/plugin.ts

@@ -14,12 +14,6 @@ import {
 } from './widget';
 
 
-/**
- * The list of file extensions for csv tables.
- */
-const EXTENSIONS = ['.csv'];
-
-
 /**
  * The table file handler extension.
  */
@@ -36,14 +30,5 @@ const csvHandlerExtension: JupyterLabPlugin<void> = {
  * Activate the table widget extension.
  */
 function activateCSVWidget(app: JupyterLab, registry: IDocumentRegistry): void {
-  let options = {
-    fileExtensions: EXTENSIONS,
-    defaultFor: EXTENSIONS,
-    displayName: 'Table',
-    modelName: 'text',
-    preferKernel: false,
-    canStartKernel: false
-  };
-
-  registry.addWidgetFactory(new CSVWidgetFactory(), options);
+  registry.addWidgetFactory(new CSVWidgetFactory());
 }

+ 21 - 0
src/csvwidget/widget.ts

@@ -216,6 +216,27 @@ function createDelimiterSwitcherNode(): HTMLElement {
  */
 export
 class CSVWidgetFactory extends ABCWidgetFactory<CSVWidget, DocumentRegistry.IModel> {
+  /**
+   * The name of the widget to display in dialogs.
+   */
+  get name(): string {
+    return 'Table';
+  }
+
+  /**
+   * The file extensions the widget can view.
+   */
+  get fileExtensions(): string[] {
+    return ['.csv'];
+  }
+
+  /**
+   * The file extensions for which the factory should be the default.
+   */
+  get defaultFor(): string[] {
+    return ['.csv'];
+  }
+
   /**
    * Create a new widget given a context.
    */