• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript mainmenu.TabsMenu类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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(); });
  });
}
开发者ID:7125messi,项目名称:jupyterlab,代码行数:44,代码来源:index.ts


示例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;
    });
  });
}
开发者ID:SylvainCorlay,项目名称:jupyterlab,代码行数:81,代码来源:index.ts


示例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;
      });
    });
  }
}
开发者ID:ellisonbg,项目名称:jupyterlab,代码行数:85,代码来源:index.ts


示例4: each

 const populateTabs = () => {
   menu.removeGroup(tabGroup);
   tabGroup.length = 0;
   each(app.shell.widgets('main'), widget => {
     tabGroup.push(createMenuItem(widget));
   });
   menu.addGroup(tabGroup, 1);
 };
开发者ID:7125messi,项目名称:jupyterlab,代码行数:8,代码来源:index.ts


示例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 : '';
 };
开发者ID:groutr,项目名称:jupyterlab,代码行数:13,代码来源:index.ts


示例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 : '';
    };
开发者ID:SylvainCorlay,项目名称:jupyterlab,代码行数:17,代码来源:index.ts


示例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 : '';
      };
开发者ID:ellisonbg,项目名称:jupyterlab,代码行数:20,代码来源:index.ts



注:本文中的@jupyterlab/mainmenu.TabsMenu类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript src.EditMenu类代码示例发布时间:2022-05-28
下一篇:
TypeScript mainmenu.RunMenu类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap