mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-13 19:48:37 -05:00
Merge VS Code 1.21 source code (#1067)
* Initial VS Code 1.21 file copy with patches * A few more merges * Post npm install * Fix batch of build breaks * Fix more build breaks * Fix more build errors * Fix more build breaks * Runtime fixes 1 * Get connection dialog working with some todos * Fix a few packaging issues * Copy several node_modules to package build to fix loader issues * Fix breaks from master * A few more fixes * Make tests pass * First pass of license header updates * Second pass of license header updates * Fix restore dialog issues * Remove add additional themes menu items * fix select box issues where the list doesn't show up * formatting * Fix editor dispose issue * Copy over node modules to correct location on all platforms
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
import 'vs/css!./media/progressService2';
|
||||
import * as dom from 'vs/base/browser/dom';
|
||||
import { localize } from 'vs/nls';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { IProgressService2, IProgressOptions, ProgressLocation, IProgress, IProgressStep, Progress, emptyProgress } from 'vs/platform/progress/common/progress';
|
||||
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
|
||||
import { OcticonLabel } from 'vs/base/browser/ui/octiconLabel/octiconLabel';
|
||||
@@ -15,6 +15,7 @@ import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { StatusbarAlignment, IStatusbarRegistry, StatusbarItemDescriptor, Extensions, IStatusbarItem } from 'vs/workbench/browser/parts/statusbar/statusbar';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { always } from 'vs/base/common/async';
|
||||
import { ProgressBadge, IActivityService } from 'vs/workbench/services/activity/common/activity';
|
||||
|
||||
class WindowProgressItem implements IStatusbarItem {
|
||||
|
||||
@@ -60,27 +61,31 @@ export class ProgressService2 implements IProgressService2 {
|
||||
private _stack: [IProgressOptions, Progress<IProgressStep>][] = [];
|
||||
|
||||
constructor(
|
||||
@IViewletService private _viewletService: IViewletService
|
||||
@IActivityService private readonly _activityBar: IActivityService,
|
||||
@IViewletService private readonly _viewletService: IViewletService
|
||||
) {
|
||||
//
|
||||
}
|
||||
|
||||
withProgress(options: IProgressOptions, task: (progress: IProgress<{ message?: string, percentage?: number }>) => TPromise<any>): void {
|
||||
withProgress<P extends Thenable<R>, R=any>(options: IProgressOptions, task: (progress: IProgress<IProgressStep>) => P): P {
|
||||
|
||||
const { location } = options;
|
||||
switch (location) {
|
||||
case ProgressLocation.Window:
|
||||
this._withWindowProgress(options, task);
|
||||
break;
|
||||
return this._withWindowProgress(options, task);
|
||||
case ProgressLocation.Explorer:
|
||||
return this._withViewletProgress('workbench.view.explorer', task);
|
||||
case ProgressLocation.Scm:
|
||||
this._withViewletProgress('workbench.view.scm', task);
|
||||
break;
|
||||
return this._withViewletProgress('workbench.view.scm', task);
|
||||
case ProgressLocation.Extensions:
|
||||
return this._withViewletProgress('workbench.view.extensions', task);
|
||||
default:
|
||||
console.warn(`Bad progress location: ${location}`);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private _withWindowProgress(options: IProgressOptions, callback: (progress: IProgress<{ message?: string, percentage?: number }>) => TPromise<any>): void {
|
||||
private _withWindowProgress<P extends Thenable<R>, R=any>(options: IProgressOptions, callback: (progress: IProgress<{ message?: string, percentage?: number }>) => P): P {
|
||||
|
||||
const task: [IProgressOptions, Progress<IProgressStep>] = [options, new Progress<IProgressStep>(() => this._updateWindowProgress())];
|
||||
|
||||
@@ -104,7 +109,8 @@ export class ProgressService2 implements IProgressService2 {
|
||||
}, 150);
|
||||
|
||||
// cancel delay if promise finishes below 150ms
|
||||
always(promise, () => clearTimeout(delayHandle));
|
||||
always(TPromise.wrap(promise), () => clearTimeout(delayHandle));
|
||||
return promise;
|
||||
}
|
||||
|
||||
private _updateWindowProgress(idx: number = 0) {
|
||||
@@ -138,45 +144,49 @@ export class ProgressService2 implements IProgressService2 {
|
||||
}
|
||||
}
|
||||
|
||||
private _withViewletProgress(viewletId: string, task: (progress: IProgress<{ message?: string, percentage?: number }>) => TPromise<any>): void {
|
||||
private _withViewletProgress<P extends Thenable<R>, R=any>(viewletId: string, task: (progress: IProgress<{ message?: string, percentage?: number }>) => P): P {
|
||||
|
||||
const promise = task(emptyProgress);
|
||||
|
||||
// show in viewlet
|
||||
const viewletProgress = this._viewletService.getProgressIndicator(viewletId);
|
||||
if (viewletProgress) {
|
||||
viewletProgress.showWhile(promise);
|
||||
viewletProgress.showWhile(TPromise.wrap(promise));
|
||||
}
|
||||
|
||||
// show activity bar
|
||||
// let activityProgress: IDisposable;
|
||||
// let delayHandle = setTimeout(() => {
|
||||
// delayHandle = undefined;
|
||||
// const handle = this._activityBar.showActivity(
|
||||
// viewletId,
|
||||
// new ProgressBadge(() => ''),
|
||||
// 'progress-badge'
|
||||
// );
|
||||
// const startTimeVisible = Date.now();
|
||||
// const minTimeVisible = 300;
|
||||
// activityProgress = {
|
||||
// dispose() {
|
||||
// const d = Date.now() - startTimeVisible;
|
||||
// if (d < minTimeVisible) {
|
||||
// // should at least show for Nms
|
||||
// setTimeout(() => handle.dispose(), minTimeVisible - d);
|
||||
// } else {
|
||||
// // shown long enough
|
||||
// handle.dispose();
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
// }, 300);
|
||||
let activityProgress: IDisposable;
|
||||
let delayHandle = setTimeout(() => {
|
||||
delayHandle = undefined;
|
||||
const handle = this._activityBar.showActivity(
|
||||
viewletId,
|
||||
new ProgressBadge(() => ''),
|
||||
'progress-badge',
|
||||
100
|
||||
);
|
||||
const startTimeVisible = Date.now();
|
||||
const minTimeVisible = 300;
|
||||
activityProgress = {
|
||||
dispose() {
|
||||
const d = Date.now() - startTimeVisible;
|
||||
if (d < minTimeVisible) {
|
||||
// should at least show for Nms
|
||||
setTimeout(() => handle.dispose(), minTimeVisible - d);
|
||||
} else {
|
||||
// shown long enough
|
||||
handle.dispose();
|
||||
}
|
||||
}
|
||||
};
|
||||
}, 300);
|
||||
|
||||
// always(promise, () => {
|
||||
// clearTimeout(delayHandle);
|
||||
// dispose(activityProgress);
|
||||
// });
|
||||
const onDone = () => {
|
||||
clearTimeout(delayHandle);
|
||||
dispose(activityProgress);
|
||||
};
|
||||
|
||||
promise.then(onDone, onDone);
|
||||
return promise;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user