提交 3137ddac 编写于 作者: J Joao Moreno

fixes #17722

上级 4d01c750
......@@ -13,6 +13,11 @@ import { Registry } from 'vs/platform/registry/common/platform';
import { ViewletDescriptor, ViewletRegistry, Extensions as ViewletExtensions } from 'vs/workbench/browser/viewlet';
import { IExtensionService } from 'vs/platform/extensions/common/extensions';
import { IProgressService } from 'vs/platform/progress/common/progress';
import { IContextKeyService, RawContextKey, IContextKey } from 'vs/platform/contextkey/common/contextkey';
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
const ActiveViewletContextId = 'activeViewlet';
export const ActiveViewletContext = new RawContextKey<string>(ActiveViewletContextId, '');
export class ViewletService implements IViewletService {
......@@ -24,20 +29,40 @@ export class ViewletService implements IViewletService {
private extensionViewlets: ViewletDescriptor[];
private extensionViewletsLoaded: TPromise<void>;
private extensionViewletsLoadedPromiseComplete: ValueCallback;
private activeViewletContextKey: IContextKey<string>;
private disposables: IDisposable[] = [];
public get onDidViewletOpen(): Event<IViewlet> { return this.sidebarPart.onDidViewletOpen; }
public get onDidViewletClose(): Event<IViewlet> { return this.sidebarPart.onDidViewletClose; }
constructor(
sidebarPart: SidebarPart,
@IExtensionService private extensionService: IExtensionService
@IExtensionService private extensionService: IExtensionService,
@IContextKeyService contextKeyService: IContextKeyService
) {
this.sidebarPart = sidebarPart;
this.viewletRegistry = Registry.as<ViewletRegistry>(ViewletExtensions.Viewlets);
this.activeViewletContextKey = ActiveViewletContext.bindTo(contextKeyService);
this.onDidViewletOpen(this._onDidViewletOpen, this, this.disposables);
this.onDidViewletClose(this._onDidViewletClose, this, this.disposables);
this.loadExtensionViewlets();
}
private _onDidViewletOpen(viewlet: IViewlet): void {
this.activeViewletContextKey.set(viewlet.getId());
}
private _onDidViewletClose(viewlet: IViewlet): void {
const id = viewlet.getId();
if (this.activeViewletContextKey.get() === id) {
this.activeViewletContextKey.set('');
}
}
private loadExtensionViewlets(): void {
this.extensionViewlets = [];
......@@ -104,4 +129,8 @@ export class ViewletService implements IViewletService {
public getProgressIndicator(id: string): IProgressService {
return this.sidebarPart.getProgressIndicator(id);
}
dispose(): void {
this.disposables = dispose(this.disposables);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册