當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。