Skip to content

Commit

Permalink
move open/save api into stable api, #13807
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Sep 22, 2017
1 parent 45bc150 commit 9dce465
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 91 deletions.
85 changes: 85 additions & 0 deletions src/vs/vscode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1503,6 +1503,75 @@ declare module 'vscode' {
onDidSelectItem?(item: QuickPickItem | string): any;
}

/**
* Options to configure the behaviour of a file open dialog.
*/
export interface OpenDialogOptions {
/**
* The resource the dialog shows when opened.
*/
defaultUri?: Uri;

/**
* A human-readable string for the open button.
*/
openLabel?: string;

/**
* Only allow to select files. *Note* that not all operating systems support
* to select files and folders in one dialog instance.
*/
openFiles?: boolean;

/**
* Only allow to select folders. *Note* that not all operating systems support
* to select files and folders in one dialog instance.
*/
openFolders?: boolean;

/**
* Allow to select many files or folders.
*/
openMany?: boolean;

/**
* A set of file filters that are shown in the dialog, e.g.
* ```ts
* {
* ['Images']: ['*.png', '*.jpg']
* ['TypeScript']: ['*.ts', '*.tsx']
* }
* ```
*/
filters: { [name: string]: string[] };
}

/**
* Options to configure the behaviour of a file save dialog.
*/
export interface SaveDialogOptions {
/**
* The resource the dialog shows when opened.
*/
defaultUri?: Uri;

/**
* A human-readable string for the save button.
*/
saveLabel?: string;

/**
* A set of file filters that are shown in the dialog, e.g.
* ```ts
* {
* ['Images']: ['*.png', '*.jpg']
* ['TypeScript']: ['*.ts', '*.tsx']
* }
* ```
*/
filters: { [name: string]: string[] };
}

/**
* Represents an action that is shown with an information, warning, or
* error message.
Expand Down Expand Up @@ -4446,6 +4515,22 @@ declare module 'vscode' {
*/
export function showQuickPick<T extends QuickPickItem>(items: T[] | Thenable<T[]>, options?: QuickPickOptions, token?: CancellationToken): Thenable<T | undefined>;

/**
* Shows a file open dialog to the user.
*
* @param options Options that control the dialog.
* @returns A promise that resolves to the selected resources or `undefined`.
*/
export function showOpenDialog(options: OpenDialogOptions): Thenable<Uri[] | undefined>;

/**
* Shows a file save dialog to the user.
*
* @param options Options that control the dialog.
* @returns A promise that resolves to the selected resource or `undefined`.
*/
export function showSaveDialog(options: SaveDialogOptions): Thenable<Uri | undefined>;

/**
* Opens an input box to ask the user for input.
*
Expand Down
85 changes: 0 additions & 85 deletions src/vs/vscode.proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,93 +7,8 @@

declare module 'vscode' {

/**
* Options to configure the behaviour of a file open dialog.
*/
export interface OpenDialogOptions {
/**
* The resource the dialog shows when opened.
*/
defaultUri?: Uri;

/**
* A human-readable string for the open button.
*/
openLabel?: string;

/**
* Only allow to select files. *Note* that not all operating systems support
* to select files and folders in one dialog instance.
*/
openFiles?: boolean;

/**
* Only allow to select folders. *Note* that not all operating systems support
* to select files and folders in one dialog instance.
*/
openFolders?: boolean;

/**
* Allow to select many files or folders.
*/
openMany?: boolean;

/**
* A set of file filters that are shown in the dialog, e.g.
* ```ts
* {
* ['Images']: ['*.png', '*.jpg']
* ['TypeScript']: ['*.ts', '*.tsx']
* }
* ```
*/
filters: { [name: string]: string[] };
}

/**
* Options to configure the behaviour of a file save dialog.
*/
export interface SaveDialogOptions {
/**
* The resource the dialog shows when opened.
*/
defaultUri?: Uri;

/**
* A human-readable string for the save button.
*/
saveLabel?: string;

/**
* A set of file filters that are shown in the dialog, e.g.
* ```ts
* {
* ['Images']: ['*.png', '*.jpg']
* ['TypeScript']: ['*.ts', '*.tsx']
* }
* ```
*/
filters: { [name: string]: string[] };
}

export namespace window {

/**
* Shows a file open dialog to the user.
*
* @param options Options that control the dialog.
* @returns A promise that resolves to the selected resources or `undefined`.
*/
export function showOpenDialog(options: OpenDialogOptions): Thenable<Uri[] | undefined>;

/**
* Shows a file save dialog to the user.
*
* @param options Options that control the dialog.
* @returns A promise that resolves to the selected resource or `undefined`.
*/
export function showSaveDialog(options: SaveDialogOptions): Thenable<Uri | undefined>;

/**
* Shows a selection list of [workspace folders](#workspace.workspaceFolders) to pick from.
* Returns `undefined` if no folder is open.
Expand Down
12 changes: 6 additions & 6 deletions src/vs/workbench/api/node/extHost.api.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,12 @@ export function createApiFactory(
showInputBox(options?: vscode.InputBoxOptions, token?: vscode.CancellationToken) {
return extHostQuickOpen.showInput(options, token);
},
showOpenDialog(options) {
return extHostDialogs.showOpenDialog(options);
},
showSaveDialog(options) {
return extHostDialogs.showSaveDialog(options);
},
createStatusBarItem(position?: vscode.StatusBarAlignment, priority?: number): vscode.StatusBarItem {
return extHostStatusBar.createStatusBarEntry(extension.id, <number>position, priority);
},
Expand Down Expand Up @@ -385,12 +391,6 @@ export function createApiFactory(
sampleFunction: proposedApiFunction(extension, () => {
return extHostMessageService.showMessage(extension, Severity.Info, 'Hello Proposed Api!', {}, []);
}),
showOpenDialog: proposedApiFunction(extension, options => {
return extHostDialogs.showOpenDialog(options);
}),
showSaveDialog: proposedApiFunction(extension, options => {
return extHostDialogs.showSaveDialog(options);
})
};

// namespace: workspace
Expand Down

0 comments on commit 9dce465

Please sign in to comment.