本文整理汇总了TypeScript中@jupyterlab/apputils.InstanceTracker.add方法的典型用法代码示例。如果您正苦于以下问题:TypeScript InstanceTracker.add方法的具体用法?TypeScript InstanceTracker.add怎么用?TypeScript InstanceTracker.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@jupyterlab/apputils.InstanceTracker
的用法示例。
在下文中一共展示了InstanceTracker.add方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
.then(session => {
term.session = session;
void tracker.add(main);
app.shell.activateById(main.id);
return main;
})
示例2: activateFactory
/**
* Activate the file browser factory provider.
*/
function activateFactory(app: JupyterLab, docManager: IDocumentManager, state: IStateDB): IFileBrowserFactory {
const { commands, shell } = app;
const tracker = new InstanceTracker<FileBrowser>({ namespace, shell });
return {
createFileBrowser(id: string, options: IFileBrowserFactory.IOptions = {}): FileBrowser {
const model = new FileBrowserModel({
manager: options.documentManager || docManager,
state: options.state === null ? null : options.state || state
});
const widget = new FileBrowser({
id, model, commands: options.commands || commands
});
const { registry } = docManager;
// Add a context menu handler to the file browser's directory listing.
let node = widget.node.getElementsByClassName('jp-DirListing-content')[0];
node.addEventListener('contextmenu', (event: MouseEvent) => {
event.preventDefault();
const path = widget.pathForClick(event) || '';
const menu = createContextMenu(path, commands, registry);
menu.open(event.clientX, event.clientY);
});
// Track the newly created file browser.
tracker.add(widget);
return widget;
},
tracker
};
}
示例3:
return promise.then(session => {
term.session = session;
tracker.add(main);
shell.activateById(main.id);
return main;
}).catch(() => { term.dispose(); });
示例4: catch
execute: async args => {
// wait for the widget to lazy load
let Terminal: typeof WidgetModuleType.Terminal;
try {
Terminal = (await Private.ensureWidget()).Terminal;
} catch (err) {
Private.showErrorMessage(err);
}
const name = args['name'] as string;
const term = new Terminal();
term.title.icon = TERMINAL_ICON_CLASS;
term.title.label = '...';
let main = new MainAreaWidget({ content: term });
app.shell.add(main);
try {
term.session = await (name
? serviceManager.terminals
.connectTo(name)
.catch(() => serviceManager.terminals.startNew())
: serviceManager.terminals.startNew());
void tracker.add(main);
app.shell.activateById(main.id);
return main;
} catch {
term.dispose();
}
}
示例5:
factory.widgetCreated.connect((sender, widget) => {
Private.factoryNameProperty.set(widget, factory.name);
// Notify the instance tracker if restore data needs to update.
widget.context.pathChanged.connect(() => {
void tracker.save(widget);
});
void tracker.add(widget);
});
示例6: openInspector
function openInspector(): MainAreaWidget<InspectorPanel> {
if (!inspector || inspector.isDisposed) {
inspector = new MainAreaWidget({ content: new InspectorPanel() });
inspector.id = 'jp-inspector';
inspector.title.label = title;
tracker.add(inspector);
source = source && !source.isDisposed ? source : null;
inspector.content.source = source;
}
if (!inspector.isAttached) {
shell.add(inspector, 'main', { activate: false });
}
shell.activateById(inspector.id);
return inspector;
}
示例7: newInspectorPanel
/**
* Create and track a new inspector.
*/
function newInspectorPanel(): InspectorPanel {
const inspector = new InspectorPanel();
inspector.id = 'jp-inspector';
inspector.title.label = 'Inspector';
inspector.title.closable = true;
inspector.disposed.connect(() => {
if (manager.inspector === inspector) {
manager.inspector = null;
}
});
// Track the inspector.
tracker.add(inspector);
// Add the default inspector child items.
Private.defaultInspectorItems.forEach(item => { inspector.add(item); });
return inspector;
}
示例8: newInspectorPanel
/**
* Create and track a new inspector.
*/
function newInspectorPanel(): InspectorPanel {
const inspector = new InspectorPanel();
inspector.id = 'jp-inspector';
inspector.title.label = 'Inspector';
inspector.disposed.connect(() => {
if (manager.inspector === inspector) {
manager.inspector = null;
}
});
// Track the inspector.
let widget = new MainAreaWidget({ content: inspector });
tracker.add(widget);
// Add the default inspector child items.
Private.defaultInspectorItems.forEach(item => { inspector.add(item); });
return inspector;
}
示例9: SettingEditor
execute: () => {
if (tracker.currentWidget) {
shell.activateById(tracker.currentWidget.id);
return;
}
const key = plugin.id;
const when = app.restored;
const editor = new SettingEditor({
editorFactory, key, registry, state, when
});
tracker.add(editor);
editor.id = namespace;
editor.title.label = 'Settings';
editor.title.iconClass = 'jp-SettingsIcon';
editor.title.closable = true;
shell.addToMainArea(editor);
shell.activateById(editor.id);
},
示例10: activateFactory
/**
* Activate the file browser factory provider.
*/
function activateFactory(app: JupyterLab, serviceManager: IServiceManager, documentManager: IDocumentManager, state: IStateDB): IFileBrowserFactory {
const { commands, shell } = app;
const tracker = new InstanceTracker<FileBrowser>({ namespace, shell });
return {
createFileBrowser(id: string, options: IFileBrowserFactory.IOptions = {}): FileBrowser {
const widget = new FileBrowser({
commands: options.commands || commands,
id: id,
manager: options.documentManager || documentManager,
model: new FileBrowserModel({
manager: options.serviceManager || serviceManager,
state: options.state === null ? null : options.state || state
})
});
tracker.add(widget);
return widget;
}
};
}