Skip to content

Commit 285107a

Browse files
committed
Register views outside viewlet
1 parent ed76a26 commit 285107a

2 files changed

Lines changed: 64 additions & 56 deletions

File tree

src/vs/workbench/parts/extensions/electron-browser/extensions.contribution.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
import { ExtensionsInput } from 'vs/workbench/parts/extensions/common/extensionsInput';
2828
import { ViewletRegistry, Extensions as ViewletExtensions, ViewletDescriptor } from 'vs/workbench/browser/viewlet';
2929
import { ExtensionEditor } from 'vs/workbench/parts/extensions/electron-browser/extensionEditor';
30-
import { StatusUpdater, ExtensionsViewlet, MaliciousExtensionChecker } from 'vs/workbench/parts/extensions/electron-browser/extensionsViewlet';
30+
import { StatusUpdater, ExtensionsViewlet, MaliciousExtensionChecker, ExtensionsViewletViewsContribution } from 'vs/workbench/parts/extensions/electron-browser/extensionsViewlet';
3131
import { IQuickOpenRegistry, Extensions, QuickOpenHandlerDescriptor } from 'vs/workbench/browser/quickopen';
3232
import { IConfigurationRegistry, Extensions as ConfigurationExtensions, ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry';
3333
import * as jsonContributionRegistry from 'vs/platform/jsonschemas/common/jsonContributionRegistry';
@@ -54,6 +54,7 @@ workbenchRegistry.registerWorkbenchContribution(StatusUpdater, LifecyclePhase.Ru
5454
workbenchRegistry.registerWorkbenchContribution(MaliciousExtensionChecker, LifecyclePhase.Eventually);
5555
workbenchRegistry.registerWorkbenchContribution(ConfigureRecommendedExtensionsCommandsContributor, LifecyclePhase.Eventually);
5656
workbenchRegistry.registerWorkbenchContribution(KeymapExtensions, LifecyclePhase.Running);
57+
workbenchRegistry.registerWorkbenchContribution(ExtensionsViewletViewsContribution, LifecyclePhase.Starting);
5758

5859
Registry.as<IOutputChannelRegistry>(OutputExtensions.OutputChannels)
5960
.registerChannel(ExtensionsChannelId, ExtensionsLabel);

src/vs/workbench/parts/extensions/electron-browser/extensionsViewlet.ts

Lines changed: 62 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -66,65 +66,11 @@ const SearchBuiltInExtensionsContext = new RawContextKey<boolean>('searchBuiltIn
6666
const RecommendedExtensionsContext = new RawContextKey<boolean>('recommendedExtensions', false);
6767
const DefaultRecommendedExtensionsContext = new RawContextKey<boolean>('defaultRecommendedExtensions', false);
6868

69-
export class ExtensionsViewlet extends PersistentViewsViewlet implements IExtensionsViewlet {
70-
71-
private onSearchChange: EventOf<string>;
72-
private nonEmptyWorkspaceContextKey: IContextKey<boolean>;
73-
private searchExtensionsContextKey: IContextKey<boolean>;
74-
private searchInstalledExtensionsContextKey: IContextKey<boolean>;
75-
private searchBuiltInExtensionsContextKey: IContextKey<boolean>;
76-
private recommendedExtensionsContextKey: IContextKey<boolean>;
77-
private defaultRecommendedExtensionsContextKey: IContextKey<boolean>;
78-
79-
private searchDelayer: ThrottledDelayer<any>;
80-
private root: HTMLElement;
81-
82-
private searchBox: HTMLInputElement;
83-
private extensionsBox: HTMLElement;
84-
private primaryActions: IAction[];
85-
private secondaryActions: IAction[];
86-
private disposables: IDisposable[] = [];
69+
export class ExtensionsViewletViewsContribution implements IWorkbenchContribution {
8770

8871
constructor(
89-
@IPartService partService: IPartService,
90-
@ITelemetryService telemetryService: ITelemetryService,
91-
@IProgressService private progressService: IProgressService,
92-
@IInstantiationService instantiationService: IInstantiationService,
93-
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
94-
@IEditorGroupService private editorInputService: IEditorGroupService,
95-
@IExtensionManagementService private extensionManagementService: IExtensionManagementService,
96-
@INotificationService private notificationService: INotificationService,
97-
@IViewletService private viewletService: IViewletService,
98-
@IThemeService themeService: IThemeService,
99-
@IConfigurationService private configurationService: IConfigurationService,
100-
@IStorageService storageService: IStorageService,
101-
@IWorkspaceContextService contextService: IWorkspaceContextService,
102-
@IContextKeyService contextKeyService: IContextKeyService,
103-
@IContextMenuService contextMenuService: IContextMenuService,
104-
@IExtensionService extensionService: IExtensionService
10572
) {
106-
super(VIEWLET_ID, ViewLocation.Extensions, `${VIEWLET_ID}.state`, true, partService, telemetryService, storageService, instantiationService, themeService, contextService, contextKeyService, contextMenuService, extensionService);
107-
10873
this.registerViews();
109-
this.searchDelayer = new ThrottledDelayer(500);
110-
this.nonEmptyWorkspaceContextKey = NonEmptyWorkspaceContext.bindTo(contextKeyService);
111-
this.searchExtensionsContextKey = SearchExtensionsContext.bindTo(contextKeyService);
112-
this.searchInstalledExtensionsContextKey = SearchInstalledExtensionsContext.bindTo(contextKeyService);
113-
this.searchBuiltInExtensionsContextKey = SearchBuiltInExtensionsContext.bindTo(contextKeyService);
114-
this.recommendedExtensionsContextKey = RecommendedExtensionsContext.bindTo(contextKeyService);
115-
this.defaultRecommendedExtensionsContextKey = DefaultRecommendedExtensionsContext.bindTo(contextKeyService);
116-
this.defaultRecommendedExtensionsContextKey.set(!this.configurationService.getValue<boolean>(ShowRecommendationsOnlyOnDemandKey));
117-
this.disposables.push(this.viewletService.onDidViewletOpen(this.onViewletOpen, this, this.disposables));
118-
119-
this.configurationService.onDidChangeConfiguration(e => {
120-
if (e.affectsConfiguration(AutoUpdateConfigurationKey)) {
121-
this.secondaryActions = null;
122-
this.updateTitleArea();
123-
}
124-
if (e.affectedKeys.indexOf(ShowRecommendationsOnlyOnDemandKey) > -1) {
125-
this.defaultRecommendedExtensionsContextKey.set(!this.configurationService.getValue<boolean>(ShowRecommendationsOnlyOnDemandKey));
126-
}
127-
}, this, this.disposables);
12874
}
12975

13076
private registerViews(): void {
@@ -247,6 +193,67 @@ export class ExtensionsViewlet extends PersistentViewsViewlet implements IExtens
247193
canToggleVisibility: true
248194
};
249195
}
196+
}
197+
198+
export class ExtensionsViewlet extends PersistentViewsViewlet implements IExtensionsViewlet {
199+
200+
private onSearchChange: EventOf<string>;
201+
private nonEmptyWorkspaceContextKey: IContextKey<boolean>;
202+
private searchExtensionsContextKey: IContextKey<boolean>;
203+
private searchInstalledExtensionsContextKey: IContextKey<boolean>;
204+
private searchBuiltInExtensionsContextKey: IContextKey<boolean>;
205+
private recommendedExtensionsContextKey: IContextKey<boolean>;
206+
private defaultRecommendedExtensionsContextKey: IContextKey<boolean>;
207+
208+
private searchDelayer: ThrottledDelayer<any>;
209+
private root: HTMLElement;
210+
211+
private searchBox: HTMLInputElement;
212+
private extensionsBox: HTMLElement;
213+
private primaryActions: IAction[];
214+
private secondaryActions: IAction[];
215+
private disposables: IDisposable[] = [];
216+
217+
constructor(
218+
@IPartService partService: IPartService,
219+
@ITelemetryService telemetryService: ITelemetryService,
220+
@IProgressService private progressService: IProgressService,
221+
@IInstantiationService instantiationService: IInstantiationService,
222+
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
223+
@IEditorGroupService private editorInputService: IEditorGroupService,
224+
@IExtensionManagementService private extensionManagementService: IExtensionManagementService,
225+
@INotificationService private notificationService: INotificationService,
226+
@IViewletService private viewletService: IViewletService,
227+
@IThemeService themeService: IThemeService,
228+
@IConfigurationService private configurationService: IConfigurationService,
229+
@IStorageService storageService: IStorageService,
230+
@IWorkspaceContextService contextService: IWorkspaceContextService,
231+
@IContextKeyService contextKeyService: IContextKeyService,
232+
@IContextMenuService contextMenuService: IContextMenuService,
233+
@IExtensionService extensionService: IExtensionService
234+
) {
235+
super(VIEWLET_ID, ViewLocation.Extensions, `${VIEWLET_ID}.state`, true, partService, telemetryService, storageService, instantiationService, themeService, contextService, contextKeyService, contextMenuService, extensionService);
236+
237+
this.searchDelayer = new ThrottledDelayer(500);
238+
this.nonEmptyWorkspaceContextKey = NonEmptyWorkspaceContext.bindTo(contextKeyService);
239+
this.searchExtensionsContextKey = SearchExtensionsContext.bindTo(contextKeyService);
240+
this.searchInstalledExtensionsContextKey = SearchInstalledExtensionsContext.bindTo(contextKeyService);
241+
this.searchBuiltInExtensionsContextKey = SearchBuiltInExtensionsContext.bindTo(contextKeyService);
242+
this.recommendedExtensionsContextKey = RecommendedExtensionsContext.bindTo(contextKeyService);
243+
this.defaultRecommendedExtensionsContextKey = DefaultRecommendedExtensionsContext.bindTo(contextKeyService);
244+
this.defaultRecommendedExtensionsContextKey.set(!this.configurationService.getValue<boolean>(ShowRecommendationsOnlyOnDemandKey));
245+
this.disposables.push(this.viewletService.onDidViewletOpen(this.onViewletOpen, this, this.disposables));
246+
247+
this.configurationService.onDidChangeConfiguration(e => {
248+
if (e.affectsConfiguration(AutoUpdateConfigurationKey)) {
249+
this.secondaryActions = null;
250+
this.updateTitleArea();
251+
}
252+
if (e.affectedKeys.indexOf(ShowRecommendationsOnlyOnDemandKey) > -1) {
253+
this.defaultRecommendedExtensionsContextKey.set(!this.configurationService.getValue<boolean>(ShowRecommendationsOnlyOnDemandKey));
254+
}
255+
}, this, this.disposables);
256+
}
250257

251258
async create(parent: HTMLElement): TPromise<void> {
252259
addClass(parent, 'extensions-viewlet');

0 commit comments

Comments
 (0)