當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript application.ILabShell類代碼示例

本文整理匯總了TypeScript中@jupyterlab/application.ILabShell的典型用法代碼示例。如果您正苦於以下問題:TypeScript ILabShell類的具體用法?TypeScript ILabShell怎麽用?TypeScript ILabShell使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ILabShell類的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: while

    execute: args => {
      const path = (args.path as string) || '';
      const browserForPath = Private.getBrowserForPath(path, factory);

      // Check for browser not found
      if (!browserForPath) {
        return;
      }
      // Shortcut if we are using the main file browser
      if (browser === browserForPath) {
        labShell.activateById(browser.id);
        return;
      } else {
        const areas: ILabShell.Area[] = ['left', 'right'];
        for (let area of areas) {
          const it = labShell.widgets(area);
          let widget = it.next();
          while (widget) {
            if (widget.contains(browserForPath)) {
              labShell.activateById(widget.id);
              return;
            }
            widget = it.next();
          }
        }
      }
    }
開發者ID:ellisonbg,項目名稱:jupyterlab,代碼行數:27,代碼來源:index.ts

示例2: activateBrowser

/**
 * Activate the default file browser in the sidebar.
 */
function activateBrowser(
  app: JupyterFrontEnd,
  factory: IFileBrowserFactory,
  docManager: IDocumentManager,
  labShell: ILabShell,
  restorer: ILayoutRestorer,
  settingRegistry: ISettingRegistry
): void {
  const browser = factory.defaultBrowser;
  const { commands } = app;

  // Let the application restorer track the primary file browser (that is
  // automatically created) for restoration of application state (e.g. setting
  // the file browser as the current side bar widget).
  //
  // All other file browsers created by using the factory function are
  // responsible for their own restoration behavior, if any.
  restorer.add(browser, namespace);

  addCommands(app, factory, labShell, docManager);

  browser.title.iconClass = 'jp-FolderIcon jp-SideBar-tabIcon';
  browser.title.caption = 'File Browser';
  labShell.add(browser, 'left', { rank: 100 });

  // If the layout is a fresh session without saved data, open file browser.
  labShell.restored.then(layout => {
    if (layout.fresh) {
      commands.execute(CommandIDs.showBrowser, void 0);
    }
  });

  Promise.all([app.restored, browser.model.restored]).then(() => {
    function maybeCreate() {
      // Create a launcher if there are no open items.
      if (labShell.isEmpty('main')) {
        Private.createLauncher(commands, browser);
      }
    }

    // When layout is modified, create a launcher if there are no open items.
    labShell.layoutModified.connect(() => {
      maybeCreate();
    });

    let navigateToCurrentDirectory: boolean = false;

    settingRegistry
      .load('@jupyterlab/filebrowser-extension:browser')
      .then(settings => {
        settings.changed.connect(settings => {
          navigateToCurrentDirectory = settings.get(
            'navigateToCurrentDirectory'
          ).composite as boolean;
        });
        navigateToCurrentDirectory = settings.get('navigateToCurrentDirectory')
          .composite as boolean;
      });

    // Whether to automatically navigate to a document's current directory
    labShell.currentChanged.connect((_, change) => {
      if (navigateToCurrentDirectory && change.newValue) {
        const { newValue } = change;
        const context = docManager.contextForWidget(newValue);
        if (context) {
          const { path } = context;
          Private.navigateToPath(path, factory)
            .then(() => {
              labShell.currentWidget.activate();
            })
            .catch((reason: any) => {
              console.warn(
                `${CommandIDs.navigate} failed to open: ${path}`,
                reason
              );
            });
        }
      }
    });

    maybeCreate();
  });
}
開發者ID:ellisonbg,項目名稱:jupyterlab,代碼行數:86,代碼來源:index.ts

示例3: String

    execute: (args: JSONObject) => {
      const cwd = args['cwd'] ? String(args['cwd']) : '';
      const id = `launcher-${Private.id++}`;
      const callback = (item: Widget) => {
        labShell.add(item, 'main', { ref: id });
      };
      const launcher = new Launcher({ cwd, callback, commands });

      launcher.model = model;
      launcher.title.label = 'Launcher';
      launcher.title.iconClass = 'jp-LauncherIcon';

      let main = new MainAreaWidget({ content: launcher });

      // If there are any other widgets open, remove the launcher close icon.
      main.title.closable = !!toArray(labShell.widgets('main')).length;
      main.id = id;

      labShell.add(main, 'main', { activate: args['activate'] as boolean });

      labShell.layoutModified.connect(() => {
        // If there is only a launcher open, remove the close icon.
        main.title.closable = toArray(labShell.widgets('main')).length > 1;
      }, main);

      return main;
    }
開發者ID:afshin,項目名稱:jupyterlab,代碼行數:27,代碼來源:index.ts

示例4: contextMenuWidget

 execute: () => {
   const widget = contextMenuWidget();
   if (!widget) {
     return;
   }
   const { id } = widget;
   const otherWidgets = toArray(labShell.widgets('main')).filter(
     widget => widget.id !== id
   );
   closeWidgets(otherWidgets);
 }
開發者ID:alexmorley,項目名稱:jupyterlab,代碼行數:11,代碼來源:index.ts

示例5: findTab

 const tabAreaFor = (widget: Widget): DockLayout.ITabAreaConfig | null => {
   const { mainArea } = labShell.saveLayout();
   if (mainArea.mode !== 'multiple-document') {
     return null;
   }
   let area = mainArea.dock.main;
   if (!area) {
     return null;
   }
   return findTab(area, widget);
 };
開發者ID:alexmorley,項目名稱:jupyterlab,代碼行數:11,代碼來源:index.ts

示例6:

 execute: () => {
   const widget = tracker.currentWidget;
   if (widget && !widget.isHidden) {
     labShell.collapseLeft();
   }
 }
開發者ID:ellisonbg,項目名稱:jupyterlab,代碼行數:6,代碼來源:index.ts

示例7: maybeCreate

 function maybeCreate() {
   // Create a launcher if there are no open items.
   if (labShell.isEmpty('main')) {
     Private.createLauncher(commands, browser);
   }
 }
開發者ID:ellisonbg,項目名稱:jupyterlab,代碼行數:6,代碼來源:index.ts

示例8:

 execute: () => {
   if (labShell && !view.isHidden) {
     labShell.collapseLeft();
   }
 }
開發者ID:afshin,項目名稱:jupyterlab,代碼行數:5,代碼來源:index.ts

示例9:

 isEnabled: () => {
   // Ensure there are at least two widgets.
   const iterator = labShell.widgets('main');
   return !!iterator.next() && !!iterator.next();
 },
開發者ID:alexmorley,項目名稱:jupyterlab,代碼行數:5,代碼來源:index.ts

示例10: toArray

 labShell.layoutModified.connect(() => {
   // If there is only a launcher open, remove the close icon.
   main.title.closable = toArray(labShell.widgets('main')).length > 1;
 }, main);
開發者ID:afshin,項目名稱:jupyterlab,代碼行數:4,代碼來源:index.ts

示例11:

 const callback = (item: Widget) => {
   labShell.add(item, 'main', { ref: id });
 };
開發者ID:afshin,項目名稱:jupyterlab,代碼行數:3,代碼來源:index.ts

示例12: toArray

 () => {
   // If there is only a launcher open, remove the close icon.
   main.title.closable = toArray(labShell.widgets('main')).length > 1;
 },
開發者ID:alexmorley,項目名稱:jupyterlab,代碼行數:4,代碼來源:index.ts


注:本文中的@jupyterlab/application.ILabShell類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。