提交 918e4933 编写于 作者: S Sandeep Somavarapu

Fix when no views are registered to test extension

上级 bc03bc9b
...@@ -57,7 +57,7 @@ export class ActivitybarPart extends Part { ...@@ -57,7 +57,7 @@ export class ActivitybarPart extends Part {
private globalActivityIdToActions: { [globalActivityId: string]: GlobalActivityAction; }; private globalActivityIdToActions: { [globalActivityId: string]: GlobalActivityAction; };
private placeholderComposites: IPlaceholderComposite[] = []; private placeholderComposites: IPlaceholderComposite[] = [];
private extensionsRegistered: boolean = false; private extensionsRegistrationCompleted: boolean = false;
private compositeBar: CompositeBar; private compositeBar: CompositeBar;
private compositeActions: { [compositeId: string]: { activityAction: ViewletActivityAction, pinnedAction: ToggleCompositePinnedAction } }; private compositeActions: { [compositeId: string]: { activityAction: ViewletActivityAction, pinnedAction: ToggleCompositePinnedAction } };
...@@ -100,7 +100,7 @@ export class ActivitybarPart extends Part { ...@@ -100,7 +100,7 @@ export class ActivitybarPart extends Part {
} }
private onDidRegisterExtensions(): void { private onDidRegisterExtensions(): void {
this.extensionsRegistered = true; this.extensionsRegistrationCompleted = true;
this.removeNotExistingPlaceholderComposites(); this.removeNotExistingPlaceholderComposites();
this.updateCompositebar(); this.updateCompositebar();
} }
...@@ -214,7 +214,7 @@ export class ActivitybarPart extends Part { ...@@ -214,7 +214,7 @@ export class ActivitybarPart extends Part {
const placeHolderComposite = this.placeholderComposites.filter(c => c.id === compositeId)[0]; const placeHolderComposite = this.placeholderComposites.filter(c => c.id === compositeId)[0];
compositeActions = { compositeActions = {
activityAction: this.instantiationService.createInstance(PlaceHolderViewletActivityAction, compositeId, placeHolderComposite.iconUrl), activityAction: this.instantiationService.createInstance(PlaceHolderViewletActivityAction, compositeId, placeHolderComposite.iconUrl),
pinnedAction: new PlaceHolderToggleCompositePinnedAction(compositeId, placeHolderComposite.iconUrl, this.compositeBar) pinnedAction: new PlaceHolderToggleCompositePinnedAction(compositeId, this.compositeBar)
}; };
} }
this.compositeActions[compositeId] = compositeActions; this.compositeActions[compositeId] = compositeActions;
...@@ -225,8 +225,18 @@ export class ActivitybarPart extends Part { ...@@ -225,8 +225,18 @@ export class ActivitybarPart extends Part {
private updateCompositebar(): void { private updateCompositebar(): void {
const viewlets = this.viewletService.getViewlets(); const viewlets = this.viewletService.getViewlets();
for (const viewlet of viewlets) { for (const viewlet of viewlets) {
if (!this.extensionsRegistered || this.canShow(viewlet)) { const hasPlaceholder = this.placeholderComposites.some(c => c.id === viewlet.id);
// Add the composite if it has views registered or
// If it was existing before and the extensions registration is not yet completed.
if (this.hasRegisteredViews(viewlet)
|| (hasPlaceholder && !this.extensionsRegistrationCompleted)
) {
this.compositeBar.addComposite(viewlet, false); this.compositeBar.addComposite(viewlet, false);
// Pin it by default if it is new => it does not has a placeholder
if (!hasPlaceholder) {
this.compositeBar.pin(viewlet.id);
}
this.enableCompositeActions(viewlet); this.enableCompositeActions(viewlet);
const activeViewlet = this.viewletService.getActiveViewlet(); const activeViewlet = this.viewletService.getActiveViewlet();
if (activeViewlet && activeViewlet.getId() === viewlet.id) { if (activeViewlet && activeViewlet.getId() === viewlet.id) {
...@@ -277,7 +287,7 @@ export class ActivitybarPart extends Part { ...@@ -277,7 +287,7 @@ export class ActivitybarPart extends Part {
} }
} }
private canShow(viewlet: ViewletDescriptor): boolean { private hasRegisteredViews(viewlet: ViewletDescriptor): boolean {
const viewLocation = ViewLocation.get(viewlet.id); const viewLocation = ViewLocation.get(viewlet.id);
if (viewLocation) { if (viewLocation) {
return ViewsRegistry.getViews(viewLocation).length > 0; return ViewsRegistry.getViews(viewLocation).length > 0;
...@@ -313,7 +323,7 @@ export class ActivitybarPart extends Part { ...@@ -313,7 +323,7 @@ export class ActivitybarPart extends Part {
} }
public shutdown(): void { public shutdown(): void {
const state = this.viewletService.getViewlets().filter(viewlet => !!viewlet.iconUrl && this.canShow(viewlet)).map(viewlet => ({ id: viewlet.id, iconUrl: viewlet.iconUrl })); const state = this.viewletService.getViewlets().filter(viewlet => this.hasRegisteredViews(viewlet)).map(viewlet => ({ id: viewlet.id, iconUrl: viewlet.iconUrl }));
this.storageService.store(ActivitybarPart.PLACEHOLDER_VIEWLETS, JSON.stringify(state), StorageScope.GLOBAL); this.storageService.store(ActivitybarPart.PLACEHOLDER_VIEWLETS, JSON.stringify(state), StorageScope.GLOBAL);
this.compositeBar.shutdown(); this.compositeBar.shutdown();
super.shutdown(); super.shutdown();
...@@ -360,7 +370,7 @@ class PlaceHolderViewletActivityAction extends ViewletActivityAction { ...@@ -360,7 +370,7 @@ class PlaceHolderViewletActivityAction extends ViewletActivityAction {
class PlaceHolderToggleCompositePinnedAction extends ToggleCompositePinnedAction { class PlaceHolderToggleCompositePinnedAction extends ToggleCompositePinnedAction {
constructor( constructor(
id: string, iconUrl: string, compositeBar: ICompositeBar id: string, compositeBar: ICompositeBar
) { ) {
super({ id, name: id, cssClass: void 0 }, compositeBar); super({ id, name: id, cssClass: void 0 }, compositeBar);
this.enabled = false; this.enabled = false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册