本文整理汇总了TypeScript中vscode.window.showOpenDialog方法的典型用法代码示例。如果您正苦于以下问题:TypeScript window.showOpenDialog方法的具体用法?TypeScript window.showOpenDialog怎么用?TypeScript window.showOpenDialog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vscode.window
的用法示例。
在下文中一共展示了window.showOpenDialog方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: init
@command('git.init')
async init(): Promise<void> {
const homeUri = Uri.file(os.homedir());
const defaultUri = workspace.workspaceFolders && workspace.workspaceFolders.length > 0
? Uri.file(workspace.workspaceFolders[0].uri.fsPath)
: homeUri;
const result = await window.showOpenDialog({
canSelectFiles: false,
canSelectFolders: true,
canSelectMany: false,
defaultUri,
openLabel: localize('init repo', "Initialize Repository")
});
if (!result || result.length === 0) {
return;
}
const uri = result[0];
if (homeUri.toString().startsWith(uri.toString())) {
const yes = localize('create repo', "Initialize Repository");
const answer = await window.showWarningMessage(localize('are you sure', "This will create a Git repository in '{0}'. Are you sure you want to continue?", uri.fsPath), yes);
if (answer !== yes) {
return;
}
}
const path = uri.fsPath;
await this.git.init(path);
await this.model.tryOpenRepository(path);
}
示例2: showOpenFolderDialog
export async function showOpenFolderDialog(): Promise<string> {
const folder = await window.showOpenDialog({
canSelectFiles: false,
canSelectFolders: true,
canSelectMany: false,
openLabel: Constants.placeholders.selectNewProjectPath,
});
if (!folder) {
throw new CancellationEvent();
}
return folder[0].fsPath;
}
示例3: promptForTargetDirectory
async function promptForTargetDirectory(): Promise<string | undefined> {
const options: OpenDialogOptions = {
canSelectMany: false,
openLabel: "Select a folder to create the bloc in",
canSelectFolders: true
};
return window.showOpenDialog(options).then(uri => {
if (_.isNil(uri) || _.isEmpty(uri)) {
return undefined;
}
return uri[0].fsPath;
});
}
示例4: changeJuliaEnvironment
async function changeJuliaEnvironment() {
telemetry.traceEvent('changeCurrentEnvironment');
const optionsEnv: vscode.QuickPickOptions = {
placeHolder: 'Select environment'
};
let depotPaths = await packagepath.getPkgDepotPath();
let envFolders = [{ label: '(pick a folder)', description: '' }];
for (let depotPath of depotPaths) {
let envFolderForThisDepot = path.join(depotPath, 'environments');
let folderExists = await fs.exists(envFolderForThisDepot);
if (folderExists) {
let envirsForThisDepot = await fs.readdir(envFolderForThisDepot);
for (let envFolder of envirsForThisDepot) {
envFolders.push({ label: envFolder, description: path.join(envFolderForThisDepot, envFolder) });
}
}
}
let resultPackage = await vscode.window.showQuickPick(envFolders, optionsEnv);
if (resultPackage !== undefined) {
if (resultPackage.description == '') {
let resultFolder = await vscode.window.showOpenDialog({ canSelectFiles: false, canSelectFolders: true });
// Is this actually an environment?
if (resultFolder !== undefined) {
let envPathUri = resultFolder[0].toString();
let envPath = vscode.Uri.parse(envPathUri).fsPath;
let isThisAEnv = await fs.exists(path.join(envPath, 'Project.toml'));
if (isThisAEnv) {
switchEnvToPath(envPath);
}
else {
vscode.window.showErrorMessage('The selected path is not a julia environment.');
}
}
}
else {
switchEnvToPath(resultPackage.description);
}
}
}
示例5: showSdkActivationFailure
export async function showSdkActivationFailure(
sdkType: string,
search: (path: string[]) => string,
downloadUrl: string,
saveSdkPath: (path: string) => Thenable<void>,
commandToReRun?: string,
) {
const locateAction = "Locate SDK";
const downloadAction = "Download SDK";
let displayMessage = `Could not find a ${sdkType} SDK. ` +
`Please ensure ${sdkType.toLowerCase()} is installed and in your PATH (you may need to restart).`;
while (true) {
const selectedItem = await window.showErrorMessage(displayMessage,
locateAction,
downloadAction,
showLogAction,
);
// TODO: Refactor/reformat/comment this code - it's messy and hard to understand!
if (selectedItem === locateAction) {
const selectedFolders =
await window.showOpenDialog({ canSelectFolders: true, openLabel: `Set ${sdkType} SDK folder` });
if (selectedFolders && selectedFolders.length > 0) {
const matchingSdkFolder = search(selectedFolders.map(fsPath));
if (matchingSdkFolder) {
await saveSdkPath(matchingSdkFolder);
await reloadExtension();
if (commandToReRun) {
commands.executeCommand(commandToReRun);
}
break;
} else {
displayMessage = `That folder does not appear to be a ${sdkType} SDK.`;
}
}
} else if (selectedItem === downloadAction) {
openInBrowser(downloadUrl);
break;
} else if (selectedItem === showLogAction) {
openExtensionLogFile();
break;
} else {
break;
}
}
}
示例6: pushImage
let newMediaObjectDisposable = vscode.commands.registerCommand('extension.writeCnblog.newMediaObject', () => {
const edit = vscode.window.activeTextEditor;
if (!edit) {
vscode.window.showErrorMessage("没有打开编辑窗口");
return;
}
vscode.window.showOpenDialog({
filters: { 'Images': ['png', 'jpg', 'gif', 'bmp'] }
}).then(result => {
if (result) {
const { fsPath } = result[0];
//上传图片
pushImage(fsPath,edit);
}
}, error);
});
示例7: async
disposable = vscode.commands.registerCommand('extension.browse', async (cmdArgs: any) => {
commandArgs = cmdArgs;
let x = vscode.extensions.getExtension("pdconsec.vscode-print");
if (!x) { throw new Error("Cannot resolve extension. Has the name changed? It is defined by the publisher and the extension name defined in package.json"); }
var stylePath = `${x.extensionPath.replace(/\\/g, "/")}/node_modules/highlight.js/styles`;
let printConfig = vscode.workspace.getConfiguration("print", null);
let currentPath = `${stylePath}/${printConfig.colourScheme}.css`;
vscode.window.showOpenDialog({
canSelectFiles: true,
canSelectMany: false,
defaultUri: vscode.Uri.file(fs.existsSync(currentPath) ? currentPath : stylePath),
filters: {
Stylesheet: ['css']
}
}).then(f => {
if (f) {
let p = f[0].fsPath;
let lbs = p.lastIndexOf("\\");
var path = p.substring(0, lbs).replace(/\\/g, "/");
var newValue = p.substring(lbs + 1, p.lastIndexOf("."));
try {
vscode.workspace.getConfiguration().update("print.colourScheme", newValue, vscode.ConfigurationTarget.Global).then(() => {
if (path !== stylePath) {
let newCachePath = `${stylePath}/${newValue}.css`;
fs.copyFile(p, newCachePath, err => {
vscode.window.showErrorMessage(err.message);
});
}
}, (err) => {
debugger;
});
} catch (err) {
debugger;
}
}
});
});
示例8: showOpenDialog
public showOpenDialog(options: vscode.OpenDialogOptions): Thenable<vscode.Uri[] | undefined> {
return vscode.window.showOpenDialog(options);
}