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


TypeScript InstanceTracker.add方法代码示例

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


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

示例1:

        .then(session => {
          term.session = session;
          void tracker.add(main);
          app.shell.activateById(main.id);

          return main;
        })
开发者ID:alexmorley,项目名称:jupyterlab,代码行数:7,代码来源:index.ts

示例2: activateFactory

/**
 * Activate the file browser factory provider.
 */
function activateFactory(app: JupyterLab, docManager: IDocumentManager, state: IStateDB): IFileBrowserFactory {
  const { commands, shell } = app;
  const tracker = new InstanceTracker<FileBrowser>({ namespace, shell });

  return {
    createFileBrowser(id: string, options: IFileBrowserFactory.IOptions = {}): FileBrowser {
      const model = new FileBrowserModel({
        manager: options.documentManager || docManager,
        state: options.state === null ? null : options.state || state
      });
      const widget = new FileBrowser({
        id, model, commands: options.commands || commands
      });
      const { registry } = docManager;

      // Add a context menu handler to the file browser's directory listing.
      let node = widget.node.getElementsByClassName('jp-DirListing-content')[0];
      node.addEventListener('contextmenu', (event: MouseEvent) => {
        event.preventDefault();
        const path = widget.pathForClick(event) || '';
        const menu = createContextMenu(path, commands, registry);
        menu.open(event.clientX, event.clientY);
      });

      // Track the newly created file browser.
      tracker.add(widget);

      return widget;
    },
    tracker
  };
}
开发者ID:eskirk,项目名称:jupyterlab,代码行数:35,代码来源:index.ts

示例3:

      return promise.then(session => {
        term.session = session;
        tracker.add(main);
        shell.activateById(main.id);

        return main;
      }).catch(() => { term.dispose(); });
开发者ID:cfsmile,项目名称:jupyterlab,代码行数:7,代码来源:index.ts

示例4: catch

    execute: async args => {
      // wait for the widget to lazy load
      let Terminal: typeof WidgetModuleType.Terminal;
      try {
        Terminal = (await Private.ensureWidget()).Terminal;
      } catch (err) {
        Private.showErrorMessage(err);
      }

      const name = args['name'] as string;
      const term = new Terminal();

      term.title.icon = TERMINAL_ICON_CLASS;
      term.title.label = '...';
      let main = new MainAreaWidget({ content: term });
      app.shell.add(main);

      try {
        term.session = await (name
          ? serviceManager.terminals
              .connectTo(name)
              .catch(() => serviceManager.terminals.startNew())
          : serviceManager.terminals.startNew());

        void tracker.add(main);
        app.shell.activateById(main.id);

        return main;
      } catch {
        term.dispose();
      }
    }
开发者ID:jupyter,项目名称:jupyterlab,代码行数:32,代码来源:index.ts

示例5:

 factory.widgetCreated.connect((sender, widget) => {
   Private.factoryNameProperty.set(widget, factory.name);
   // Notify the instance tracker if restore data needs to update.
   widget.context.pathChanged.connect(() => {
     void tracker.save(widget);
   });
   void tracker.add(widget);
 });
开发者ID:afshin,项目名称:jupyterlab,代码行数:8,代码来源:mimerenderers.ts

示例6: openInspector

 function openInspector(): MainAreaWidget<InspectorPanel> {
   if (!inspector || inspector.isDisposed) {
     inspector = new MainAreaWidget({ content: new InspectorPanel() });
     inspector.id = 'jp-inspector';
     inspector.title.label = title;
     tracker.add(inspector);
     source = source && !source.isDisposed ? source : null;
     inspector.content.source = source;
   }
   if (!inspector.isAttached) {
     shell.add(inspector, 'main', { activate: false });
   }
   shell.activateById(inspector.id);
   return inspector;
 }
开发者ID:ellisonbg,项目名称:jupyterlab,代码行数:15,代码来源:index.ts

示例7: newInspectorPanel

    /**
     * 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;
    }
开发者ID:7125messi,项目名称:jupyterlab,代码行数:23,代码来源:index.ts

示例8: newInspectorPanel

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

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

      // Track the inspector.
      let widget = new MainAreaWidget({ content: inspector });
      tracker.add(widget);

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

      return inspector;
    }
开发者ID:cfsmile,项目名称:jupyterlab,代码行数:23,代码来源:index.ts

示例9: SettingEditor

      execute: () => {
        if (tracker.currentWidget) {
          shell.activateById(tracker.currentWidget.id);
          return;
        }

        const key = plugin.id;
        const when = app.restored;
        const editor = new SettingEditor({
          editorFactory, key, registry, state, when
        });

        tracker.add(editor);
        editor.id = namespace;
        editor.title.label = 'Settings';
        editor.title.iconClass = 'jp-SettingsIcon';
        editor.title.closable = true;
        shell.addToMainArea(editor);
        shell.activateById(editor.id);
      },
开发者ID:cameronoelsen,项目名称:jupyterlab,代码行数:20,代码来源:index.ts

示例10: activateFactory

/**
 * Activate the file browser factory provider.
 */
function activateFactory(app: JupyterLab, serviceManager: IServiceManager, documentManager: IDocumentManager, state: IStateDB): IFileBrowserFactory {
  const { commands, shell } = app;
  const tracker = new InstanceTracker<FileBrowser>({ namespace, shell });

  return {
    createFileBrowser(id: string, options: IFileBrowserFactory.IOptions = {}): FileBrowser {
      const widget = new FileBrowser({
        commands: options.commands || commands,
        id: id,
        manager: options.documentManager || documentManager,
        model: new FileBrowserModel({
          manager: options.serviceManager || serviceManager,
          state: options.state === null ? null : options.state || state
        })
      });

      tracker.add(widget);
      return widget;
    }
  };
}
开发者ID:samvasko,项目名称:jupyterlab,代码行数:24,代码来源:index.ts


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