@@ -56,6 +56,7 @@ import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
5656import { SingleServerExtensionManagementServerService } from 'vs/workbench/services/extensions/node/extensionManagementServerService' ;
5757import { Query } from 'vs/workbench/parts/extensions/common/extensionQuery' ;
5858import { SuggestEnabledInput , attachSuggestEnabledInputBoxStyler } from 'vs/workbench/parts/codeEditor/browser/suggestEnabledInput' ;
59+ import { alert } from 'vs/base/browser/ui/aria/aria' ;
5960
6061interface SearchInputEvent extends Event {
6162 target : HTMLInputElement ;
@@ -69,6 +70,18 @@ const SearchBuiltInExtensionsContext = new RawContextKey<boolean>('searchBuiltIn
6970const RecommendedExtensionsContext = new RawContextKey < boolean > ( 'recommendedExtensions' , false ) ;
7071const DefaultRecommendedExtensionsContext = new RawContextKey < boolean > ( 'defaultRecommendedExtensions' , false ) ;
7172const GroupByServersContext = new RawContextKey < boolean > ( 'groupByServersContext' , false ) ;
73+ const viewIdNameMappings : { [ id : string ] : string } = {
74+ 'extensions.listView' : localize ( 'marketPlace' , "Marketplace" ) ,
75+ 'extensions.enabledExtensionList' : localize ( 'enabledExtensions' , "Enabled" ) ,
76+ 'extensions.disabledExtensionList' : localize ( 'disabledExtensions' , "Disabled" ) ,
77+ 'extensions.popularExtensionsList' : localize ( 'popularExtensions' , "Popular" ) ,
78+ 'extensions.recommendedList' : localize ( 'recommendedExtensions' , "Recommended" ) ,
79+ 'extensions.otherrecommendedList' : localize ( 'otherRecommendedExtensions' , "Other Recommendations" ) ,
80+ 'extensions.workspaceRecommendedList' : localize ( 'workspaceRecommendedExtensions' , "Workspace Recommendations" ) ,
81+ 'extensions.builtInExtensionsList' : localize ( 'builtInExtensions' , "Features" ) ,
82+ 'extensions.builtInThemesExtensionsList' : localize ( 'builtInThemesExtensions' , "Themes" ) ,
83+ 'extensions.builtInBasicsExtensionsList' : localize ( 'builtInBasicsExtensions' , "Programming Languages" ) ,
84+ } ;
7285
7386export class ExtensionsViewletViewsContribution implements IWorkbenchContribution {
7487
@@ -101,9 +114,10 @@ export class ExtensionsViewletViewsContribution implements IWorkbenchContributio
101114 }
102115
103116 private createMarketPlaceExtensionsListViewDescriptor ( ) : IViewDescriptor {
117+ const id = 'extensions.listView' ;
104118 return {
105- id : 'extensions.listView' ,
106- name : localize ( 'marketPlace' , "Marketplace" ) ,
119+ id,
120+ name : viewIdNameMappings [ id ] ,
107121 container : VIEW_CONTAINER ,
108122 ctor : ExtensionsListView ,
109123 when : ContextKeyExpr . and ( ContextKeyExpr . has ( 'searchExtensions' ) , ContextKeyExpr . not ( 'searchInstalledExtensions' ) , ContextKeyExpr . not ( 'searchBuiltInExtensions' ) , ContextKeyExpr . not ( 'recommendedExtensions' ) , ContextKeyExpr . not ( 'groupByServersContext' ) ) ,
@@ -112,9 +126,10 @@ export class ExtensionsViewletViewsContribution implements IWorkbenchContributio
112126 }
113127
114128 private createEnabledExtensionsListViewDescriptor ( ) : IViewDescriptor {
129+ const id = 'extensions.enabledExtensionList' ;
115130 return {
116- id : 'extensions.enabledExtensionList' ,
117- name : localize ( 'enabledExtensions' , "Enabled" ) ,
131+ id,
132+ name : viewIdNameMappings [ id ] ,
118133 container : VIEW_CONTAINER ,
119134 ctor : EnabledExtensionsView ,
120135 when : ContextKeyExpr . and ( ContextKeyExpr . not ( 'searchExtensions' ) , ContextKeyExpr . has ( 'hasInstalledExtensions' ) ) ,
@@ -125,9 +140,10 @@ export class ExtensionsViewletViewsContribution implements IWorkbenchContributio
125140 }
126141
127142 private createDisabledExtensionsListViewDescriptor ( ) : IViewDescriptor {
143+ const id = 'extensions.disabledExtensionList' ;
128144 return {
129- id : 'extensions.disabledExtensionList' ,
130- name : localize ( 'disabledExtensions' , "Disabled" ) ,
145+ id,
146+ name : viewIdNameMappings [ id ] ,
131147 container : VIEW_CONTAINER ,
132148 ctor : DisabledExtensionsView ,
133149 when : ContextKeyExpr . and ( ContextKeyExpr . not ( 'searchExtensions' ) , ContextKeyExpr . has ( 'hasInstalledExtensions' ) ) ,
@@ -139,9 +155,10 @@ export class ExtensionsViewletViewsContribution implements IWorkbenchContributio
139155 }
140156
141157 private createPopularExtensionsListViewDescriptor ( ) : IViewDescriptor {
158+ const id = 'extensions.popularExtensionsList' ;
142159 return {
143- id : 'extensions.popularExtensionsList' ,
144- name : localize ( 'popularExtensions' , "Popular" ) ,
160+ id,
161+ name : viewIdNameMappings [ id ] ,
145162 container : VIEW_CONTAINER ,
146163 ctor : ExtensionsListView ,
147164 when : ContextKeyExpr . and ( ContextKeyExpr . not ( 'searchExtensions' ) , ContextKeyExpr . not ( 'hasInstalledExtensions' ) ) ,
@@ -162,9 +179,10 @@ export class ExtensionsViewletViewsContribution implements IWorkbenchContributio
162179 }
163180
164181 private createDefaultRecommendedExtensionsListViewDescriptor ( ) : IViewDescriptor {
182+ const id = 'extensions.recommendedList' ;
165183 return {
166- id : 'extensions.recommendedList' ,
167- name : localize ( 'recommendedExtensions' , "Recommended" ) ,
184+ id,
185+ name : viewIdNameMappings [ id ] ,
168186 container : VIEW_CONTAINER ,
169187 ctor : DefaultRecommendedExtensionsView ,
170188 when : ContextKeyExpr . and ( ContextKeyExpr . not ( 'searchExtensions' ) , ContextKeyExpr . has ( 'defaultRecommendedExtensions' ) ) ,
@@ -175,9 +193,10 @@ export class ExtensionsViewletViewsContribution implements IWorkbenchContributio
175193 }
176194
177195 private createOtherRecommendedExtensionsListViewDescriptor ( ) : IViewDescriptor {
196+ const id = 'extensions.otherrecommendedList' ;
178197 return {
179- id : 'extensions.otherrecommendedList' ,
180- name : localize ( 'otherRecommendedExtensions' , "Other Recommendations" ) ,
198+ id,
199+ name : viewIdNameMappings [ id ] ,
181200 container : VIEW_CONTAINER ,
182201 ctor : RecommendedExtensionsView ,
183202 when : ContextKeyExpr . has ( 'recommendedExtensions' ) ,
@@ -188,9 +207,10 @@ export class ExtensionsViewletViewsContribution implements IWorkbenchContributio
188207 }
189208
190209 private createWorkspaceRecommendedExtensionsListViewDescriptor ( ) : IViewDescriptor {
210+ const id = 'extensions.workspaceRecommendedList' ;
191211 return {
192- id : 'extensions.workspaceRecommendedList' ,
193- name : localize ( 'workspaceRecommendedExtensions' , "Workspace Recommendations" ) ,
212+ id,
213+ name : viewIdNameMappings [ id ] ,
194214 container : VIEW_CONTAINER ,
195215 ctor : WorkspaceRecommendedExtensionsView ,
196216 when : ContextKeyExpr . and ( ContextKeyExpr . has ( 'recommendedExtensions' ) , ContextKeyExpr . has ( 'nonEmptyWorkspace' ) ) ,
@@ -201,9 +221,10 @@ export class ExtensionsViewletViewsContribution implements IWorkbenchContributio
201221 }
202222
203223 private createBuiltInExtensionsListViewDescriptor ( ) : IViewDescriptor {
224+ const id = 'extensions.builtInExtensionsList' ;
204225 return {
205- id : 'extensions.builtInExtensionsList' ,
206- name : localize ( 'builtInExtensions' , "Features" ) ,
226+ id,
227+ name : viewIdNameMappings [ id ] ,
207228 container : VIEW_CONTAINER ,
208229 ctor : BuiltInExtensionsView ,
209230 when : ContextKeyExpr . has ( 'searchBuiltInExtensions' ) ,
@@ -213,9 +234,10 @@ export class ExtensionsViewletViewsContribution implements IWorkbenchContributio
213234 }
214235
215236 private createBuiltInThemesExtensionsListViewDescriptor ( ) : IViewDescriptor {
237+ const id = 'extensions.builtInThemesExtensionsList' ;
216238 return {
217- id : 'extensions.builtInThemesExtensionsList' ,
218- name : localize ( 'builtInThemesExtensions' , "Themes" ) ,
239+ id,
240+ name : viewIdNameMappings [ id ] ,
219241 container : VIEW_CONTAINER ,
220242 ctor : BuiltInThemesExtensionsView ,
221243 when : ContextKeyExpr . has ( 'searchBuiltInExtensions' ) ,
@@ -225,9 +247,10 @@ export class ExtensionsViewletViewsContribution implements IWorkbenchContributio
225247 }
226248
227249 private createBuiltInBasicsExtensionsListViewDescriptor ( ) : IViewDescriptor {
250+ const id = 'extensions.builtInBasicsExtensionsList' ;
228251 return {
229- id : 'extensions.builtInBasicsExtensionsList' ,
230- name : localize ( 'builtInBasicsExtensions' , "Programming Languages" ) ,
252+ id,
253+ name : viewIdNameMappings [ id ] ,
231254 container : VIEW_CONTAINER ,
232255 ctor : BuiltInBasicsExtensionsView ,
233256 when : ContextKeyExpr . has ( 'searchBuiltInExtensions' ) ,
@@ -432,17 +455,46 @@ export class ExtensionsViewlet extends ViewContainerViewlet implements IExtensio
432455 this . nonEmptyWorkspaceContextKey . set ( this . contextService . getWorkbenchState ( ) !== WorkbenchState . EMPTY ) ;
433456
434457 if ( value ) {
435- return this . progress ( TPromise . join ( this . panels . map ( view => ( < ExtensionsListView > view ) . show ( this . normalizedQuery ( ) ) ) ) ) ;
458+ return this . progress ( TPromise . join ( this . panels . map ( view => {
459+ ( < ExtensionsListView > view ) . show ( this . normalizedQuery ( ) ) . then ( model => {
460+ this . alertSearchResult ( model . length , view . id ) ;
461+ } ) ;
462+ } ) ) ) ;
436463 }
437464 return TPromise . as ( null ) ;
438465 }
439466
440467 protected onDidAddViews ( added : IAddedViewDescriptorRef [ ] ) : ViewletPanel [ ] {
441468 const addedViews = super . onDidAddViews ( added ) ;
442- this . progress ( TPromise . join ( addedViews . map ( addedView => ( < ExtensionsListView > addedView ) . show ( this . normalizedQuery ( ) ) ) ) ) ;
469+ this . progress ( TPromise . join ( addedViews . map ( addedView => {
470+ ( < ExtensionsListView > addedView ) . show ( this . normalizedQuery ( ) ) . then ( model => {
471+ this . alertSearchResult ( model . length , addedView . id ) ;
472+ } ) ;
473+ } ) ) ) ;
443474 return addedViews ;
444475 }
445476
477+ private alertSearchResult ( count : number , viewId : string ) {
478+ switch ( count ) {
479+ case 0 :
480+ break ;
481+ case 1 :
482+ if ( viewIdNameMappings [ viewId ] ) {
483+ alert ( localize ( 'extensionFoundInSection' , "1 extension found in the {0} section." , viewIdNameMappings [ viewId ] ) ) ;
484+ } else {
485+ alert ( localize ( 'extensionFound' , "1 extension found." ) ) ;
486+ }
487+ break ;
488+ default :
489+ if ( viewIdNameMappings [ viewId ] ) {
490+ alert ( localize ( 'extensionsFoundInSection' , "{0} extensions found in the {1} section." , count , viewIdNameMappings [ viewId ] ) ) ;
491+ } else {
492+ alert ( localize ( 'extensionsFound' , "{0} extensions found." , count ) ) ;
493+ }
494+ break ;
495+ }
496+ }
497+
446498 protected createView ( viewDescriptor : IViewDescriptor , options : IViewletViewOptions ) : ViewletPanel {
447499 for ( const extensionManagementServer of this . extensionManagementServerService . extensionManagementServers ) {
448500 if ( viewDescriptor . id === `server.extensionsList.${ extensionManagementServer . authority } ` ) {
0 commit comments