本文整理汇总了TypeScript中@jupyterlab/application.ILabShell.add方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ILabShell.add方法的具体用法?TypeScript ILabShell.add怎么用?TypeScript ILabShell.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@jupyterlab/application.ILabShell
的用法示例。
在下文中一共展示了ILabShell.add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: String
execute: (args: JSONObject) => {
const cwd = args['cwd'] ? String(args['cwd']) : '';
const id = `launcher-${Private.id++}`;
const callback = (item: Widget) => {
labShell.add(item, 'main', { ref: id });
};
const launcher = new Launcher({ cwd, callback, commands });
launcher.model = model;
launcher.title.label = 'Launcher';
launcher.title.iconClass = 'jp-LauncherIcon';
let main = new MainAreaWidget({ content: launcher });
// If there are any other widgets open, remove the launcher close icon.
main.title.closable = !!toArray(labShell.widgets('main')).length;
main.id = id;
labShell.add(main, 'main', { activate: args['activate'] as boolean });
labShell.layoutModified.connect(() => {
// If there is only a launcher open, remove the close icon.
main.title.closable = toArray(labShell.widgets('main')).length > 1;
}, main);
return main;
}
示例2: activateBrowser
/**
* Activate the default file browser in the sidebar.
*/
function activateBrowser(
app: JupyterFrontEnd,
factory: IFileBrowserFactory,
docManager: IDocumentManager,
labShell: ILabShell,
restorer: ILayoutRestorer,
settingRegistry: ISettingRegistry
): void {
const browser = factory.defaultBrowser;
const { commands } = app;
// Let the application restorer track the primary file browser (that is
// automatically created) for restoration of application state (e.g. setting
// the file browser as the current side bar widget).
//
// All other file browsers created by using the factory function are
// responsible for their own restoration behavior, if any.
restorer.add(browser, namespace);
addCommands(app, factory, labShell, docManager);
browser.title.iconClass = 'jp-FolderIcon jp-SideBar-tabIcon';
browser.title.caption = 'File Browser';
labShell.add(browser, 'left', { rank: 100 });
// If the layout is a fresh session without saved data, open file browser.
labShell.restored.then(layout => {
if (layout.fresh) {
commands.execute(CommandIDs.showBrowser, void 0);
}
});
Promise.all([app.restored, browser.model.restored]).then(() => {
function maybeCreate() {
// Create a launcher if there are no open items.
if (labShell.isEmpty('main')) {
Private.createLauncher(commands, browser);
}
}
// When layout is modified, create a launcher if there are no open items.
labShell.layoutModified.connect(() => {
maybeCreate();
});
let navigateToCurrentDirectory: boolean = false;
settingRegistry
.load('@jupyterlab/filebrowser-extension:browser')
.then(settings => {
settings.changed.connect(settings => {
navigateToCurrentDirectory = settings.get(
'navigateToCurrentDirectory'
).composite as boolean;
});
navigateToCurrentDirectory = settings.get('navigateToCurrentDirectory')
.composite as boolean;
});
// Whether to automatically navigate to a document's current directory
labShell.currentChanged.connect((_, change) => {
if (navigateToCurrentDirectory && change.newValue) {
const { newValue } = change;
const context = docManager.contextForWidget(newValue);
if (context) {
const { path } = context;
Private.navigateToPath(path, factory)
.then(() => {
labShell.currentWidget.activate();
})
.catch((reason: any) => {
console.warn(
`${CommandIDs.navigate} failed to open: ${path}`,
reason
);
});
}
}
});
maybeCreate();
});
}
示例3:
const callback = (item: Widget) => {
labShell.add(item, 'main', { ref: id });
};