本文整理汇总了TypeScript中@jupyterlab/mainmenu.TabsMenu类的典型用法代码示例。如果您正苦于以下问题:TypeScript TabsMenu类的具体用法?TypeScript TabsMenu怎么用?TypeScript TabsMenu使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TabsMenu类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: createTabsMenu
function createTabsMenu(app: JupyterLab, menu: TabsMenu): void {
const commands = app.commands;
// Add commands for cycling the active tabs.
menu.addGroup([
{ command: 'application:activate-next-tab' },
{ command: 'application:activate-previous-tab' }
], 0);
let tabGroup: Menu.IItemOptions[] = [];
// Utility function to create a command to activate
// a given tab, or get it if it already exists.
const createMenuItem = (widget: Widget): Menu.IItemOptions => {
const commandID = `tabmenu:activate-${widget.id}`;
if (!commands.hasCommand(commandID)) {
commands.addCommand(commandID, {
label: () => widget.title.label,
isVisible: () => !widget.isDisposed,
isEnabled: () => !widget.isDisposed,
isToggled: () => app.shell.currentWidget === widget,
execute: () => app.shell.activateById(widget.id)
});
}
return { command: commandID };
};
app.restored.then(() => {
// Iterate over the current widgets in the
// main area, and add them to the tab group
// of the menu.
const populateTabs = () => {
menu.removeGroup(tabGroup);
tabGroup.length = 0;
each(app.shell.widgets('main'), widget => {
tabGroup.push(createMenuItem(widget));
});
menu.addGroup(tabGroup, 1);
};
populateTabs();
app.shell.layoutModified.connect(() => { populateTabs(); });
});
}
示例2: createTabsMenu
export function createTabsMenu(app: JupyterLab, menu: TabsMenu): void {
const commands = app.commands;
// Add commands for cycling the active tabs.
menu.addGroup(
[
{ command: 'application:activate-next-tab' },
{ command: 'application:activate-previous-tab' },
{ command: CommandIDs.activatePreviouslyUsedTab }
],
0
);
// A list of the active tabs in the main area.
const tabGroup: Menu.IItemOptions[] = [];
// A disposable for getting rid of the out-of-date tabs list.
let disposable: IDisposable;
// Utility function to create a command to activate
// a given tab, or get it if it already exists.
const createMenuItem = (widget: Widget): Menu.IItemOptions => {
const commandID = `tabmenu:activate-${widget.id}`;
if (!commands.hasCommand(commandID)) {
commands.addCommand(commandID, {
label: () => widget.title.label,
isVisible: () => !widget.isDisposed,
isEnabled: () => !widget.isDisposed,
isToggled: () => app.shell.currentWidget === widget,
execute: () => app.shell.activateById(widget.id)
});
}
return { command: commandID };
};
let previousId = '';
// Command to toggle between the current
// tab and the last modified tab.
commands.addCommand(CommandIDs.activatePreviouslyUsedTab, {
label: 'Activate Previously Used Tab',
isEnabled: () => !!previousId,
execute: () =>
previousId && app.commands.execute(`tabmenu:activate-${previousId}`)
});
app.restored.then(() => {
// Iterate over the current widgets in the
// main area, and add them to the tab group
// of the menu.
const populateTabs = () => {
// remove the previous tab list
if (disposable && !disposable.isDisposed) {
disposable.dispose();
}
tabGroup.length = 0;
let isPreviouslyUsedTabAttached = false;
each(app.shell.widgets('main'), widget => {
if (widget.id === previousId) {
isPreviouslyUsedTabAttached = true;
}
tabGroup.push(createMenuItem(widget));
});
disposable = menu.addGroup(tabGroup, 1);
previousId = isPreviouslyUsedTabAttached ? previousId : '';
};
populateTabs();
app.shell.layoutModified.connect(() => {
populateTabs();
});
// Update the id of the previous active tab if
// a new tab is selected.
app.shell.currentChanged.connect((sender, args) => {
let widget = args.oldValue;
if (!widget) {
return;
}
previousId = widget.id;
});
});
}
示例3: createTabsMenu
export function createTabsMenu(
app: JupyterFrontEnd,
menu: TabsMenu,
labShell: ILabShell | null
): void {
const commands = app.commands;
// Add commands for cycling the active tabs.
menu.addGroup(
[
{ command: 'application:activate-next-tab' },
{ command: 'application:activate-previous-tab' },
{ command: CommandIDs.activatePreviouslyUsedTab }
],
0
);
// A list of the active tabs in the main area.
const tabGroup: Menu.IItemOptions[] = [];
// A disposable for getting rid of the out-of-date tabs list.
let disposable: IDisposable;
// Command to activate a widget by id.
commands.addCommand(CommandIDs.activateById, {
label: args => {
const id = args['id'] || '';
const widget = find(app.shell.widgets('main'), w => w.id === id);
return (widget && widget.title.label) || '';
},
isToggled: args => {
const id = args['id'] || '';
return app.shell.currentWidget && app.shell.currentWidget.id === id;
},
execute: args => app.shell.activateById((args['id'] as string) || '')
});
let previousId = '';
// Command to toggle between the current
// tab and the last modified tab.
commands.addCommand(CommandIDs.activatePreviouslyUsedTab, {
label: 'Activate Previously Used Tab',
isEnabled: () => !!previousId,
execute: () => commands.execute(CommandIDs.activateById, { id: previousId })
});
if (labShell) {
app.restored.then(() => {
// Iterate over the current widgets in the
// main area, and add them to the tab group
// of the menu.
const populateTabs = () => {
// remove the previous tab list
if (disposable && !disposable.isDisposed) {
disposable.dispose();
}
tabGroup.length = 0;
let isPreviouslyUsedTabAttached = false;
each(app.shell.widgets('main'), widget => {
if (widget.id === previousId) {
isPreviouslyUsedTabAttached = true;
}
tabGroup.push({
command: CommandIDs.activateById,
args: { id: widget.id }
});
});
disposable = menu.addGroup(tabGroup, 1);
previousId = isPreviouslyUsedTabAttached ? previousId : '';
};
populateTabs();
labShell.layoutModified.connect(() => {
populateTabs();
});
// Update the ID of the previous active tab if a new tab is selected.
labShell.currentChanged.connect((_, args) => {
let widget = args.oldValue;
if (!widget) {
return;
}
previousId = widget.id;
});
});
}
}
示例4: each
const populateTabs = () => {
menu.removeGroup(tabGroup);
tabGroup.length = 0;
each(app.shell.widgets('main'), widget => {
tabGroup.push(createMenuItem(widget));
});
menu.addGroup(tabGroup, 1);
};
示例5: each
const populateTabs = () => {
menu.removeGroup(tabGroup);
tabGroup.length = 0;
let isPreviouslyUsedTabAttached = false;
each(app.shell.widgets('main'), widget => {
if (widget.id === previousId) {
isPreviouslyUsedTabAttached = true;
}
tabGroup.push(createMenuItem(widget));
});
menu.addGroup(tabGroup, 1);
previousId = isPreviouslyUsedTabAttached ? previousId : '';
};
示例6: each
const populateTabs = () => {
// remove the previous tab list
if (disposable && !disposable.isDisposed) {
disposable.dispose();
}
tabGroup.length = 0;
let isPreviouslyUsedTabAttached = false;
each(app.shell.widgets('main'), widget => {
if (widget.id === previousId) {
isPreviouslyUsedTabAttached = true;
}
tabGroup.push(createMenuItem(widget));
});
disposable = menu.addGroup(tabGroup, 1);
previousId = isPreviouslyUsedTabAttached ? previousId : '';
};
示例7: each
const populateTabs = () => {
// remove the previous tab list
if (disposable && !disposable.isDisposed) {
disposable.dispose();
}
tabGroup.length = 0;
let isPreviouslyUsedTabAttached = false;
each(app.shell.widgets('main'), widget => {
if (widget.id === previousId) {
isPreviouslyUsedTabAttached = true;
}
tabGroup.push({
command: CommandIDs.activateById,
args: { id: widget.id }
});
});
disposable = menu.addGroup(tabGroup, 1);
previousId = isPreviouslyUsedTabAttached ? previousId : '';
};