当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript TabsMenu.addGroup方法代码示例

本文整理汇总了TypeScript中@jupyterlab/mainmenu.TabsMenu.addGroup方法的典型用法代码示例。如果您正苦于以下问题:TypeScript TabsMenu.addGroup方法的具体用法?TypeScript TabsMenu.addGroup怎么用?TypeScript TabsMenu.addGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@jupyterlab/mainmenu.TabsMenu的用法示例。


在下文中一共展示了TabsMenu.addGroup方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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


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