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