@@ -47,6 +47,7 @@ interface IPlaceholderViewlet {
4747 id : string ;
4848 name ?: string ;
4949 iconUrl ?: UriComponents ;
50+ iconCSS ?: string ;
5051 views ?: { when ?: string } [ ] ;
5152}
5253
@@ -60,7 +61,7 @@ interface IPinnedViewlet {
6061interface ICachedViewlet {
6162 id : string ;
6263 name ?: string ;
63- iconUrl ?: UriComponents ;
64+ icon ?: URI | string ;
6465 pinned : boolean ;
6566 order ?: number ;
6667 visible : boolean ;
@@ -444,7 +445,7 @@ export class ActivitybarPart extends Part implements IActivityBarService {
444445 } else {
445446 const cachedComposite = this . cachedViewlets . filter ( c => c . id === compositeId ) [ 0 ] ;
446447 compositeActions = {
447- activityAction : this . instantiationService . createInstance ( PlaceHolderViewletActivityAction , compositeId , cachedComposite ?. name || compositeId , cachedComposite ?. iconUrl ? URI . revive ( cachedComposite . iconUrl ) : undefined ) ,
448+ activityAction : this . instantiationService . createInstance ( PlaceHolderViewletActivityAction , compositeId , cachedComposite ?. icon ) ,
448449 pinnedAction : new PlaceHolderToggleCompositePinnedAction ( compositeId , this . compositeBar )
449450 } ;
450451 }
@@ -637,21 +638,25 @@ export class ActivitybarPart extends Part implements IActivityBarService {
637638
638639 private saveCachedViewlets ( ) : void {
639640 const state : ICachedViewlet [ ] = [ ] ;
640- const allViewlets = this . viewletService . getViewlets ( ) ;
641641
642642 const compositeItems = this . compositeBar . getCompositeBarItems ( ) ;
643643 for ( const compositeItem of compositeItems ) {
644644 const viewContainer = this . getViewContainer ( compositeItem . id ) ;
645- const viewlet = allViewlets . filter ( ( { id } ) => id === compositeItem . id ) [ 0 ] ;
646- if ( viewlet ) {
645+ if ( viewContainer ) {
646+ const viewContainerModel = this . viewDescriptorService . getViewContainerModel ( viewContainer ) ;
647647 const views : { when : string | undefined } [ ] = [ ] ;
648- if ( viewContainer ) {
649- const viewContainerModel = this . viewDescriptorService . getViewContainerModel ( viewContainer ) ;
650- for ( const { when } of viewContainerModel . allViewDescriptors ) {
651- views . push ( { when : when ? when . serialize ( ) : undefined } ) ;
652- }
648+ for ( const { when } of viewContainerModel . allViewDescriptors ) {
649+ views . push ( { when : when ? when . serialize ( ) : undefined } ) ;
653650 }
654- state . push ( { id : compositeItem . id , name : viewlet . name , iconUrl : viewlet . iconUrl && viewlet . iconUrl . scheme === Schemas . file ? viewlet . iconUrl : undefined , views, pinned : compositeItem . pinned , order : compositeItem . order , visible : compositeItem . visible } ) ;
651+ state . push ( {
652+ id : compositeItem . id ,
653+ name : viewContainerModel . title ,
654+ icon : URI . isUri ( viewContainerModel . icon ) && viewContainerModel . icon . scheme === Schemas . file ? viewContainerModel . icon : viewContainerModel . icon ,
655+ views,
656+ pinned : compositeItem . pinned ,
657+ order : compositeItem . order ,
658+ visible : compositeItem . visible
659+ } ) ;
655660 } else {
656661 state . push ( { id : compositeItem . id , pinned : compositeItem . pinned , order : compositeItem . order , visible : false } ) ;
657662 }
@@ -661,12 +666,13 @@ export class ActivitybarPart extends Part implements IActivityBarService {
661666 }
662667
663668 private getCachedViewlets ( ) : ICachedViewlet [ ] {
664- const cachedViewlets : Array < ICachedViewlet > = JSON . parse ( this . pinnedViewletsValue ) ;
665- for ( const placeholderViewlet of JSON . parse ( this . placeholderViewletsValue ) ) {
669+ const cachedViewlets : ICachedViewlet [ ] = this . getPinnedViewlets ( ) ;
670+ for ( const placeholderViewlet of this . getPlaceholderViewlets ( ) ) {
666671 const cachedViewlet = cachedViewlets . filter ( cached => cached . id === placeholderViewlet . id ) [ 0 ] ;
667672 if ( cachedViewlet ) {
668673 cachedViewlet . name = placeholderViewlet . name ;
669- cachedViewlet . iconUrl = placeholderViewlet . iconUrl ;
674+ cachedViewlet . icon = placeholderViewlet . iconCSS ? placeholderViewlet . iconCSS :
675+ placeholderViewlet . iconUrl ? URI . revive ( placeholderViewlet . iconUrl ) : undefined ;
670676 cachedViewlet . views = placeholderViewlet . views ;
671677 }
672678 }
@@ -675,8 +681,27 @@ export class ActivitybarPart extends Part implements IActivityBarService {
675681 }
676682
677683 private storeCachedViewletsState ( cachedViewlets : ICachedViewlet [ ] ) : void {
678- this . pinnedViewletsValue = JSON . stringify ( cachedViewlets . map ( ( { id, pinned, visible, order } ) => ( < IPinnedViewlet > { id, pinned, visible, order } ) ) ) ;
679- this . placeholderViewletsValue = JSON . stringify ( cachedViewlets . map ( ( { id, iconUrl, name, views } ) => ( < IPlaceholderViewlet > { id, iconUrl, name, views } ) ) ) ;
684+ this . setPinnedViewlets ( cachedViewlets . map ( ( { id, pinned, visible, order } ) => ( < IPinnedViewlet > {
685+ id,
686+ pinned,
687+ visible,
688+ order
689+ } ) ) ) ;
690+ this . setPlaceholderViewlets ( cachedViewlets . map ( ( { id, icon, name, views } ) => ( < IPlaceholderViewlet > {
691+ id,
692+ iconUrl : URI . isUri ( icon ) ? icon : undefined ,
693+ iconCSS : isString ( icon ) ? icon : undefined ,
694+ name,
695+ views
696+ } ) ) ) ;
697+ }
698+
699+ private getPinnedViewlets ( ) : IPinnedViewlet [ ] {
700+ return JSON . parse ( this . pinnedViewletsValue ) ;
701+ }
702+
703+ private setPinnedViewlets ( pinnedViewlets : IPinnedViewlet [ ] ) : void {
704+ this . pinnedViewletsValue = JSON . stringify ( pinnedViewlets ) ;
680705 }
681706
682707 private _pinnedViewletsValue : string | undefined ;
@@ -703,6 +728,14 @@ export class ActivitybarPart extends Part implements IActivityBarService {
703728 this . storageService . store ( ActivitybarPart . PINNED_VIEWLETS , value , StorageScope . GLOBAL ) ;
704729 }
705730
731+ private getPlaceholderViewlets ( ) : IPlaceholderViewlet [ ] {
732+ return JSON . parse ( this . placeholderViewletsValue ) ;
733+ }
734+
735+ private setPlaceholderViewlets ( placeholderViewlets : IPlaceholderViewlet [ ] ) : void {
736+ this . placeholderViewletsValue = JSON . stringify ( placeholderViewlets ) ;
737+ }
738+
706739 private _placeholderViewletsValue : string | undefined ;
707740 private get placeholderViewletsValue ( ) : string {
708741 if ( ! this . _placeholderViewletsValue ) {
@@ -732,7 +765,7 @@ export class ActivitybarPart extends Part implements IActivityBarService {
732765 if ( value !== undefined ) {
733766 const storedStates : Array < string | ICachedViewlet > = JSON . parse ( value ) ;
734767 const cachedViewlets = storedStates . map ( c => {
735- const serialized : ICachedViewlet = typeof c === 'string' /* migration from pinned states to composites states */ ? { id : c , pinned : true , order : undefined , visible : true , name : undefined , iconUrl : undefined , views : undefined } : c ;
768+ const serialized : ICachedViewlet = typeof c === 'string' /* migration from pinned states to composites states */ ? { id : c , pinned : true , order : undefined , visible : true , name : undefined , icon : undefined , views : undefined } : c ;
736769 serialized . visible = isUndefinedOrNull ( serialized . visible ) ? true : serialized . visible ;
737770 return serialized ;
738771 } ) ;
0 commit comments