Skip to content

Commit

Permalink
inline ScopedService into its only user
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Jan 11, 2016
1 parent ff48078 commit f1971c4
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 57 deletions.
54 changes: 0 additions & 54 deletions src/vs/workbench/common/services.ts

This file was deleted.

48 changes: 47 additions & 1 deletion src/vs/workbench/services/progress/browser/progressService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import {TPromise} from 'vs/base/common/winjs.base';
import types = require('vs/base/common/types');
import {ProgressBar} from 'vs/base/browser/ui/progressbar/progressbar';
import {ScopedService} from 'vs/workbench/common/services';
import {EditorEvent, EventType, ViewletEvent} from 'vs/workbench/common/events';
import {IEventService} from 'vs/platform/event/common/event';
import {IProgressService, IProgressRunner} from 'vs/platform/progress/common/progress';

Expand All @@ -19,6 +19,52 @@ interface ProgressState {
whilePromise?: TPromise<any>;
}

export abstract class ScopedService {
private _eventService: IEventService;
private scopeId: string;

constructor(eventService: IEventService, scopeId: string) {
this._eventService = eventService;
this.scopeId = scopeId;

this.registerListeners();
}

public get eventService(): IEventService {
return this._eventService;
}

public registerListeners(): void {
this.eventService.addListener(EventType.EDITOR_CLOSED, (e: EditorEvent) => {
if (e.editorId === this.scopeId) {
this.onScopeDeactivated();
}
});

this.eventService.addListener(EventType.EDITOR_OPENED, (e: EditorEvent) => {
if (e.editorId === this.scopeId) {
this.onScopeActivated();
}
});

this.eventService.addListener(EventType.VIEWLET_CLOSED, (e: ViewletEvent) => {
if (e.viewletId === this.scopeId) {
this.onScopeDeactivated();
}
});

this.eventService.addListener(EventType.VIEWLET_OPENED, (e: ViewletEvent) => {
if (e.viewletId === this.scopeId) {
this.onScopeActivated();
}
});
}

public abstract onScopeActivated(): void;

public abstract onScopeDeactivated(): void;
}

export class WorkbenchProgressService extends ScopedService implements IProgressService {
public serviceId = IProgressService;
private isActive: boolean;
Expand Down
3 changes: 1 addition & 2 deletions src/vs/workbench/test/browser/services.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ import {EventType} from 'vs/workbench/common/events';
import {MainTelemetryService} from 'vs/platform/telemetry/browser/mainTelemetryService';
import Severity from 'vs/base/common/severity';
import {UntitledEditorService} from 'vs/workbench/services/untitled/browser/untitledEditorService';
import {WorkbenchProgressService} from 'vs/workbench/services/progress/browser/progressService';
import {ScopedService} from 'vs/workbench/common/services';
import {WorkbenchProgressService, ScopedService} from 'vs/workbench/services/progress/browser/progressService';
import {EditorArrangement} from 'vs/workbench/services/editor/common/editorService';
import {DelegatingWorkbenchEditorService, WorkbenchEditorService, IEditorPart} from 'vs/workbench/services/editor/browser/editorService';
import {IViewletService} from 'vs/workbench/services/viewlet/common/viewletService';
Expand Down

0 comments on commit f1971c4

Please sign in to comment.