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


TypeScript window.showWarningMessage方法代碼示例

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


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

示例1: stageAll

	@command('git.stageAll', { repository: true })
	async stageAll(repository: Repository): Promise<void> {
		const resources = repository.mergeGroup.resourceStates.filter(s => s instanceof Resource) as Resource[];
		const mergeConflicts = resources.filter(s => s.resourceGroupType === ResourceGroupType.Merge);

		if (mergeConflicts.length > 0) {
			const message = mergeConflicts.length > 1
				? localize('confirm stage files with merge conflicts', "Are you sure you want to stage {0} files with merge conflicts?", mergeConflicts.length)
				: localize('confirm stage file with merge conflicts', "Are you sure you want to stage {0} with merge conflicts?", path.basename(mergeConflicts[0].resourceUri.fsPath));

			const yes = localize('yes', "Yes");
			const pick = await window.showWarningMessage(message, { modal: true }, yes);

			if (pick !== yes) {
				return;
			}
		}

		await repository.add([]);
	}
開發者ID:golf1052,項目名稱:vscode,代碼行數:20,代碼來源:commands.ts

示例2: localize

	return client.onProjectLanguageServiceStateChanged(body => {
		if (body.languageServiceEnabled) {
			item.hide();
		} else {
			item.show();
			const configFileName = body.projectName;
			if (configFileName) {
				item.configFileName = configFileName;
				vscode.window.showWarningMessage<LargeProjectMessageItem>(item.getCurrentHint().message,
					{
						title: localize('large.label', "Configure Excludes"),
						index: 0
					}).then(selected => {
						if (selected && selected.index === 0) {
							onConfigureExcludesSelected(client, configFileName);
						}
					});
			}
		}
	});
開發者ID:jinlongchen2018,項目名稱:vscode,代碼行數:20,代碼來源:projectStatus.ts

示例3: publish

	@command('git.publish')
	async publish(): Promise<void> {
		const remotes = this.model.remotes;

		if (remotes.length === 0) {
			window.showWarningMessage(localize('no remotes to publish', "Your repository has no remotes configured to publish to."));
			return;
		}

		const branchName = this.model.HEAD && this.model.HEAD.name || '';
		const picks = this.model.remotes.map(r => r.name);
		const placeHolder = localize('pick remote', "Pick a remote to publish the branch '{0}' to:", branchName);
		const choice = await window.showQuickPick(picks, { placeHolder });

		if (!choice) {
			return;
		}

		await this.model.pushTo(choice, branchName, true);
	}
開發者ID:FabianLauer,項目名稱:vscode,代碼行數:20,代碼來源:commands.ts

示例4: execShellCMD

function execShellCMD(cwd:string) {
  if (process) {
    const msg = 'There is an active running shell command right now. Terminate it before executing another shell command.';
    vscode.window.showWarningMessage(msg, 'Terminate')
      .then((choice) => {
        if (choice === 'Terminate') {
          term();
        }
      });
  } else {
    var lastCmd = commandHistory.last();
    var options = {
      placeHolder: 'Type your shell command here.',
      value: lastCmd ? lastCmd.cmd : undefined
    };
    vscode.window.showInputBox(options).then((cmd) => {
      exec(cmd, cwd);
    });
  }
}
開發者ID:bbenoist,項目名稱:vscode-shell,代碼行數:20,代碼來源:extension.ts

示例5: execute

    async execute(editor: TextEditor, uri?: Uri, args: OpenWorkingFileCommandArgs = {}) {
        args = { ...args };
        if (args.line === undefined) {
            args.line = editor == null ? 0 : editor.selection.active.line;
        }

        try {
            if (args.uri == null) {
                uri = getCommandUri(uri, editor);
                if (uri == null) return undefined;

                args.uri = await GitUri.fromUri(uri);
                if (args.uri instanceof GitUri && args.uri.sha) {
                    const workingUri = await Container.git.getWorkingUri(args.uri.repoPath!, args.uri);
                    if (workingUri === undefined) {
                        return window.showWarningMessage(
                            'Unable to open working file. File could not be found in the working tree'
                        );
                    }

                    args.uri = new GitUri(workingUri, args.uri.repoPath);
                }
            }

            if (args.line !== undefined && args.line !== 0) {
                if (args.showOptions === undefined) {
                    args.showOptions = {};
                }
                args.showOptions.selection = new Range(args.line, 0, args.line, 0);
            }

            const e = await openEditor(args.uri, { ...args.showOptions, rethrow: true });
            if (args.annotationType === undefined) return e;

            return Container.fileAnnotations.show(e!, args.annotationType, args.line);
        }
        catch (ex) {
            Logger.error(ex, 'OpenWorkingFileCommand');
            return Messages.showGenericErrorMessage('Unable to open working file');
        }
    }
開發者ID:chrisleaman,項目名稱:vscode-gitlens,代碼行數:41,代碼來源:openWorkingFile.ts

示例6: doesAnyAssetExist

        doesAnyAssetExist(generator).then(res => {
            if (res) {
                const yesItem = { title: 'Yes' };
                const cancelItem = { title: 'Cancel', isCloseAffordance: true };

                vscode.window.showWarningMessage('Replace existing build and debug assets?', cancelItem, yesItem)
                    .then(selection => {
                        if (selection === yesItem) {
                            deleteAssets(generator).then(_ => resolve(true));
                        }
                        else {
                            // The user clicked cancel
                            resolve(false);
                        }
                    });
            }
            else {
                // The assets don't exist, so we're good to go.
                resolve(true);
            }
        });
開發者ID:eamodio,項目名稱:omnisharp-vscode,代碼行數:21,代碼來源:assets.ts

示例7: open

	let disposable = vscode.commands.registerCommand('extension.viewInBrowser', () => {
        var editor = vscode.window.activeTextEditor;
        
        if (!editor) {
            vscode.window.showWarningMessage('no active text editor!');
            return; 
        }
        const file = editor.document.fileName;
        
        const ext = path.extname(file);
        
        if (/^\.(html|htm|shtml|xhtml)$/.test(ext)) {
            if(os.platform() == 'linux'){
                    open(`file:///${file}`,'x-www-browser');
                }else{
                    open(`file:///${file}`);
                }
        } else {
            vscode.window.showInformationMessage('support html file only!');
        }
	});
開發者ID:queerkid,項目名稱:view-in-browser,代碼行數:21,代碼來源:extension.ts

示例8: stage

	@command('git.stage')
	async stage(...resourceStates: SourceControlResourceState[]): Promise<void> {
		if (resourceStates.length === 0 || !(resourceStates[0].resourceUri instanceof Uri)) {
			const resource = this.getSCMResource();

			if (!resource) {
				return;
			}

			resourceStates = [resource];
		}

		const selection = resourceStates.filter(s => s instanceof Resource) as Resource[];
		const mergeConflicts = selection.filter(s => s.resourceGroupType === ResourceGroupType.Merge);

		if (mergeConflicts.length > 0) {
			const message = mergeConflicts.length > 1
				? localize('confirm stage files with merge conflicts', "Are you sure you want to stage {0} files with merge conflicts?", mergeConflicts.length)
				: localize('confirm stage file with merge conflicts', "Are you sure you want to stage {0} with merge conflicts?", path.basename(mergeConflicts[0].resourceUri.fsPath));

			const yes = localize('yes', "Yes");
			const pick = await window.showWarningMessage(message, { modal: true }, yes);

			if (pick !== yes) {
				return;
			}
		}

		const workingTree = selection
			.filter(s => s.resourceGroupType === ResourceGroupType.WorkingTree);

		const scmResources = [...workingTree, ...mergeConflicts];

		if (!scmResources.length) {
			return;
		}

		const resources = scmResources.map(r => r.resourceUri);
		await this.runByRepository(resources, async (repository, resources) => repository.add(resources));
	}
開發者ID:kieferrm,項目名稱:vscode,代碼行數:40,代碼來源:commands.ts

示例9: getTidySettings

 /**
  * get options from workspace options or from file .htmltidy
  */
 private getTidySettings() {
     if (!this.tidySettings) {
         let options = this.config.optionsTidy;
         if (vscode.workspace.workspaceFolders) {
             for (let folder of vscode.workspace.workspaceFolders) {
                 const optionsFileName = path.join(folder.uri.fsPath, '.htmlTidy');
                 if (fs.existsSync(optionsFileName)) {
                     try {
                         const fileOptions = JSON.parse(fs.readFileSync(optionsFileName, 'utf8'));
                         options = fileOptions;
                     } catch (err) {
                         console.error(err);
                         vscode.window.showWarningMessage(`Options in file ${optionsFileName} not valid`);
                     }
                     break;
                 }
             }
         }
         this.tidySettings = options;
     }
     return this.tidySettings;
 }
開發者ID:AnWeber,項目名稱:vscode-tidyhtml,代碼行數:25,代碼來源:tidyformatter.ts

示例10: enable

function enable() {
	let folders = Workspace.workspaceFolders;
	if (!folders) {
		Window.showWarningMessage(`${linterName} can only be enabled if VS Code is opened on a workspace folder.`);
		return;
	}
	let disabledFolders = folders.filter(folder => !Workspace.getConfiguration('standard',folder.uri).get('enable', true));
	if (disabledFolders.length === 0) {
		if (folders.length === 1) {
			Window.showInformationMessage(`${linterName} is already enabled in the workspace.`);
		} else {
			Window.showInformationMessage(`${linterName} is already enabled on all workspace folders.`);
		}
		return;
	}
	pickFolder(disabledFolders, `Select a workspace folder to enable ${linterName} for`).then(folder => {
		if (!folder) {
			return;
		}
		Workspace.getConfiguration('standard', folder.uri).update('enable', true);
	});
}
開發者ID:chenxsan,項目名稱:vscode-standardjs,代碼行數:22,代碼來源:extension.ts


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