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


TypeScript mainmenu.MainMenu类代码示例

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


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

示例1: describe

  describe('MainMenu', () => {
    let commands: CommandRegistry;
    let mainMenu: MainMenu;

    before(() => {
      commands = new CommandRegistry();
    });

    beforeEach(() => {
      mainMenu = new MainMenu(commands);
    });

    afterEach(() => {
      mainMenu.dispose();
    });

    describe('#constructor()', () => {
      it('should construct a new main menu', () => {
        const menu = new MainMenu(new CommandRegistry());
        expect(menu).to.be.an.instanceof(MainMenu);
      });
    });

    describe('#addMenu()', () => {
      it('should add a new menu', () => {
        const menu = new Menu({ commands });
        mainMenu.addMenu(menu);
        expect(find(mainMenu.menus, m => menu === m) !== undefined).to.equal(
          true
        );
      });

      it('should take a rank as an option', () => {
        const menu1 = new Menu({ commands });
        const menu2 = new Menu({ commands });
        mainMenu.addMenu(menu1, { rank: 300 });
        mainMenu.addMenu(menu2, { rank: 200 });
        expect(ArrayExt.firstIndexOf(mainMenu.menus, menu1)).to.equal(6);
        expect(ArrayExt.firstIndexOf(mainMenu.menus, menu2)).to.equal(5);
      });
    });

    describe('#fileMenu', () => {
      it('should be a FileMenu', () => {
        expect(mainMenu.fileMenu).to.be.an.instanceof(FileMenu);
      });

      it('should be the first menu', () => {
        expect(
          ArrayExt.firstIndexOf(mainMenu.menus, mainMenu.fileMenu.menu)
        ).to.equal(0);
      });
    });

    describe('#editMenu', () => {
      it('should be a EditMenu', () => {
        expect(mainMenu.editMenu).to.be.an.instanceof(EditMenu);
      });

      it('should be the second menu', () => {
        expect(
          ArrayExt.firstIndexOf(mainMenu.menus, mainMenu.editMenu.menu)
        ).to.equal(1);
      });
    });

    describe('#viewMenu', () => {
      it('should be a ViewMenu', () => {
        expect(mainMenu.viewMenu).to.be.an.instanceof(ViewMenu);
      });

      it('should be the third menu', () => {
        expect(
          ArrayExt.firstIndexOf(mainMenu.menus, mainMenu.viewMenu.menu)
        ).to.equal(2);
      });
    });

    describe('#runMenu', () => {
      it('should be a RunMenu', () => {
        expect(mainMenu.runMenu).to.be.an.instanceof(RunMenu);
      });

      it('should be the fourth menu', () => {
        expect(
          ArrayExt.firstIndexOf(mainMenu.menus, mainMenu.runMenu.menu)
        ).to.equal(3);
      });
    });

    describe('#kernelMenu', () => {
      it('should be a KernelMenu', () => {
        expect(mainMenu.kernelMenu).to.be.an.instanceof(KernelMenu);
      });

      it('should be the fifth menu', () => {
        expect(
          ArrayExt.firstIndexOf(mainMenu.menus, mainMenu.kernelMenu.menu)
        ).to.equal(4);
      });
//.........这里部分代码省略.........
开发者ID:willingc,项目名称:jupyterlab,代码行数:101,代码来源:mainmenu.spec.ts

示例2: MainMenu

  activate: (
    app: JupyterFrontEnd,
    palette: ICommandPalette,
    inspector: IInspector | null,
    labShell: ILabShell | null
  ): IMainMenu => {
    const { commands } = app;

    let menu = new MainMenu(commands);
    menu.id = 'jp-MainMenu';

    let logo = new Widget();
    logo.addClass('jp-MainAreaPortraitIcon');
    logo.addClass('jp-JupyterIcon');
    logo.id = 'jp-MainLogo';

    // Only add quit button if the back-end supports it by checking page config.
    let quitButton = PageConfig.getOption('quitButton');
    menu.fileMenu.quitEntry = quitButton === 'True';

    // Create the application menus.
    createEditMenu(app, menu.editMenu);
    createFileMenu(app, menu.fileMenu, inspector);
    createKernelMenu(app, menu.kernelMenu);
    createRunMenu(app, menu.runMenu);
    createSettingsMenu(app, menu.settingsMenu);
    createViewMenu(app, menu.viewMenu);

    // The tabs menu relies on lab shell functionality.
    if (labShell) {
      createTabsMenu(app, menu.tabsMenu, labShell);
    }

    // Create commands to open the main application menus.
    const activateMenu = (item: Menu) => {
      menu.activeMenu = item;
      menu.openActiveMenu();
    };

    commands.addCommand(CommandIDs.openEdit, {
      label: 'Open Edit Menu',
      execute: () => activateMenu(menu.editMenu.menu)
    });
    commands.addCommand(CommandIDs.openFile, {
      label: 'Open File Menu',
      execute: () => activateMenu(menu.fileMenu.menu)
    });
    commands.addCommand(CommandIDs.openKernel, {
      label: 'Open Kernel Menu',
      execute: () => activateMenu(menu.kernelMenu.menu)
    });
    commands.addCommand(CommandIDs.openRun, {
      label: 'Open Run Menu',
      execute: () => activateMenu(menu.runMenu.menu)
    });
    commands.addCommand(CommandIDs.openView, {
      label: 'Open View Menu',
      execute: () => activateMenu(menu.viewMenu.menu)
    });
    commands.addCommand(CommandIDs.openSettings, {
      label: 'Open Settings Menu',
      execute: () => activateMenu(menu.settingsMenu.menu)
    });
    commands.addCommand(CommandIDs.openTabs, {
      label: 'Open Tabs Menu',
      execute: () => activateMenu(menu.tabsMenu.menu)
    });
    commands.addCommand(CommandIDs.openHelp, {
      label: 'Open Help Menu',
      execute: () => activateMenu(menu.helpMenu.menu)
    });
    commands.addCommand(CommandIDs.openFirst, {
      label: 'Open First Menu',
      execute: () => {
        menu.activeIndex = 0;
        menu.openActiveMenu();
      }
    });

    // Add some of the commands defined here to the command palette.
    if (menu.fileMenu.quitEntry) {
      palette.addItem({
        command: CommandIDs.quit,
        category: 'Main Area'
      });
    }

    palette.addItem({
      command: CommandIDs.shutdownAllKernels,
      category: 'Kernel Operations'
    });

    palette.addItem({
      command: CommandIDs.activatePreviouslyUsedTab,
      category: 'Main Area'
    });

    app.shell.add(logo, 'top');
    app.shell.add(menu, 'top');

//.........这里部分代码省略.........
开发者ID:ellisonbg,项目名称:jupyterlab,代码行数:101,代码来源:index.ts

示例3: it

 it('should take a rank as an option', () => {
   const menu1 = new Menu({ commands });
   const menu2 = new Menu({ commands });
   mainMenu.addMenu(menu1, { rank: 300 });
   mainMenu.addMenu(menu2, { rank: 200 });
   expect(ArrayExt.firstIndexOf(mainMenu.menus, menu1)).to.equal(6);
   expect(ArrayExt.firstIndexOf(mainMenu.menus, menu2)).to.equal(5);
 });
开发者ID:willingc,项目名称:jupyterlab,代码行数:8,代码来源:mainmenu.spec.ts

示例4: afterEach

 afterEach(() => {
   mainMenu.dispose();
 });
开发者ID:willingc,项目名称:jupyterlab,代码行数:3,代码来源:mainmenu.spec.ts

示例5:

 execute: () => {
   menu.activeIndex = 0;
   menu.openActiveMenu();
 }
开发者ID:ellisonbg,项目名称:jupyterlab,代码行数:4,代码来源:index.ts


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