提交 06b82f52 编写于 作者: P Pine Wu

Split didExtensionViewletLoad from didViewletToggle

上级 902137c4
......@@ -52,7 +52,11 @@ export class ActivitybarPart extends Part implements IActivityService {
// Deactivate viewlet action on close
this.toUnbind.push(this.viewletService.onDidViewletClose(viewlet => this.onCompositeClosed(viewlet)));
// Update viewlet switcher when extension viewlets become ready
this.toUnbind.push(this.viewletService.onDidExtensionViewletsLoad(() => this.refreshViewletSwitcher()));
// Update viewlet switcher on toggling of a viewlet
this.toUnbind.push(this.viewletService.onDidViewletToggle(() => this.refreshViewletSwitcher()));
}
private onActiveCompositeChanged(composite: IComposite): void {
......
......@@ -24,10 +24,12 @@ export class ViewletService implements IViewletService {
private enabledExtViewletIds: string[];
private extViewlets: ViewletDescriptor[];
private _onDidExtensionViewletsLoad = new Emitter<void>();
private _onDidViewletToggle = new Emitter<void>();
public get onDidViewletOpen(): Event<IViewlet> { return this.sidebarPart.onDidViewletOpen; };
public get onDidViewletClose(): Event<IViewlet> { return this.sidebarPart.onDidViewletClose; };
public get onDidExtensionViewletsLoad(): Event<void> { return this._onDidExtensionViewletsLoad.event; };
public get onDidViewletToggle(): Event<void> { return this._onDidViewletToggle.event; };
constructor(
sidebarPart: ISidebar,
......@@ -53,14 +55,14 @@ export class ViewletService implements IViewletService {
}
});
this._onDidExtensionViewletsLoad.fire(null);
this._onDidExtensionViewletsLoad.fire();
}
public openViewlet(id: string, focus?: boolean): TPromise<IViewlet> {
return this.sidebarPart.openViewlet(id, focus);
}
public toggleViewlet(id: string): TPromise<IViewlet> {
public toggleViewlet(id: string): TPromise<void> {
const index = this.enabledExtViewletIds.indexOf(id);
if (index === -1) {
this.enabledExtViewletIds.push(id);
......@@ -69,7 +71,7 @@ export class ViewletService implements IViewletService {
}
this.setEnabledExtViewlets();
this._onDidExtensionViewletsLoad.fire();
this._onDidViewletToggle.fire();
return TPromise.as(null);
}
......
......@@ -18,6 +18,7 @@ export interface IViewletService {
onDidViewletOpen: Event<IViewlet>;
onDidViewletClose: Event<IViewlet>;
onDidExtensionViewletsLoad: Event<void>;
onDidViewletToggle: Event<void>;
/**
* Opens a viewlet with the given identifier and pass keyboard focus to it if specified.
......@@ -27,7 +28,7 @@ export interface IViewletService {
/**
* Toggles a viewlet with the given identifier.
*/
toggleViewlet(id: string): TPromise<IViewlet>;
toggleViewlet(id: string): TPromise<void>;
/**
* Returns the current active viewlet or null if none.
......
......@@ -101,19 +101,20 @@ class TestViewletService implements IViewletService {
public _serviceBrand: any;
onDidViewletOpenEmitter = new Emitter<IViewlet>();
onDidViewletOpen = this.onDidViewletOpenEmitter.event;
onDidViewletCloseEmitter = new Emitter<IViewlet>();
onDidViewletClose = this.onDidViewletCloseEmitter.event;
onDidExtensionViewletsLoadEmitter = new Emitter<void>();
onDidViewletToggleEmitter = new Emitter<void>();
onDidViewletOpen = this.onDidViewletOpenEmitter.event;
onDidViewletClose = this.onDidViewletCloseEmitter.event;
onDidExtensionViewletsLoad = this.onDidExtensionViewletsLoadEmitter.event;
onDidViewletToggle = this.onDidViewletToggleEmitter.event;
public openViewlet(id: string, focus?: boolean): TPromise<IViewlet> {
return TPromise.as(null);
}
public toggleViewlet(id: string): TPromise<IViewlet> {
public toggleViewlet(id: string): TPromise<void> {
return TPromise.as(null);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册