diff --git a/src/vs/workbench/browser/parts/activitybar/activitybarActions.ts b/src/vs/workbench/browser/parts/activitybar/activitybarActions.ts index 3530176196779ddea193ba87f972cab6797b273e..9f25cc84d7bff808a671712d7594bd78264d27ef 100644 --- a/src/vs/workbench/browser/parts/activitybar/activitybarActions.ts +++ b/src/vs/workbench/browser/parts/activitybar/activitybarActions.ts @@ -166,7 +166,7 @@ export class GlobalActivityActionItem extends ActivityActionItem { } } -export class PlaceHolderViewletActivityAction extends ViewletActivityAction { +export class CachedViewletActivityAction extends ViewletActivityAction { constructor( id: string, iconUrl: URI, @@ -185,7 +185,7 @@ export class PlaceHolderViewletActivityAction extends ViewletActivityAction { } } -export class PlaceHolderToggleCompositePinnedAction extends ToggleCompositePinnedAction { +export class CachedToggleCompositePinnedAction extends ToggleCompositePinnedAction { constructor(id: string, compositeBar: ICompositeBar) { super({ id, name: id, cssClass: void 0 }, compositeBar); diff --git a/src/vs/workbench/browser/parts/activitybar/activitybarPart.ts b/src/vs/workbench/browser/parts/activitybar/activitybarPart.ts index b6323a910dffb3f5318b3996cb8d4bbb2e1ffe0a..b572ff8dfcfeb049ef0853bc03772e9b1a6515c3 100644 --- a/src/vs/workbench/browser/parts/activitybar/activitybarPart.ts +++ b/src/vs/workbench/browser/parts/activitybar/activitybarPart.ts @@ -10,7 +10,7 @@ import { ActionsOrientation, ActionBar } from 'vs/base/browser/ui/actionbar/acti import { GlobalActivityExtensions, IGlobalActivityRegistry } from 'vs/workbench/common/activity'; import { Registry } from 'vs/platform/registry/common/platform'; import { Part } from 'vs/workbench/browser/part'; -import { GlobalActivityActionItem, GlobalActivityAction, ViewletActivityAction, ToggleViewletAction, PlaceHolderToggleCompositePinnedAction, PlaceHolderViewletActivityAction } from 'vs/workbench/browser/parts/activitybar/activitybarActions'; +import { GlobalActivityActionItem, GlobalActivityAction, ViewletActivityAction, ToggleViewletAction, CachedToggleCompositePinnedAction, CachedViewletActivityAction } from 'vs/workbench/browser/parts/activitybar/activitybarActions'; import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet'; import { IBadge } from 'vs/workbench/services/activity/common/activity'; import { IPartService, Parts, Position as SideBarPosition } from 'vs/workbench/services/part/common/partService'; @@ -33,12 +33,12 @@ import { ViewletDescriptor } from 'vs/workbench/browser/viewlet'; import { IViewsService, IViewContainersRegistry, Extensions as ViewContainerExtensions } from 'vs/workbench/common/views'; import { IContextKeyService, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; -interface IPlaceholderComposite { +interface ICachedComposite { id: string; iconUrl: URI; } -interface ISerializedPlaceholderComposite extends IPlaceholderComposite { +interface ISerializedCachedComposite extends ICachedComposite { whens?: string[]; } @@ -46,14 +46,14 @@ export class ActivitybarPart extends Part { private static readonly ACTION_HEIGHT = 50; private static readonly PINNED_VIEWLETS = 'workbench.activity.pinnedViewlets'; - private static readonly PLACEHOLDER_VIEWLETS = 'workbench.activity.placeholderViewlets'; + private static readonly CACHED_VIEWLETS = 'workbench.activity.placeholderViewlets'; private dimension: Dimension; private globalActionBar: ActionBar; private globalActivityIdToActions: { [globalActivityId: string]: GlobalActivityAction; } = Object.create(null); - private placeholderComposites: IPlaceholderComposite[] = []; + private cachedComposites: ICachedComposite[] = []; private compositeBar: CompositeBar; private compositeActions: { [compositeId: string]: { activityAction: ViewletActivityAction, pinnedAction: ToggleCompositePinnedAction } } = Object.create(null); @@ -87,17 +87,17 @@ export class ActivitybarPart extends Part { overflowActionSize: ActivitybarPart.ACTION_HEIGHT })); - const previousState = this.storageService.get(ActivitybarPart.PLACEHOLDER_VIEWLETS, StorageScope.GLOBAL, '[]'); - const serializedPlaceholderComposites = JSON.parse(previousState); - this.placeholderComposites = []; - for (const { id, iconUrl, whens } of serializedPlaceholderComposites) { + const previousState = this.storageService.get(ActivitybarPart.CACHED_VIEWLETS, StorageScope.GLOBAL, '[]'); + const serializedCachedComposites = JSON.parse(previousState); + this.cachedComposites = []; + for (const { id, iconUrl, whens } of serializedCachedComposites) { if (whens && whens.length > 0) { if (whens.every(when => !contextKeyService.contextMatchesRules(ContextKeyExpr.deserialize(when)))) { // Hidden by default continue; } } - this.placeholderComposites.push({ + this.cachedComposites.push({ id, iconUrl: typeof iconUrl === 'object' ? URI.revive(iconUrl) : void 0 }); @@ -253,10 +253,10 @@ export class ActivitybarPart extends Part { pinnedAction: new ToggleCompositePinnedAction(viewlet, this.compositeBar) }; } else { - const placeHolderComposite = this.placeholderComposites.filter(c => c.id === compositeId)[0]; + const cachedComposite = this.cachedComposites.filter(c => c.id === compositeId)[0]; compositeActions = { - activityAction: this.instantiationService.createInstance(PlaceHolderViewletActivityAction, compositeId, placeHolderComposite && placeHolderComposite.iconUrl), - pinnedAction: new PlaceHolderToggleCompositePinnedAction(compositeId, this.compositeBar) + activityAction: this.instantiationService.createInstance(CachedViewletActivityAction, compositeId, cachedComposite && cachedComposite.iconUrl), + pinnedAction: new CachedToggleCompositePinnedAction(compositeId, this.compositeBar) }; } @@ -271,8 +271,8 @@ export class ActivitybarPart extends Part { for (const viewlet of viewlets) { this.compositeBar.addComposite(viewlet); - // Pin it by default if it is new => it does not has a placeholder - if (this.placeholderComposites.every(c => c.id !== viewlet.id)) { + // Pin it by default if it is new => it is not in cache + if (this.cachedComposites.every(c => c.id !== viewlet.id)) { this.compositeBar.pin(viewlet.id); } @@ -309,10 +309,10 @@ export class ActivitybarPart extends Part { private enableCompositeActions(viewlet: ViewletDescriptor): void { const { activityAction, pinnedAction } = this.getCompositeActions(viewlet.id); - if (activityAction instanceof PlaceHolderViewletActivityAction) { + if (activityAction instanceof CachedViewletActivityAction) { activityAction.setActivity(viewlet); } - if (pinnedAction instanceof PlaceHolderToggleCompositePinnedAction) { + if (pinnedAction instanceof CachedToggleCompositePinnedAction) { pinnedAction.setActivity(viewlet); } } @@ -347,7 +347,7 @@ export class ActivitybarPart extends Part { protected saveState(): void { const viewContainerRegistry = Registry.as(ViewContainerExtensions.ViewContainersRegistry); - const state: ISerializedPlaceholderComposite[] = []; + const state: ISerializedCachedComposite[] = []; for (const { id, iconUrl } of this.viewletService.getAllViewlets()) { const viewContainer = viewContainerRegistry.get(id); const whens: string[] = []; @@ -360,7 +360,7 @@ export class ActivitybarPart extends Part { } state.push({ id, iconUrl, whens }); } - this.storageService.store(ActivitybarPart.PLACEHOLDER_VIEWLETS, JSON.stringify(state), StorageScope.GLOBAL); + this.storageService.store(ActivitybarPart.CACHED_VIEWLETS, JSON.stringify(state), StorageScope.GLOBAL); super.saveState(); }