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


TypeScript IDocumentManager.contextForWidget方法代碼示例

本文整理匯總了TypeScript中@jupyterlab/docmanager.IDocumentManager.contextForWidget方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript IDocumentManager.contextForWidget方法的具體用法?TypeScript IDocumentManager.contextForWidget怎麽用?TypeScript IDocumentManager.contextForWidget使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@jupyterlab/docmanager.IDocumentManager的用法示例。


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

示例1: showDialog

 execute: () => {
   if (!isEnabled()) {
     return;
   }
   const context = docManager.contextForWidget(shell.currentWidget);
   return context.listCheckpoints().then(checkpoints => {
     if (checkpoints.length < 1) {
       return;
     }
     const lastCheckpoint = checkpoints[checkpoints.length - 1];
     if (!lastCheckpoint) {
       return;
     }
     return showDialog({
       title: 'Revert notebook to checkpoint',
       body: new RevertConfirmWidget(lastCheckpoint),
       buttons: [
         Dialog.cancelButton(),
         Dialog.warnButton({ label: 'Revert' })
       ]
     }).then(result => {
       if (context.isDisposed) {
         return;
       }
       if (result.button.accept) {
         if (context.model.readOnly) {
           return context.revert();
         }
         return context.restoreCheckpoint().then(() => context.revert());
       }
     });
   });
 }
開發者ID:SylvainCorlay,項目名稱:jupyterlab,代碼行數:33,代碼來源:index.ts

示例2: each

 each(shell.widgets('main'), widget => {
   const context = docManager.contextForWidget(widget);
   if (context && !context.model.readOnly && !paths.has(context.path)) {
     paths.add(context.path);
     promises.push(context.save());
   }
 });
開發者ID:afshin,項目名稱:jupyterlab,代碼行數:7,代碼來源:index.ts

示例3:

 execute: () => {
   if (isEnabled()) {
     let context = docManager.contextForWidget(app.shell.currentWidget);
     return context.saveAs().then(() => {
       return context.createCheckpoint();
     });
   }
 }
開發者ID:samvasko,項目名稱:jupyterlab,代碼行數:8,代碼來源:index.ts

示例4:

 execute: () => {
   if (isEnabled()) {
     let context = docManager.contextForWidget(app.shell.currentWidget);
     if (context.model.readOnly) {
       return context.revert();
     }
     return context.restoreCheckpoint().then(() => context.revert());
   }
 }
開發者ID:SimonBiggs,項目名稱:jupyterlab,代碼行數:9,代碼來源:index.ts

示例5:

 isVisible: () => {
   const widget = app.shell.currentWidget;
   if (!widget) {
     return;
   }
   // Find the context for the widget.
   let context = docManager.contextForWidget(widget);
   return context !== null;
 },
開發者ID:cameronoelsen,項目名稱:jupyterlab,代碼行數:9,代碼來源:index.ts

示例6:

    execute: () => {
      let context = docManager.contextForWidget(contextMenuWidget());
      if (!context) {
        return;
      }

      // 'activate' is needed if this command is selected in the "open tabs" sidebar
      commands.execute('filebrowser:activate', { path: context.path });
      commands.execute('filebrowser:navigate', { path: context.path });
    }
開發者ID:SylvainCorlay,項目名稱:jupyterlab,代碼行數:10,代碼來源:index.ts

示例7:

    execute: () => {
      let context = docManager.contextForWidget(app.shell.currentWidget);
      if (!context) {
        return;
      }

      // 'activate-main' is needed if this command is selected in the "open tabs" sidebar
      commands.execute('filebrowser:activate-main');
      commands.execute('filebrowser:navigate-main', {path: context.path});
    }
開發者ID:groutr,項目名稱:jupyterlab,代碼行數:10,代碼來源:index.ts

示例8: renameDialog

 execute: () => {
   const widget = app.shell.currentWidget;
   if (!widget) {
     return;
   }
   // Find the context for the widget.
   let context = docManager.contextForWidget(widget);
   if (context) {
     return renameDialog(docManager, context.path);
   }
 },
開發者ID:cameronoelsen,項目名稱:jupyterlab,代碼行數:11,代碼來源:index.ts

示例9: while

 isEnabled: () => {
   const iterator = app.shell.widgets('main');
   let widget = iterator.next();
   while (widget) {
     if (docManager.contextForWidget(widget)) {
       return true;
     }
     widget = iterator.next();
   }
   return false;
 },
開發者ID:SimonBiggs,項目名稱:jupyterlab,代碼行數:11,代碼來源:index.ts


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