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


TypeScript ICommandPalette.addItem方法代码示例

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


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

示例1: MainMenu

  activate: (app: JupyterLab, palette: ICommandPalette): IMainMenu => {
    let menu = new MainMenu(app.commands);
    menu.id = 'jp-MainMenu';

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

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

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

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

    app.shell.addToTopArea(logo);
    app.shell.addToTopArea(menu);

    return menu;
  }
开发者ID:dalejung,项目名称:jupyterlab,代码行数:33,代码来源:index.ts

示例2: addCommands

/**
 * Add the main application commands.
 */
function addCommands(app: JupyterLab, palette: ICommandPalette): void {
  const category = 'Main Area';
  let command = CommandIDs.activateNextTab;
  app.commands.addCommand(command, {
    label: 'Activate Next Tab',
    execute: () => { app.shell.activateNextTab(); }
  });
  palette.addItem({ command, category });

  command = CommandIDs.activatePreviousTab;
  app.commands.addCommand(command, {
    label: 'Activate Previous Tab',
    execute: () => { app.shell.activatePreviousTab(); }
  });
  palette.addItem({ command, category });

  command = CommandIDs.closeAll;
  app.commands.addCommand(command, {
    label: 'Close All Widgets',
    execute: () => { app.shell.closeAll(); }
  });
  palette.addItem({ command, category });

  command = CommandIDs.setMode;
  app.commands.addCommand(command, {
    isVisible: args => {
      const mode = args['mode'] as string;
      return mode === 'single-document' || mode === 'multiple-document';
    },
    execute: args => {
      const mode = args['mode'] as string;
      if (mode === 'single-document' || mode === 'multiple-document') {
        app.shell.mode = mode;
        return;
      }
      throw new Error(`Unsupported application shell mode: ${mode}`);
    }
  });

  command = CommandIDs.toggleMode;
  app.commands.addCommand(command, {
    label: 'Toggle Single-Document Mode',
    execute: () => {
      const args = app.shell.mode === 'multiple-document' ?
        { mode: 'single-document' } : { mode: 'multiple-document' };
      return app.commands.execute(CommandIDs.setMode, args);
    }
  });
  palette.addItem({ command, category });
}
开发者ID:cameronoelsen,项目名称:jupyterlab,代码行数:53,代码来源:index.ts

示例3: activate

/**
 * Activate the launcher.
 */
function activate(app: JupyterLab, services: IServiceManager, palette: ICommandPalette, linker: ICommandLinker, restorer: ILayoutRestorer): ILauncher {
  const { commands, shell } = app;

  let model = new LauncherModel();
  let widget = new LauncherWidget({ linker });

  widget.model = model;
  widget.id = 'launcher';
  widget.title.label = 'Launcher';

  // Let the application restorer track the launcher for restoration of
  // application state (e.g. setting the launcher as the current side bar
  // widget).
  restorer.add(widget, 'launcher');

  commands.addCommand(CommandIDs.show, {
    label: 'Show Launcher',
    execute: () => {
      if (!widget.isAttached) {
        shell.addToLeftArea(widget);
      }
      shell.activateById(widget.id);
    }
  });
  palette.addItem({ command: CommandIDs.show, category: 'Help' });

  shell.addToLeftArea(widget);

  return model;
}
开发者ID:charnpreetsingh185,项目名称:jupyterlab,代码行数:33,代码来源:index.ts

示例4: activate

/**
 * Activate the launcher.
 */
function activate(app: JupyterLab, palette: ICommandPalette): ILauncher {
  const { commands, shell } = app;

  let model = new LauncherModel();

  commands.addCommand(CommandIDs.create, {
    label: 'New Launcher',
    execute: (args: JSONObject) => {
      let cwd = args['cwd'] ? String(args['cwd']) : '';
      let id = `launcher-${Private.id++}`;
      let callback = (item: Widget) => {
        shell.addToMainArea(item, { ref: id });
        shell.activateById(item.id);
      };
      let widget = new Launcher({ cwd, callback });
      widget.model = model;
      widget.id = id;
      widget.title.label = 'Launcher';
      widget.title.iconClass = 'jp-LauncherIcon';
      widget.title.closable = true;
      shell.addToMainArea(widget);
      if (args['activate'] !== false) {
        shell.activateById(widget.id);
      }
    }
  });

  palette.addItem({ command: CommandIDs.create, category: 'Launcher'});

  return model;
}
开发者ID:cameronoelsen,项目名称:jupyterlab,代码行数:34,代码来源:index.ts

示例5: InspectorManager

  activate: (app: JupyterLab, palette: ICommandPalette, restorer: ILayoutRestorer): IInspector => {
    const { commands, shell } = app;
    const manager = new InspectorManager();
    const category = 'Inspector';
    const command = CommandIDs.open;
    const label = 'Open Inspector';
    const tracker = new InstanceTracker<InspectorPanel>({
      namespace: 'inspector',
      shell
    });

    /**
     * Create and track a new inspector.
     */
    function newInspectorPanel(): InspectorPanel {
      const inspector = new InspectorPanel();

      inspector.id = 'jp-inspector';
      inspector.title.label = 'Inspector';
      inspector.title.closable = true;
      inspector.disposed.connect(() => {
        if (manager.inspector === inspector) {
          manager.inspector = null;
        }
      });

      // Track the inspector.
      tracker.add(inspector);

      // Add the default inspector child items.
      Private.defaultInspectorItems.forEach(item => { inspector.add(item); });

      return inspector;
    }

    // Handle state restoration.
    restorer.restore(tracker, {
      command,
      args: () => null,
      name: () => 'inspector'
    });

    // Add command to registry and palette.
    commands.addCommand(command, {
      label,
      execute: () => {
        if (!manager.inspector || manager.inspector.isDisposed) {
          manager.inspector = newInspectorPanel();
          shell.addToMainArea(manager.inspector);
        }
        if (manager.inspector.isAttached) {
          tracker.activate(manager.inspector);
        }
      }
    });
    palette.addItem({ command, category });

    return manager;
  }
开发者ID:samvasko,项目名称:jupyterlab,代码行数:59,代码来源:index.ts

示例6:

 EXPORT_TO_FORMATS.forEach(exportToFormat => {
   let args = {
     format: exportToFormat['format'],
     label: exportToFormat['label'],
     isPalette: true
   };
   palette.addItem({ command: CommandIDs.exportToFormat, category, args });
 });
开发者ID:dalejung,项目名称:jupyterlab,代码行数:8,代码来源:index.ts

示例7: each

 each(registry.creators(), creator => {
   const command = CommandIDs.createFrom;
   const creatorName = creator.name;
   const label = `New ${creatorName}`;
   const args = { creatorName, label };
   menu.insertItem(0, { args, command });
   Private.creators.add(palette.addItem({ args, category, command }));
 });
开发者ID:charnpreetsingh185,项目名称:jupyterlab,代码行数:8,代码来源:index.ts

示例8: DisposableSet

 let addCreator = (name: string) => {
   let disposables = creatorCmds[name] = new DisposableSet();
   let command = Private.commandForName(name);
   disposables.add(commands.addCommand(command, {
     execute: () => fbWidget.createFrom(name),
     label: `New ${name}`
   }));
   disposables.add(palette.addItem({ command, category }));
 };
开发者ID:samvasko,项目名称:jupyterlab,代码行数:9,代码来源:index.ts

示例9: activate

/* tslint:enable */

/**
 * Activate the FAQ plugin.
 */
function activate(
  app: JupyterFrontEnd,
  rendermime: IRenderMimeRegistry,
  palette: ICommandPalette | null,
  restorer: ILayoutRestorer | null
): void {
  const category = 'Help';
  const command = CommandIDs.open;
  const { commands, shell } = app;
  const tracker = new InstanceTracker<MainAreaWidget>({ namespace: 'faq' });

  // Handle state restoration.
  if (restorer) {
    restorer.restore(tracker, {
      command,
      args: () => JSONExt.emptyObject,
      name: () => 'faq'
    });
  }

  let createWidget = () => {
    let content = rendermime.createRenderer('text/markdown');
    const model = rendermime.createModel({
      data: { 'text/markdown': SOURCE }
    });
    void content.renderModel(model);
    content.addClass('jp-FAQ-content');
    let widget = new MainAreaWidget({ content });
    widget.addClass('jp-FAQ');
    widget.title.label = 'FAQ';
    return widget;
  };

  let widget: MainAreaWidget;

  commands.addCommand(command, {
    label: 'Open FAQ',
    execute: () => {
      if (!widget || widget.isDisposed) {
        widget = createWidget();
      }
      if (!tracker.has(widget)) {
        void tracker.add(widget);
        shell.add(widget, 'main', { activate: false });
      }
      shell.activateById(widget.id);
    }
  });

  if (palette) {
    palette.addItem({ command, category });
  }
}
开发者ID:afshin,项目名称:jupyterlab,代码行数:58,代码来源:index.ts

示例10: activate

/**
 * Activate the landing plugin.
 */
function activate(app: JupyterLab, linker: ICommandLinker, palette: ICommandPalette, services: IServiceManager, restorer: ILayoutRestorer): void {
  const { commands, shell } = app;
  const category = 'Help';
  const command = CommandIDs.open;
  const model = new LandingModel(services.terminals.isAvailable());
  const tracker = new InstanceTracker<LandingWidget>({
    namespace: 'landing',
    shell
  });

  // Handle state restoration.
  restorer.restore(tracker, {
    command,
    args: () => null,
    name: () => 'landing'
  });

  let widget: LandingWidget;

  function newWidget(): LandingWidget {
    let widget = new LandingWidget(linker);
    widget.model = model;
    widget.id = 'landing-jupyterlab';
    widget.title.label = 'Landing';
    widget.title.closable = true;
    widget.addClass(LANDING_CLASS);
    tracker.add(widget);
    return widget;
  }

  commands.addCommand(command, {
    label: 'Open Landing',
    execute: () => {
      if (!widget || widget.isDisposed) {
        widget = newWidget();
        shell.addToMainArea(widget);
      }
      tracker.activate(widget);
    }
  });

  palette.addItem({ category, command });

  // Only create a landing page if there are no other tabs open.
  app.restored.then(() => {
    if (shell.isEmpty('main')) {
      commands.execute(command, void 0);
    }
  });
}
开发者ID:charnpreetsingh185,项目名称:jupyterlab,代码行数:53,代码来源:index.ts


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