Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Improve context handling#4453

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ian-r-rose merged 66 commits intojupyterlab:masterfromjasongrout:context
May 25, 2018
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
66 commits
Select commitHold shift + click to select a range
7a5bd00
WIP context cleanups
jasongroutApr 23, 2018
78df852
Handle paths having multiple contexts.
jasongroutApr 24, 2018
db40067
Some new docs about how JupyterLab deals with documents.
jasongroutApr 25, 2018
1e298d7
WIP
jasongroutApr 26, 2018
2e93f83
WIP
jasongroutApr 27, 2018
9c7c4a8
WIP
jasongroutApr 28, 2018
92d58d0
Revert back to original widget creation workflow, but insist we get b…
jasongroutMay 7, 2018
3816766
WIP for MimeDocument widget
jasongroutMay 9, 2018
6ede2da
WIP trying out an idea for a mime document renderer, pushing most log…
jasongroutMay 10, 2018
0ff19f6
WIP converting code to use IDocumentWidget
jasongroutMay 10, 2018
4aa4de6
Fix all compilation errors dealing with the move to IDocumentWidget.
jasongroutMay 10, 2018
58a7a4b
Fix lint errors
jasongroutMay 11, 2018
3fc6bde
WIP: Fix some tests, skip others while we are evaluating this approach.
jasongroutMay 11, 2018
1107f69
Create a specialized MimeDocument document widget type.
jasongroutMay 12, 2018
12dfc8e
Delay a document widget from being ready until the context is ready.
jasongroutMay 12, 2018
af12ced
Use the ABCWidgetFactory type parameter defaults where we can to simp…
jasongroutMay 12, 2018
55f8b32
Convert the notebook to use DocumentWidget
jasongroutMay 12, 2018
631d0e1
Move notebook content generation to the widget factory.
jasongroutMay 13, 2018
8b3b7e1
Remove image viewer toolbar-lookalike css.
jasongroutMay 13, 2018
db7fc2d
Move dirty state handling to the document widget.
jasongroutMay 13, 2018
c90b59b
Get rid of double toolbars in file editor and mime document.
jasongroutMay 13, 2018
c3496d1
Switch SingletonLayout workaround from panel layout to box layout for…
jasongroutMay 13, 2018
f7b03da
Adjust toolbar height to account for visible widgets.
jasongroutMay 14, 2018
78e85c3
Fix toolbar collapse status based on explicit hiding, rather than cum…
jasongroutMay 14, 2018
b60aaf5
Move csv viewer toolbar over to document widget toolbar.
jasongroutMay 15, 2018
1a6b58d
Delete now-redundant notebook toolbar styling.
jasongroutMay 15, 2018
11ffaaf
Revert part of 7a5bd00ce3df55b85c747d02a00e87c49e3288b4 dealing with …
jasongroutMay 15, 2018
cbb1b6a
Make a CSVDocumentWidget which creates default content and toolbar.
jasongroutMay 15, 2018
6554c24
Fix tests
jasongroutMay 15, 2018
b0a3234
Merge branch 'master' into context
jasongroutMay 15, 2018
5d9d5db
Fix issues with the merge.
jasongroutMay 16, 2018
7ecb3c8
Fix CSV viewer toolbar tests.
jasongroutMay 16, 2018
447ab04
Fix mimedocument tests.
jasongroutMay 16, 2018
ebac5f0
Allow MainAreaWidget ready promises actually be Promise<any> for conv…
jasongroutMay 16, 2018
ae8b29b
Add document widget tests.
jasongroutMay 16, 2018
087d1d9
Fix more tests.
jasongroutMay 16, 2018
0468ec2
WIP notebook tests.
jasongroutMay 17, 2018
ae892b4
More notebook test fixes.
jasongroutMay 17, 2018
ba2802f
Fix more tests, convert many to use async/await.
jasongroutMay 17, 2018
672e843
Add the notebook panel .notebook attribute to ease the transition.
jasongroutMay 17, 2018
57b5c07
Fix integrity failures.
jasongroutMay 17, 2018
99c6c45
Make MainAreaWidget promise resolve *after* the spinner is removed.
jasongroutMay 17, 2018
5a21d5a
When a code editor is created, clear the history after setting the in…
jasongroutMay 17, 2018
7b618ba
Clear the notebook model undo history when the model is set.
jasongroutMay 17, 2018
ec7d693
Move .notebook references to .content
jasongroutMay 17, 2018
d72fd54
Delete the .notebook attribute for notebook panels again.
jasongroutMay 18, 2018
ce1abda
Fix model initialization test.
jasongroutMay 18, 2018
5da4760
path generally will be a stricter criteria than factory name, so matc…
jasongroutMay 18, 2018
64212a6
Initialize a model after the context's first save/revert.
jasongroutMay 18, 2018
5027e9e
Merge remote-tracking branch 'origin/master' into context
jasongroutMay 20, 2018
f12be48
Just use the BoxLayout instead of trying SingletonLayout.
jasongroutMay 20, 2018
7bb239a
Remove comment monologue that is no longer necessary or accurate of t…
jasongroutMay 20, 2018
56e5766
Run notebook panel contentfactory tests.
jasongroutMay 20, 2018
427a67e
Tweak documentation
jasongroutMay 22, 2018
4efcad2
Use StackedLayout instead of BoxLayout for single children.
jasongroutMay 22, 2018
21040a0
Fix review comment issues.
jasongroutMay 23, 2018
bf94b1e
Document the choices around focusing content.
jasongroutMay 23, 2018
d031011
We don’t need the document opener spinner anymore now that the docume…
jasongroutMay 23, 2018
dba0b63
MainAreaWidget attribute name change: ready -> reveal
jasongroutMay 23, 2018
414fd43
Change the main area widget reveal promise to ‘revealed’
jasongroutMay 23, 2018
413f401
Fix the revealed logic for the notebook panel.
jasongroutMay 23, 2018
63c41c1
Clarify logic around `isRevealed` to mean “spinner is gone, either a …
jasongroutMay 23, 2018
3ab6372
Update docs per review comments.
jasongroutMay 24, 2018
6749792
Move signal construction to attribute definition, consistent with the…
jasongroutMay 24, 2018
693810c
Support making the content null.
jasongroutMay 24, 2018
ac907af
Change MainAreaWidget to using the spinner as just a DOM node rather …
jasongroutMay 25, 2018
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
PrevPrevious commit
NextNext commit
WIP converting code to use IDocumentWidget
  • Loading branch information
@jasongrout
jasongrout committedMay 10, 2018
commit0ff19f6366fda8a0bd85f80414596554dd5464bd
3 changes: 2 additions & 1 deletionpackages/csvviewer-extension/package.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,7 +31,8 @@
"dependencies": {
"@jupyterlab/application": "^0.16.2",
"@jupyterlab/apputils": "^0.16.3",
"@jupyterlab/csvviewer": "^0.16.2"
"@jupyterlab/csvviewer": "^0.16.2",
"@jupyterlab/docregistry": "^0.16.2"
},
"devDependencies": {
"rimraf": "~2.6.2",
Expand Down
5 changes: 4 additions & 1 deletionpackages/csvviewer-extension/src/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,6 +13,9 @@ import {
CSVViewer, CSVViewerFactory
} from '@jupyterlab/csvviewer';

import {
IDocumentWidget
} from '@jupyterlab/docregistry';

/**
* The name of the factory that creates CSV widgets.
Expand DownExpand Up@@ -47,7 +50,7 @@ function activate(app: JupyterLab, restorer: ILayoutRestorer): void {
defaultFor: ['csv'],
readOnly: true
});
const tracker = new InstanceTracker<CSVViewer>({ namespace: 'csvviewer' });
const tracker = new InstanceTracker<IDocumentWidget<CSVViewer>>({ namespace: 'csvviewer' });

// Handle state restoration.
restorer.restore(tracker, {
Expand Down
12 changes: 7 additions & 5 deletionspackages/csvviewer/src/widget.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,7 @@ import {
} from '@jupyterlab/coreutils';

import {
ABCWidgetFactory, DocumentRegistry
ABCWidgetFactory, DocumentRegistry, IDocumentWidget, DocumentWidget
} from '@jupyterlab/docregistry';

import {
Expand DownExpand Up@@ -58,7 +58,7 @@ const RENDER_TIMEOUT = 1000;
* A viewer for CSV tables.
*/
export
class CSVViewer extends Widgetimplements DocumentRegistry.IReadyWidget{
class CSVViewer extends Widget {
/**
* Construct a new CSV viewer.
*/
Expand DownExpand Up@@ -186,11 +186,13 @@ namespace CSVViewer {
* A widget factory for CSV widgets.
*/
export
class CSVViewerFactory extends ABCWidgetFactory<CSVViewer, DocumentRegistry.IModel> {
class CSVViewerFactory extends ABCWidgetFactory<IDocumentWidget<CSVViewer>, DocumentRegistry.IModel> {
/**
* Create a new widget given a context.
*/
protected createNewWidget(context: DocumentRegistry.Context): CSVViewer {
return new CSVViewer({ context });
protected createNewWidget(context: DocumentRegistry.Context): IDocumentWidget<CSVViewer> {
const content = new CSVViewer({ context });
const widget = new DocumentWidget({ content, context });
return widget;
}
}
18 changes: 9 additions & 9 deletionspackages/docmanager/src/manager.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,15 +11,15 @@ import {
} from '@jupyterlab/coreutils';

import {
DocumentRegistry, Context
DocumentRegistry, Context, IDocumentWidget
} from '@jupyterlab/docregistry';

import {
Contents, Kernel, ServiceManager
} from '@jupyterlab/services';

import {
ArrayExt, find, filter
ArrayExt, find
} from '@phosphor/algorithm';

import {
Expand DownExpand Up@@ -171,7 +171,7 @@ class DocumentManager implements IDisposable {
* Uses the same widget factory and context as the source, or returns
* `undefined` if the source widget is not managed by this manager.
*/
cloneWidget(widget: Widget):DocumentRegistry.IReadyWidget | undefined {
cloneWidget(widget: Widget):IDocumentWidget | undefined {
return this._widgetManager.cloneWidget(widget);
}

Expand DownExpand Up@@ -275,7 +275,7 @@ class DocumentManager implements IDisposable {
* This can be used to find an existing widget instead of opening
* a new widget.
*/
findWidget(path: string, widgetName='default'):DocumentRegistry.IReadyWidget | undefined {
findWidget(path: string, widgetName='default'):IDocumentWidget | undefined {
if (widgetName === 'default') {
let factory = this.registry.defaultWidgetFactory(path);
if (!factory) {
Expand DownExpand Up@@ -320,7 +320,7 @@ class DocumentManager implements IDisposable {
* This function will return `undefined` if a valid widget factory
* cannot be found.
*/
open(path: string, widgetName='default', kernel?: Partial<Kernel.IModel>, options?: DocumentRegistry.IOpenOptions ):DocumentRegistry.IReadyWidget | undefined {
open(path: string, widgetName='default', kernel?: Partial<Kernel.IModel>, options?: DocumentRegistry.IOpenOptions ):IDocumentWidget | undefined {
return this._createOrOpenDocument('open', path, widgetName, kernel, options);
}

Expand All@@ -340,7 +340,7 @@ class DocumentManager implements IDisposable {
* This function will return `undefined` if a valid widget factory
* cannot be found.
*/
openOrReveal(path: string, widgetName='default', kernel?: Partial<Kernel.IModel>, options?: DocumentRegistry.IOpenOptions ):DocumentRegistry.IReadyWidget | undefined {
openOrReveal(path: string, widgetName='default', kernel?: Partial<Kernel.IModel>, options?: DocumentRegistry.IOpenOptions ):IDocumentWidget | undefined {
let widget = this.findWidget(path, widgetName);
if (widget) {
this._opener.open(widget, options || {});
Expand DownExpand Up@@ -418,7 +418,7 @@ class DocumentManager implements IDisposable {
// widgets that have different models.

// Allow options to be passed when adding a sibling.
let adopter = (widget:DocumentRegistry.IReadyWidget, options?: DocumentRegistry.IOpenOptions) => {
let adopter = (widget:IDocumentWidget, options?: DocumentRegistry.IOpenOptions) => {
this._widgetManager.adoptWidget(context, widget);
this._opener.open(widget, options);
};
Expand DownExpand Up@@ -474,7 +474,7 @@ class DocumentManager implements IDisposable {
* The two cases differ in how the document context is handled, but the creation
* of the widget and launching of the kernel are identical.
*/
private _createOrOpenDocument(which: 'open'|'create', path: string, widgetName='default', kernel?: Partial<Kernel.IModel>, options?: DocumentRegistry.IOpenOptions):DocumentRegistry.IReadyWidget | undefined {
private _createOrOpenDocument(which: 'open'|'create', path: string, widgetName='default', kernel?: Partial<Kernel.IModel>, options?: DocumentRegistry.IOpenOptions):IDocumentWidget | undefined {
let widgetFactory = this._widgetFactoryFor(path, widgetName);
if (!widgetFactory) {
return undefined;
Expand DownExpand Up@@ -574,7 +574,7 @@ namespace DocumentManager {
/**
* Open the given widget.
*/
open(widget:DocumentRegistry.IReadyWidget, options?: DocumentRegistry.IOpenOptions): void;
open(widget:IDocumentWidget, options?: DocumentRegistry.IOpenOptions): void;
}
}

Expand Down
12 changes: 6 additions & 6 deletionspackages/docmanager/src/widgetmanager.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,7 +34,7 @@ import {
} from '@jupyterlab/apputils';

import {
DocumentRegistry
DocumentRegistry, IDocumentWidget
} from '@jupyterlab/docregistry';

import {
Expand DownExpand Up@@ -96,7 +96,7 @@ class DocumentWidgetManager implements IDisposable {
*
* @throws If the factory is not registered.
*/
createWidget(factory: DocumentRegistry.WidgetFactory, context: DocumentRegistry.Context):DocumentRegistry.IReadyWidget {
createWidget(factory: DocumentRegistry.WidgetFactory, context: DocumentRegistry.Context):IDocumentWidget {
let widget = factory.createNew(context);
Private.factoryProperty.set(widget, factory);

Expand DownExpand Up@@ -125,7 +125,7 @@ class DocumentWidgetManager implements IDisposable {
*
* @param widget - The widget to adopt.
*/
adoptWidget(context: DocumentRegistry.Context, widget:DocumentRegistry.IReadyWidget): void {
adoptWidget(context: DocumentRegistry.Context, widget:IDocumentWidget): void {
let widgets = Private.widgetsProperty.get(context);
widgets.push(widget);
MessageLoop.installMessageHook(widget, this);
Expand All@@ -146,7 +146,7 @@ class DocumentWidgetManager implements IDisposable {
* This can be used to use an existing widget instead of opening
* a new widget.
*/
findWidget(context: DocumentRegistry.Context, widgetName: string):DocumentRegistry.IReadyWidget | undefined {
findWidget(context: DocumentRegistry.Context, widgetName: string):IDocumentWidget | undefined {
let widgets = Private.widgetsProperty.get(context);
if (!widgets) {
return undefined;
Expand DownExpand Up@@ -182,7 +182,7 @@ class DocumentWidgetManager implements IDisposable {
* Uses the same widget factory and context as the source, or throws
* if the source widget is not managed by this manager.
*/
cloneWidget(widget: Widget):DocumentRegistry.IReadyWidget | undefined {
cloneWidget(widget: Widget):IDocumentWidget | undefined {
let context = Private.contextProperty.get(widget);
if (!context) {
return undefined;
Expand DownExpand Up@@ -448,7 +448,7 @@ namespace Private {
* A private attached property for the widgets associated with a context.
*/
export
const widgetsProperty = new AttachedProperty<DocumentRegistry.Context,DocumentRegistry.IReadyWidget[]>({
const widgetsProperty = new AttachedProperty<DocumentRegistry.Context,IDocumentWidget[]>({
name: 'widgets',
create: () => []
});
Expand Down
2 changes: 1 addition & 1 deletionpackages/docregistry/src/default.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,7 +22,7 @@ import {
} from '@phosphor/widgets';

import {
Toolbar,MainAreaWidget
MainAreaWidget
} from '@jupyterlab/apputils';

import {
Expand Down
18 changes: 10 additions & 8 deletionspackages/docregistry/src/mimedocument.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,11 +2,11 @@
// Distributed under the terms of the Modified BSD License.

import {
showErrorMessage, MainAreaWidget
showErrorMessage
} from '@jupyterlab/apputils';

import {
ActivityMonitor, PathExt
ActivityMonitor
} from '@jupyterlab/coreutils';

import {
Expand All@@ -22,7 +22,7 @@ import {
} from '@phosphor/messaging';

import {
SingletonLayout, Widget
PanelLayout, Widget
} from '@phosphor/widgets';

import {
Expand DownExpand Up@@ -50,8 +50,10 @@ class MimeContent extends Widget {
this._context = options.context;
this._renderer = options.renderer;

const layout = new SingletonLayout();
layout.widget = this._renderer;
// TODO: Use SingletonLayout when a new version of phosphor is released. See
// https://github.com/phosphorjs/phosphor/issues/337
const layout = new PanelLayout();
layout.addWidget(this._renderer);
this.layout = layout;

this._context.ready.then(() => {
Expand DownExpand Up@@ -186,7 +188,7 @@ namespace MimeContent {
* The options used to initialize a MimeDocument.
*/
export
interface IOptionsextends DocumentWidget.IOptions<IRenderMime.IRenderer>{
interface IOptions {
/**
* Context
*/
Expand DownExpand Up@@ -234,7 +236,7 @@ class MimeDocumentFactory extends ABCWidgetFactory<IDocumentWidget<MimeContent>,
/**
* Create a new widget given a context.
*/
protected createNewWidget(context: DocumentRegistry.Context):MainAreaWidget {
protected createNewWidget(context: DocumentRegistry.Context):IDocumentWidget<MimeContent> {
const ft = this._fileType;
const mimeType = ft.mimeTypes.length ? ft.mimeTypes[0] : 'text/plain';

Expand All@@ -254,7 +256,7 @@ class MimeDocumentFactory extends ABCWidgetFactory<IDocumentWidget<MimeContent>,
content.title.iconClass = ft.iconClass;
content.title.iconLabel = ft.iconLabel;

const widget = new DocumentWidget({content});
const widget = new DocumentWidget({content, context});

return widget;
}
Expand Down
2 changes: 1 addition & 1 deletionpackages/docregistry/src/registry.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1188,7 +1188,7 @@ namespace DocumentRegistry {
export
interface IDocumentWidget<T extends Widget = Widget, U extends DocumentRegistry.IModel = DocumentRegistry.IModel> extends Widget {
readonly content: T;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

These should have inline comments (especially "ready").

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

In documenting this promise, I say "A promise resolving when the content widget is ready to be revealed." Would "reveal" be a better name for the promise than "ready"? When the reveal promise resolves, then we reveal the document widget.

readonlypopulated: Promise<void>;
readonlyready: Promise<void>;
readonly context: DocumentRegistry.IContext<U>;
readonly toolbar: Toolbar<Widget>;
}
Expand Down
1 change: 1 addition & 0 deletionspackages/fileeditor-extension/package.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,6 +35,7 @@
"@jupyterlab/codeeditor": "^0.16.1",
"@jupyterlab/console": "^0.16.2",
"@jupyterlab/coreutils": "^1.1.2",
"@jupyterlab/docregistry": "^0.16.2",
"@jupyterlab/filebrowser": "^0.16.2",
"@jupyterlab/fileeditor": "^0.16.2",
"@jupyterlab/launcher": "^0.16.2",
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp