Skip to content

JLab Output displayed trigger #1738

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"@types/lodash": "^4.14.66",
"@types/semver": "^5.3.30",
"backbone": "1.2.3",
"base64-js": "^1.2.1",
"jquery": "^3.1.1",
"lodash": "^4.17.4",
"semver": "^5.1.0"
Expand Down
1 change: 1 addition & 0 deletions packages/controls/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"@phosphor/algorithm": "^1.1.0",
"@phosphor/domutils": "^1.1.0",
"@phosphor/messaging": "^1.2.0",
"@phosphor/signaling": "^1.2.0",
"@phosphor/widgets": "^1.2.0",
"@types/backbone": "^1.3.33",
"@types/semver": "^5.3.30",
Expand Down
61 changes: 49 additions & 12 deletions packages/jupyterlab-manager/src/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@

import * as outputBase from '@jupyter-widgets/output';

import {
DOMWidgetView, JupyterPhosphorWidget
} from '@jupyter-widgets/base';

import {
IDisposable
} from '@phosphor/disposable';

import {
Message
} from '@phosphor/messaging';

import {
Panel, Widget
} from '@phosphor/widgets';
Expand Down Expand Up @@ -100,13 +108,51 @@ class OutputModel extends outputBase.OutputModel {
private _outputs: OutputAreaModel;
}

export
class JupyterPhosphorPanelWidget extends Panel {
constructor(options: JupyterPhosphorWidget.IOptions & Panel.IOptions) {
let view = options.view;
delete options.view;
super(options);
this._view = view;
}

/**
* Process the phosphor message.
*
* Any custom phosphor widget used inside a Jupyter widget should override
* the processMessage function like this.
*/
processMessage(msg: Message) {
super.processMessage(msg);
this._view.processPhosphorMessage(msg);
}

/**
* Dispose the widget.
*
* This causes the view to be destroyed as well with 'remove'
*/
dispose() {
if (this.isDisposed) {
return;
}
super.dispose();
if (this._view) {
this._view.remove();
}
this._view = null;
}

private _view: DOMWidgetView;
}

export
class OutputView extends outputBase.OutputView {

_createElement(tagName: string) {
this.pWidget = new Panel();
return this.pWidget.node;
this.pWidget = new JupyterPhosphorPanelWidget({ view: this });
return this.pWidget.node;
}

_setElement(el: HTMLElement) {
Expand All @@ -123,6 +169,7 @@ class OutputView extends outputBase.OutputView {
* Called when view is rendered.
*/
render() {
super.render();
this._outputView = new OutputArea({
rendermime: this.model.widget_manager.rendermime,
contentFactory: OutputArea.defaultContentFactory,
Expand All @@ -139,16 +186,6 @@ class OutputView extends outputBase.OutputView {
this.update(); // Set defaults.
}

/**
* Update the contents of this view
*
* Called when the model is changed. The model may have been
* changed by another view or by a state update from the back-end.
*/
update() {
return super.update();
}

remove() {
this._outputView.dispose();
return super.remove();
Expand Down