<commit_before>// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
'use strict';

import {
  FileBrowserWidget
} from 'jupyter-js-filebrowser';

import {
  IAppShell, ICommandPalette, ICommandRegistry
} from 'phosphide';

import {
  CodeMirrorWidget
} from 'phosphor-codemirror';

import {
  ICommand, DelegateCommand
} from 'phosphor-command';

import {
  Container, Token
} from 'phosphor-di';

import {
  Widget
} from 'phosphor-widget';

import {
<<<<<<< 4243cfb95b3b892f880811814c2a2241d062a0f6
  ITerminalProvider, IFileBrowserProvider, IServicesProvider, IFileOpener
=======
  ITerminalProvider, IFileBrowserProvider, INotebookProvider, IServicesProvider
>>>>>>> Initial work to incorporate a notebook widget.
} from '../../lib';


/**
 * Register the plugin contributions.
 *
 * @param container - The di container for type registration.
 *
 * #### Notes
 * This is called automatically when the plugin is loaded.
 */
export
function resolve(container: Container): void {
  container.resolve(DefaultHandler).then(handler => { handler.run(); });
}


/**
 * The default plugin for the example.
 */
class DefaultHandler {

  /**
   * The dependencies required by the default plugin.
   */
<<<<<<< 4243cfb95b3b892f880811814c2a2241d062a0f6
  static requires: Token<any>[] = [IAppShell, ITerminalProvider, ICommandPalette, ICommandRegistry, IFileBrowserProvider, IServicesProvider, IFileOpener];
=======
  static requires: Token<any>[] = [IAppShell, ITerminalProvider, ICommandPalette, ICommandRegistry, IFileBrowserProvider, INotebookProvider, IServicesProvider];
>>>>>>> Initial work to incorporate a notebook widget.

  /**
   * Create a default plugin instance..
   */
  static create(shell: IAppShell, term: ITerminalProvider, palette: ICommandPalette, registry: ICommandRegistry, browser: IFileBrowserProvider,
<<<<<<< 4243cfb95b3b892f880811814c2a2241d062a0f6
    services: IServicesProvider, opener: IFileOpener): DefaultHandler {
    return new DefaultHandler(shell, term, palette, registry, browser,
      services, opener);
=======
    notebook: INotebookProvider, services: IServicesProvider): DefaultHandler {
    return new DefaultHandler(shell, term, palette, registry, browser, notebook, services);
>>>>>>> Initial work to incorporate a notebook widget.
  }

  /**
   * Construct a new default plugin.
   */
<<<<<<< d42f834d98c73755769ddad046348959faed2b9d
<<<<<<< 4243cfb95b3b892f880811814c2a2241d062a0f6
  constructor(shell: IAppShell, term: ITerminalProvider, palette: ICommandPalette, registry: ICommandRegistry, browser: IFileBrowserProvider,
    services: IServicesProvider, opener: IFileOpener) {
=======
  constructor(shell: IAppShell, term: ITerminalProvider, palette: ICommandPalette, registry: ICommandRegistry, notebook: INotebookProvider, browser: IFileBrowserProvider,
    services: IServicesProvider) {
>>>>>>> Initial work to incorporate a notebook widget.
=======
  constructor(shell: IAppShell, term: ITerminalProvider, palette: ICommandPalette, registry: ICommandRegistry,  browser: IFileBrowserProvider, notebook: INotebookProvider, services: IServicesProvider) {
>>>>>>> Work-in-progress for a notebook widget
    this._shell = shell;
    this._term = term;
    this._palette = palette;
    this._registry = registry;
    this._browser = browser.fileBrowser;
    this._notebook = notebook;
    this._services = services;
    this._opener = opener;
  }

  /**
   * Create a terminal and add it to the main shell area.
   */
  run() {
    let termCommandItem = {
      id: 'jupyter-plugins:new-terminal',
      command: new DelegateCommand(() => {
        let term = this._term.createTerminal();
        term.color = 'black';
        term.background = 'white';
        this._shell.addToMainArea(term);
      })
    }
    let newFileCommandItem = {
      id: 'jupyter-plugins:new-text-file',
      command: new DelegateCommand(() => {
        // TODO
        let editor = new CodeMirrorWidget();
        editor.title.text = 'untitled.txt'
        this._shell.addToMainArea(editor);
      })
    }
/*    let newNotebookCommandItem = {
      id: 'jupyter-plugins:new-notebook',
      command: new DelegateCommand(() => {
        this._notebook.createNotebook('test.ipynb').then(notebook => {
          this._shell.addToMainArea(notebook);
        });
      })
    }
    */
    this._registry.add([termCommandItem, newFileCommandItem,
                        ]);
    let openPaletteItems = [{
      id: 'jupyter-plugins:new-terminal',
      title: 'Terminal',
      caption: ''
    }, {
      id: 'jupyter-plugins:new-text-file',
      title: 'Text File',
      caption: ''
    }, {
      id: 'jupyter-plugins:new-notebook',
      title: 'Notebook',
      caption: ''
    }]
    let section = {
      text: 'New...',
      items: openPaletteItems
    }
    this._palette.add([section]);

    /*
    let term = this._term.createTerminal();
    term.color = 'black';
    term.background = 'white';
    this._shell.addToMainArea(term);
    */

    // Start a default session.
    this._shell.addToLeftArea(this._browser, { rank: 10 });
/*    let contents = this._services.contentsManager;
    contents.newUntitled('', { type: 'notebook' }).then(content => {
      let sessions = this._services.notebookSessionManager;
      sessions.startNew({ notebookPath: content.path }).then(() => {
        this._shell.addToLeftArea(this._browser, { rank: 10 });
      });
    });
*/
    let nbpath = 'test.ipynb'
    this._notebook.createNotebook(nbpath).then(nb => {
      nb.title.text = nbpath;
      this._shell.addToMainArea(nb);
    })    
  }

  private _term: ITerminalProvider = null;
  private _shell: IAppShell = null;
  private _palette: ICommandPalette = null;
  private _registry: ICommandRegistry = null;
  private _browser: FileBrowserWidget = null;
  private _notebook: INotebookProvider = null;
  private _services: IServicesProvider = null;
  private _opener: IFileOpener = null;
}<commit_msg>create session<commit_after>// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
'use strict';

import {
  FileBrowserWidget
} from 'jupyter-js-filebrowser';

import {
  IAppShell, ICommandPalette, ICommandRegistry
} from 'phosphide';

import {
  CodeMirrorWidget
} from 'phosphor-codemirror';

import {
  ICommand, DelegateCommand
} from 'phosphor-command';

import {
  Container, Token
} from 'phosphor-di';

import {
  Widget
} from 'phosphor-widget';

import {
<<<<<<< 4243cfb95b3b892f880811814c2a2241d062a0f6
  ITerminalProvider, IFileBrowserProvider, IServicesProvider, IFileOpener
=======
  ITerminalProvider, IFileBrowserProvider, INotebookProvider, IServicesProvider
>>>>>>> Initial work to incorporate a notebook widget.
} from '../../lib';


/**
 * Register the plugin contributions.
 *
 * @param container - The di container for type registration.
 *
 * #### Notes
 * This is called automatically when the plugin is loaded.
 */
export
function resolve(container: Container): void {
  container.resolve(DefaultHandler).then(handler => { handler.run(); });
}


/**
 * The default plugin for the example.
 */
class DefaultHandler {

  /**
   * The dependencies required by the default plugin.
   */
<<<<<<< 4243cfb95b3b892f880811814c2a2241d062a0f6
  static requires: Token<any>[] = [IAppShell, ITerminalProvider, ICommandPalette, ICommandRegistry, IFileBrowserProvider, IServicesProvider, IFileOpener];
=======
  static requires: Token<any>[] = [IAppShell, ITerminalProvider, ICommandPalette, ICommandRegistry, IFileBrowserProvider, INotebookProvider, IServicesProvider];
>>>>>>> Initial work to incorporate a notebook widget.

  /**
   * Create a default plugin instance..
   */
  static create(shell: IAppShell, term: ITerminalProvider, palette: ICommandPalette, registry: ICommandRegistry, browser: IFileBrowserProvider,
<<<<<<< 4243cfb95b3b892f880811814c2a2241d062a0f6
    services: IServicesProvider, opener: IFileOpener): DefaultHandler {
    return new DefaultHandler(shell, term, palette, registry, browser,
      services, opener);
=======
    notebook: INotebookProvider, services: IServicesProvider): DefaultHandler {
    return new DefaultHandler(shell, term, palette, registry, browser, notebook, services);
>>>>>>> Initial work to incorporate a notebook widget.
  }

  /**
   * Construct a new default plugin.
   */
<<<<<<< d42f834d98c73755769ddad046348959faed2b9d
<<<<<<< 4243cfb95b3b892f880811814c2a2241d062a0f6
  constructor(shell: IAppShell, term: ITerminalProvider, palette: ICommandPalette, registry: ICommandRegistry, browser: IFileBrowserProvider,
    services: IServicesProvider, opener: IFileOpener) {
=======
  constructor(shell: IAppShell, term: ITerminalProvider, palette: ICommandPalette, registry: ICommandRegistry, notebook: INotebookProvider, browser: IFileBrowserProvider,
    services: IServicesProvider) {
>>>>>>> Initial work to incorporate a notebook widget.
=======
  constructor(shell: IAppShell, term: ITerminalProvider, palette: ICommandPalette, registry: ICommandRegistry,  browser: IFileBrowserProvider, notebook: INotebookProvider, services: IServicesProvider) {
>>>>>>> Work-in-progress for a notebook widget
    this._shell = shell;
    this._term = term;
    this._palette = palette;
    this._registry = registry;
    this._browser = browser.fileBrowser;
    this._notebook = notebook;
    this._services = services;
    this._opener = opener;
  }

  /**
   * Create a terminal and add it to the main shell area.
   */
  run() {
    let termCommandItem = {
      id: 'jupyter-plugins:new-terminal',
      command: new DelegateCommand(() => {
        let term = this._term.createTerminal();
        term.color = 'black';
        term.background = 'white';
        this._shell.addToMainArea(term);
      })
    }
    let newFileCommandItem = {
      id: 'jupyter-plugins:new-text-file',
      command: new DelegateCommand(() => {
        // TODO
        let editor = new CodeMirrorWidget();
        editor.title.text = 'untitled.txt'
        this._shell.addToMainArea(editor);
      })
    }
/*    let newNotebookCommandItem = {
      id: 'jupyter-plugins:new-notebook',
      command: new DelegateCommand(() => {
        this._notebook.createNotebook('test.ipynb').then(notebook => {
          this._shell.addToMainArea(notebook);
        });
      })
    }
    */
    this._registry.add([termCommandItem, newFileCommandItem,
                        ]);
    let openPaletteItems = [{
      id: 'jupyter-plugins:new-terminal',
      title: 'Terminal',
      caption: ''
    }, {
      id: 'jupyter-plugins:new-text-file',
      title: 'Text File',
      caption: ''
    }, {
      id: 'jupyter-plugins:new-notebook',
      title: 'Notebook',
      caption: ''
    }]
    let section = {
      text: 'New...',
      items: openPaletteItems
    }
    this._palette.add([section]);

    /*
    let term = this._term.createTerminal();
    term.color = 'black';
    term.background = 'white';
    this._shell.addToMainArea(term);
    */

    // Start a default session.
    this._shell.addToLeftArea(this._browser, { rank: 10 });
/*    let contents = this._services.contentsManager;
    contents.newUntitled('', { type: 'notebook' }).then(content => {
      let sessions = this._services.notebookSessionManager;
      sessions.startNew({ notebookPath: content.path }).then(() => {
        this._shell.addToLeftArea(this._browser, { rank: 10 });
      });
    });
*/
    let nbpath = 'test.ipynb'
    
    let sessions = this._services.notebookSessionManager;
    let sessionPromise = sessions.startNew({notebookPath: nbpath});
    this._notebook.createNotebook(nbpath).then(nb => {
      nb.title.text = nbpath;
      this._shell.addToMainArea(nb);
    })
    
  }

  private _term: ITerminalProvider = null;
  private _shell: IAppShell = null;
  private _palette: ICommandPalette = null;
  private _registry: ICommandRegistry = null;
  private _browser: FileBrowserWidget = null;
  private _notebook: INotebookProvider = null;
  private _services: IServicesProvider = null;
  private _opener: IFileOpener = null;
}
{'fraction_non_alphanumeric': 0.1260024803637867, 'fraction_numerical': 0.024142207523770155, 'mean_word_length': 3.699300699300699, 'pattern_counts': {'":': 0, '<': 77, '<?xml version=': 0, '>': 93, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6581804', 'n_tokens_mistral': 3890, 'n_tokens_neox': 3668, 'n_words': 836}