mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-10 02:02:35 -05:00
* Added data service context menu: file related operations. All new files are ported from SqlOpsStudio. Will remove these functionality from SqlOpsStudio. * Used the existing constant hadoopKnoxEndpointName * Rename nodeType name from hdfs to bdc. So we can have file context menu in both mssql and SqlOpsStudio. Need to add "Create External Table from CSV" support for bdc nodeType * Rename bdc to mssqlcluster
60 lines
1.6 KiB
TypeScript
60 lines
1.6 KiB
TypeScript
'use strict';
|
|
|
|
// This code is originally from https://github.com/DonJayamanne/bowerVSCode
|
|
// License: https://github.com/DonJayamanne/bowerVSCode/blob/master/LICENSE
|
|
|
|
import { window, InputBoxOptions } from 'vscode';
|
|
import Prompt from './prompt';
|
|
import EscapeException from '../escapeException';
|
|
|
|
const figures = require('figures');
|
|
|
|
export default class InputPrompt extends Prompt {
|
|
|
|
protected _options: InputBoxOptions;
|
|
|
|
constructor(question: any, ignoreFocusOut?: boolean) {
|
|
super(question, ignoreFocusOut);
|
|
|
|
this._options = this.defaultInputBoxOptions;
|
|
this._options.prompt = this._question.message;
|
|
}
|
|
|
|
// Helper for callers to know the right type to get from the type factory
|
|
public static get promptType(): string { return 'input'; }
|
|
|
|
public render(): any {
|
|
// Prefer default over the placeHolder, if specified
|
|
let placeHolder = this._question.default ? this._question.default : this._question.placeHolder;
|
|
|
|
if (this._question.default instanceof Error) {
|
|
placeHolder = this._question.default.message;
|
|
this._question.default = undefined;
|
|
}
|
|
|
|
this._options.placeHolder = placeHolder;
|
|
|
|
return window.showInputBox(this._options)
|
|
.then(result => {
|
|
if (result === undefined) {
|
|
throw new EscapeException();
|
|
}
|
|
|
|
if (result === '') {
|
|
// Use the default value, if defined
|
|
result = this._question.default || '';
|
|
}
|
|
|
|
const validationError = this._question.validate ? this._question.validate(result || '') : undefined;
|
|
|
|
if (validationError) {
|
|
this._question.default = new Error(`${figures.warning} ${validationError}`);
|
|
|
|
return this.render();
|
|
}
|
|
|
|
return result;
|
|
});
|
|
}
|
|
}
|