55'use strict' ;
66
77import 'vs/css!vs/workbench/services/progress/browser/media/progressService2' ;
8- import { always } from 'vs/base/common/async' ;
8+ import * as dom from 'vs/base/browser/dom' ;
9+ import { IActivityBarService , ProgressBadge } from 'vs/workbench/services/activity/common/activityBarService' ;
910import { IDisposable } from 'vs/base/common/lifecycle' ;
10- import { Registry } from 'vs/platform/platform ' ;
11- import { IProgressService2 , IProgress , Progress } from 'vs/platform/progress/common/progress ' ;
11+ import { IProgressService2 , IProgress , Progress , emptyProgress } from 'vs/platform/progress/common/progress ' ;
12+ import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet ' ;
1213import { OcticonLabel } from 'vs/base/browser/ui/octiconLabel/octiconLabel' ;
14+ import { Registry } from 'vs/platform/platform' ;
1315import { StatusbarAlignment , IStatusbarRegistry , StatusbarItemDescriptor , Extensions , IStatusbarItem } from 'vs/workbench/browser/parts/statusbar/statusbar' ;
1416import { TPromise } from 'vs/base/common/winjs.base' ;
15- import { IActivityBarService , ProgressBadge } from 'vs/workbench/services/activity/common/activityBarService' ;
16- import * as dom from 'vs/base/browser/dom' ;
17-
18- class ActivityBarProgress implements IProgress < number > {
19-
20- private _handle : IDisposable ;
21-
22- constructor (
23- private _activityBar : IActivityBarService ,
24- private _viewletId : string ) {
25-
26- }
27-
28- dispose ( ) : void {
29- if ( this . _handle ) {
30- this . _handle . dispose ( ) ;
31- this . _handle = undefined ;
32- }
33- }
34-
35- report ( n : number ) : void {
36- if ( ! this . _handle ) {
37- this . _handle = this . _activityBar . showActivity ( this . _viewletId , new ProgressBadge ( ( ) => '...' ) , 'progress-badge' ) ;
38- }
39- }
40- }
17+ import { always } from 'vs/base/common/async' ;
4118
4219class WindowProgressItem implements IStatusbarItem {
4320
@@ -79,7 +56,8 @@ export class ProgressService2 implements IProgressService2 {
7956 private _stack : Progress < string > [ ] = [ ] ;
8057
8158 constructor (
82- @IActivityBarService private _activityBar : IActivityBarService
59+ @IActivityBarService private _activityBar : IActivityBarService ,
60+ @IViewletService private _viewletService : IViewletService
8361 ) {
8462 //
8563 }
@@ -98,11 +76,6 @@ export class ProgressService2 implements IProgressService2 {
9876 } ) ;
9977 }
10078
101- withViewletProgress ( viewletId : string , task : ( progress : IProgress < number > ) => TPromise < any > ) : void {
102- const progress = new ActivityBarProgress ( this . _activityBar , viewletId ) ;
103- always ( task ( progress ) , ( ) => progress . dispose ( ) ) ;
104- }
105-
10679 private _updateProgress ( ) {
10780 if ( this . _stack . length === 0 ) {
10881 WindowProgressItem . Instance . hide ( ) ;
@@ -111,6 +84,26 @@ export class ProgressService2 implements IProgressService2 {
11184 WindowProgressItem . Instance . text = this . _stack [ 0 ] . value ;
11285 }
11386 }
87+
88+ withViewletProgress ( viewletId : string , task : ( progress : IProgress < number > ) => TPromise < any > ) : void {
89+
90+ const promise = task ( emptyProgress ) ;
91+
92+ // show in viewlet
93+ const viewletProgress = this . _viewletService . getProgressIndicator ( viewletId ) ;
94+ viewletProgress . showWhile ( promise ) ;
95+
96+ // show activity bar
97+ const activityProgress = this . _activityBar . showActivity (
98+ viewletId ,
99+ new ProgressBadge ( ( ) => '...' ) ,
100+ 'progress-badge'
101+ ) ;
102+
103+ always ( promise , ( ) => {
104+ activityProgress . dispose ( ) ;
105+ } ) ;
106+ }
114107}
115108
116109
0 commit comments