Support notebook file types contribution (#3196)

* Support notebook file types contribution
- Extensions can define a provider and what file types it should be used for
- Verified that this works for Jupyter Content & Server Managers.
- Starts Jupyter server as expected

Not in this PR:
- Support for session manager end to end
- Tests
This commit is contained in:
Kevin Cunnane
2018-11-12 17:32:53 -08:00
committed by GitHub
parent 0a486a280d
commit 0b571737b7
6 changed files with 198 additions and 19 deletions

View File

@@ -13,10 +13,12 @@ import { TPromise } from 'vs/base/common/winjs.base';
import { Schemas } from 'vs/base/common/network';
import URI from 'vs/base/common/uri';
import { localize } from 'vs/nls';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { NotebookInput, NotebookInputModel } from 'sql/parts/notebook/notebookInput';
import { NotebookEditor } from 'sql/parts/notebook/notebookEditor';
let counter = 0;
/**
@@ -31,7 +33,8 @@ export class OpenNotebookAction extends Action {
constructor(
id: string,
label: string,
@IEditorService private _editorService: IEditorService
@IEditorService private _editorService: IEditorService,
@IInstantiationService private _instantiationService: IInstantiationService
) {
super(id, label);
}
@@ -40,7 +43,7 @@ export class OpenNotebookAction extends Action {
return new TPromise<void>((resolve, reject) => {
let untitledUri = URI.from({ scheme: Schemas.untitled, path: `Untitled-${counter++}`});
let model = new NotebookInputModel(untitledUri, undefined, false, undefined);
let input = new NotebookInput('modelViewId', model,);
let input = this._instantiationService.createInstance(NotebookInput, 'modelViewId', model);
this._editorService.openEditor(input, { pinned: true });
});
}

View File

@@ -10,6 +10,7 @@ import { IEditorModel } from 'vs/platform/editor/common/editor';
import { EditorInput, EditorModel, ConfirmResult } from 'vs/workbench/common/editor';
import { Emitter, Event } from 'vs/base/common/event';
import URI from 'vs/base/common/uri';
import { INotebookService } from 'sql/services/notebook/notebookService';
export type ModeViewSaveHandler = (handle: number) => Thenable<boolean>;
@@ -66,11 +67,17 @@ export class NotebookInput extends EditorInput {
// Holds the HTML content for the editor when the editor discards this input and loads another
private _parentContainer: HTMLElement;
constructor(private _title: string, private _model: NotebookInputModel,
constructor(private _title: string,
private _model: NotebookInputModel,
@INotebookService private notebookService: INotebookService
) {
super();
this._model.onDidChangeDirty(() => this._onDidChangeDirty.fire());
this.onDispose(() => {
if (this.notebookService) {
this.notebookService.handleNotebookClosed(this.notebookUri);
}
});
}
public get title(): string {