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

Split didExtensionViewletLoad from didViewletToggle

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