|
@@ -3,15 +3,23 @@
|
|
|
'use strict';
|
|
|
|
|
|
import {
|
|
|
- IAppShell
|
|
|
+ FileBrowser
|
|
|
+} from 'jupyter-js-filebrowser';
|
|
|
+
|
|
|
+import {
|
|
|
+ IAppShell, ICommandPalette, ICommandRegistry
|
|
|
} from 'phosphide';
|
|
|
|
|
|
+import {
|
|
|
+ ICommand, DelegateCommand
|
|
|
+} from 'phosphor-command';
|
|
|
+
|
|
|
import {
|
|
|
Container, Token
|
|
|
} from 'phosphor-di';
|
|
|
|
|
|
import {
|
|
|
- ITerminalProvider
|
|
|
+ ITerminalProvider, IFileBrowserProvider
|
|
|
} from '../lib';
|
|
|
|
|
|
|
|
@@ -37,31 +45,54 @@ class DefaultHandler {
|
|
|
/**
|
|
|
* The dependencies required by the default plugin.
|
|
|
*/
|
|
|
- static requires: Token<any>[] = [IAppShell, ITerminalProvider];
|
|
|
+ static requires: Token<any>[] = [IAppShell, ITerminalProvider, ICommandPalette, ICommandRegistry, IFileBrowserProvider];
|
|
|
|
|
|
/**
|
|
|
* Create a default plugin instance..
|
|
|
*/
|
|
|
- static create(shell: IAppShell, term: ITerminalProvider): DefaultHandler {
|
|
|
- return new DefaultHandler(shell, term);
|
|
|
+ static create(shell: IAppShell, term: ITerminalProvider, palette: ICommandPalette, registry: ICommandRegistry, browser: IFileBrowserProvider): DefaultHandler {
|
|
|
+ return new DefaultHandler(shell, term, palette, registry, browser);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Construct a new default plugin.
|
|
|
*/
|
|
|
- constructor(shell: IAppShell, term: ITerminalProvider) {
|
|
|
+ constructor(shell: IAppShell, term: ITerminalProvider, palette: ICommandPalette, registry: ICommandRegistry, browser: IFileBrowserProvider) {
|
|
|
this._shell = shell;
|
|
|
this._term = term;
|
|
|
+ this._palette = palette;
|
|
|
+ this._registry = registry;
|
|
|
+ this._browser = browser.fileBrowser;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Create a terminal and add it to the main shell area.
|
|
|
*/
|
|
|
run() {
|
|
|
- let term = this._term.createTerminal();
|
|
|
- this._shell.addToMainArea(term);
|
|
|
+ let commandItem = {
|
|
|
+ id: 'jupyter-plugins:new-terminal',
|
|
|
+ command: new DelegateCommand(() => {
|
|
|
+ let term = this._term.createTerminal();
|
|
|
+ this._shell.addToMainArea(term);
|
|
|
+ })
|
|
|
+ }
|
|
|
+ this._registry.add([commandItem]);
|
|
|
+ let paletteItem = {
|
|
|
+ id: 'jupyter-plugins:new-terminal',
|
|
|
+ title: 'New Terminal',
|
|
|
+ caption: ''
|
|
|
+ }
|
|
|
+ let section = {
|
|
|
+ text: 'Open...',
|
|
|
+ items: [paletteItem]
|
|
|
+ }
|
|
|
+ this._palette.add([section]);
|
|
|
+ this._shell.addToLeftArea(this._browser, { rank: 10 });
|
|
|
}
|
|
|
|
|
|
private _term: ITerminalProvider = null;
|
|
|
private _shell: IAppShell = null;
|
|
|
+ private _palette: ICommandPalette = null;
|
|
|
+ private _registry: ICommandRegistry = null;
|
|
|
+ private _browser: FileBrowser;
|
|
|
}
|