本文整理匯總了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;
}
};
}