Browse Source

new filehandler

Jason Grout 9 years ago
parent
commit
1e42444344
4 changed files with 11 additions and 10 deletions
  1. 2 0
      .gitignore
  2. 1 1
      package.json
  3. 3 3
      src/fileopener/index.ts
  4. 5 6
      src/fileopener/plugin.ts

+ 2 - 0
.gitignore

@@ -8,3 +8,5 @@ test/coverage
 lib/
 example/build
 docs
+
+.ipynb_checkpoints

+ 1 - 1
package.json

@@ -6,7 +6,7 @@
   "typings": "lib/index.d.ts",
   "dependencies": {
     "codemirror": "^5.10.0",
-    "jupyter-js-filebrowser": "^0.3.4",
+    "jupyter-js-filebrowser": "^0.3.7",
     "jupyter-js-notebook": "^0.2.1",
     "jupyter-js-services": "^0.3.3",
     "jupyter-js-terminal": "^0.1.12",

+ 3 - 3
src/fileopener/index.ts

@@ -17,14 +17,14 @@ import {
 export
 interface IFileHandler {
   /**
-   * he list of file extensions supported by the handler.
+   * The list of file extensions supported by the handler.
    */
   fileExtensions: string[];
 
   /**
    * Open the file and return a populated widget.
    */
-  open(path: string): Promise<Widget>;
+  open(path: string): Widget;
 
   /**
    * Close the file widget.
@@ -41,7 +41,7 @@ interface IFileOpener {
   /**
    * Open the file and add the widget to the application shell.
    */
-  open(path: string): Promise<void>;
+  open(path: string): void;
 
   /**
    * Register a file opener.

+ 5 - 6
src/fileopener/plugin.ts

@@ -77,7 +77,7 @@ class FileOpener implements IFileOpener {
   /**
    * Open a file and add it to the application shell.
    */
-  open(path: string): Promise<void> {
+  open(path: string): void {
     if (this._handlers.length === 0) {
       return;
     }
@@ -100,7 +100,7 @@ class FileOpener implements IFileOpener {
 
     // If there we no matches, do nothing.
     if (handlers.length == 0) {
-      return Promise.reject(new Error(`Could not open file '${path}'`));
+      throw new Error(`Could not open file '${path}'`);
 
     // If there was one handler, use it.
     } else if (handlers.length === 1) {
@@ -122,10 +122,9 @@ class FileOpener implements IFileOpener {
   /**
    * Open a file and add it to the application shell.
    */
-  private _open(handler: IFileHandler, path: string): Promise<void> {
-    return handler.open(path).then(widget => {
-      this._appShell.addToMainArea(widget);
-    });
+  private _open(handler: IFileHandler, path: string): void {
+    let widget = handler.open(path);
+    this._appShell.addToMainArea(widget);    
   }
 
   private _handlers: IFileHandler[] = [];