Merge from master

This commit is contained in:
Raj Musuku
2019-02-21 17:56:04 -08:00
parent 5a146e34fa
commit 666ae11639
11482 changed files with 119352 additions and 255574 deletions

View File

@@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/
import { Disposable } from 'vs/base/common/lifecycle';
import { TPromise } from 'vs/base/common/winjs.base';
import * as types from 'vs/base/common/types';
import { ProgressBar } from 'vs/base/browser/ui/progressbar/progressbar';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
@@ -16,7 +15,7 @@ interface ProgressState {
total?: number;
worked?: number;
done?: boolean;
whilePromise?: TPromise<any>;
whilePromise?: Thenable<any>;
whileStart?: number;
whileDelay?: number;
}
@@ -31,7 +30,7 @@ export abstract class ScopedService extends Disposable {
registerListeners(): void {
this._register(this.viewletService.onDidViewletOpen(viewlet => this.onScopeOpened(viewlet.getId())));
this._register(this.panelService.onDidPanelOpen(panel => this.onScopeOpened(panel.getId())));
this._register(this.panelService.onDidPanelOpen(({ panel }) => this.onScopeOpened(panel.getId())));
this._register(this.viewletService.onDidViewletClose(viewlet => this.onScopeClosed(viewlet.getId())));
this._register(this.panelService.onDidPanelClose(panel => this.onScopeClosed(panel.getId())));
@@ -206,7 +205,7 @@ export class ScopedProgressService extends ScopedService implements IProgressSer
};
}
showWhile(promise: TPromise<any>, delay?: number): TPromise<void> {
showWhile(promise: Thenable<any>, delay?: number): Thenable<void> {
let stack: boolean = !!this.progressState.whilePromise;
// Reset State
@@ -216,7 +215,7 @@ export class ScopedProgressService extends ScopedService implements IProgressSer
// Otherwise join with existing running promise to ensure progress is accurate
else {
promise = TPromise.join([promise, this.progressState.whilePromise]);
promise = Promise.all([promise, this.progressState.whilePromise]);
}
// Keep Promise in State
@@ -287,7 +286,7 @@ export class ProgressService implements IProgressService {
};
}
showWhile(promise: TPromise<any>, delay?: number): TPromise<void> {
showWhile(promise: Thenable<any>, delay?: number): Thenable<void> {
const stop = () => {
this.progressbar.stop().hide();
};
@@ -296,4 +295,4 @@ export class ProgressService implements IProgressService {
return promise.then(stop, stop);
}
}
}

View File

@@ -2,102 +2,43 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import 'vs/css!./media/progressService2';
import * as dom from 'vs/base/browser/dom';
import { localize } from 'vs/nls';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { IProgressService2, IProgressOptions, IProgressStep, ProgressLocation } from 'vs/workbench/services/progress/common/progress';
import { IProgress, emptyProgress, Progress } from 'vs/platform/progress/common/progress';
import { IProgressService2, IProgressOptions, IProgressStep, ProgressLocation, IProgress, emptyProgress, Progress } from 'vs/platform/progress/common/progress';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { OcticonLabel } from 'vs/base/browser/ui/octiconLabel/octiconLabel';
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 { StatusbarAlignment, IStatusbarService } from 'vs/platform/statusbar/common/statusbar';
import { always, timeout } from 'vs/base/common/async';
import { ProgressBadge, IActivityService } from 'vs/workbench/services/activity/common/activity';
import { INotificationService, Severity, INotificationHandle, INotificationActions } from 'vs/platform/notification/common/notification';
import { Action } from 'vs/base/common/actions';
import { once } from 'vs/base/common/event';
import { ViewContainer } from 'vs/workbench/common/views';
class WindowProgressItem implements IStatusbarItem {
static Instance: WindowProgressItem;
private _element: HTMLElement;
private _label: OcticonLabel;
constructor() {
WindowProgressItem.Instance = this;
}
render(element: HTMLElement): IDisposable {
this._element = element;
this._element.classList.add('progress');
const container = document.createElement('span');
this._element.appendChild(container);
const spinnerContainer = document.createElement('span');
spinnerContainer.classList.add('spinner-container');
container.appendChild(spinnerContainer);
const spinner = new OcticonLabel(spinnerContainer);
spinner.text = '$(sync~spin)';
const labelContainer = document.createElement('span');
container.appendChild(labelContainer);
this._label = new OcticonLabel(labelContainer);
this.hide();
return null;
}
set text(value: string) {
this._label.text = value;
}
set title(value: string) {
this._label.title = value;
}
hide() {
dom.hide(this._element);
}
show() {
dom.show(this._element);
}
}
export class ProgressService2 implements IProgressService2 {
_serviceBrand: any;
private _stack: [IProgressOptions, Progress<IProgressStep>][] = [];
private readonly _stack: [IProgressOptions, Progress<IProgressStep>][] = [];
private _globalStatusEntry: IDisposable;
constructor(
@IActivityService private readonly _activityBar: IActivityService,
@IViewletService private readonly _viewletService: IViewletService,
@INotificationService private readonly _notificationService: INotificationService
) {
//
}
@INotificationService private readonly _notificationService: INotificationService,
@IStatusbarService private readonly _statusbarService: IStatusbarService,
) { }
withProgress<P extends Thenable<R>, R=any>(options: IProgressOptions, task: (progress: IProgress<IProgressStep>) => P, onDidCancel?: () => void): P {
const { location } = options;
if (location instanceof ViewContainer) {
const viewlet = this._viewletService.getViewlet(location.id);
if (typeof location === 'string') {
const viewlet = this._viewletService.getViewlet(location);
if (viewlet) {
return this._withViewletProgress(location.id, task);
return this._withViewletProgress(location, task);
}
console.warn(`Bad progress location: ${location.id}`);
console.warn(`Bad progress location: ${location}`);
return undefined;
}
@@ -147,9 +88,11 @@ export class ProgressService2 implements IProgressService2 {
}
private _updateWindowProgress(idx: number = 0) {
if (idx >= this._stack.length) {
WindowProgressItem.Instance.hide();
} else {
dispose(this._globalStatusEntry);
if (idx < this._stack.length) {
const [options, progress] = this._stack[idx];
let progressTitle = options.title;
@@ -178,9 +121,10 @@ export class ProgressService2 implements IProgressService2 {
return;
}
WindowProgressItem.Instance.text = text;
WindowProgressItem.Instance.title = title;
WindowProgressItem.Instance.show();
this._globalStatusEntry = this._statusbarService.addEntry({
text: `$(sync~spin) ${text}`,
tooltip: title
}, StatusbarAlignment.LEFT);
}
}
@@ -199,12 +143,12 @@ export class ProgressService2 implements IProgressService2 {
super('progress.cancel', localize('cancel', "Cancel"), null, true);
}
run(): TPromise<any> {
run(): Thenable<any> {
if (typeof onDidCancel === 'function') {
onDidCancel();
}
return TPromise.as(undefined);
return Promise.resolve(void 0);
}
};
toDispose.push(cancelAction);
@@ -286,7 +230,7 @@ export class ProgressService2 implements IProgressService2 {
// show in viewlet
const viewletProgress = this._viewletService.getProgressIndicator(viewletId);
if (viewletProgress) {
viewletProgress.showWhile(TPromise.wrap(promise));
viewletProgress.showWhile(promise);
}
// show activity bar
@@ -324,8 +268,3 @@ export class ProgressService2 implements IProgressService2 {
return promise;
}
}
Registry.as<IStatusbarRegistry>(Extensions.Statusbar).registerStatusbarItem(
new StatusbarItemDescriptor(WindowProgressItem, StatusbarAlignment.LEFT)
);