提交 14657a93 编写于 作者: S Sandeep Somavarapu

move viewlet & panel registry into views service

上级 6f230c5f
......@@ -486,11 +486,10 @@ export class ViewsService extends Disposable implements IViewsService {
this._register(this.viewContainersRegistry.onDidRegister(({ viewContainer, viewContainerLocation }) => this.onDidRegisterViewContainer(viewContainer, viewContainerLocation)));
}
registerViewPaneContainer(viewPaneContainer: ViewPaneContainer): ViewPaneContainer {
private registerViewPaneContainer(viewPaneContainer: ViewPaneContainer): void {
this._register(viewPaneContainer.onDidAddViews(views => this.onViewsAdded(views)));
this._register(viewPaneContainer.onDidChangeViewVisibility(view => this.onViewsVisibilityChanged(view, view.isBodyVisible())));
this._register(viewPaneContainer.onDidRemoveViews(views => this.onViewsRemoved(views)));
return viewPaneContainer;
}
private onViewsAdded(added: IView[]): void {
......@@ -520,7 +519,8 @@ export class ViewsService extends Disposable implements IViewsService {
return contextKey;
}
private onDidRegisterViewContainer(viewContainer: ViewContainer, location: ViewContainerLocation): void {
private onDidRegisterViewContainer(viewContainer: ViewContainer, viewContainerLocation: ViewContainerLocation): void {
this.registerViewletOrPanel(viewContainer, viewContainerLocation);
const viewDescriptorCollection = this.viewDescriptorService.getViewDescriptors(viewContainer);
this.onViewDescriptorsAdded(viewDescriptorCollection.allViewDescriptors, viewContainer);
this._register(viewDescriptorCollection.onDidChangeViews(({ added, removed }) => {
......@@ -698,26 +698,22 @@ export class ViewsService extends Disposable implements IViewsService {
return null;
}
}
export function createFileIconThemableTreeContainerScope(container: HTMLElement, themeService: IThemeService): IDisposable {
addClass(container, 'file-icon-themable-tree');
addClass(container, 'show-file-icons');
const onDidChangeFileIconTheme = (theme: IFileIconTheme) => {
toggleClass(container, 'align-icons-and-twisties', theme.hasFileIcons && !theme.hasFolderIcons);
toggleClass(container, 'hide-arrows', theme.hidesExplorerArrows === true);
};
onDidChangeFileIconTheme(themeService.getFileIconTheme());
return themeService.onDidFileIconThemeChange(onDidChangeFileIconTheme);
}
registerSingleton(IViewsService, ViewsService);
private registerViewletOrPanel(viewContainer: ViewContainer, viewContainerLocation: ViewContainerLocation): void {
switch (viewContainerLocation) {
case ViewContainerLocation.Panel:
this.registerPanel(viewContainer);
break;
case ViewContainerLocation.Sidebar:
if (viewContainer.ctorDescriptor) {
this.registerViewlet(viewContainer);
}
break;
}
}
// Viewlets & Panels
(function registerViewletsAndPanels(): void {
const registerPanel = (viewContainer: ViewContainer): void => {
private registerPanel(viewContainer: ViewContainer): void {
const that = this;
class PaneContainerPanel extends PaneCompositePanel {
constructor(
@ITelemetryService telemetryService: ITelemetryService,
......@@ -727,11 +723,11 @@ registerSingleton(IViewsService, ViewsService);
@IContextMenuService contextMenuService: IContextMenuService,
@IExtensionService extensionService: IExtensionService,
@IWorkspaceContextService contextService: IWorkspaceContextService,
@IViewsService viewsService: ViewsService
) {
// Use composite's instantiation service to get the editor progress service for any editors instantiated within the composite
const viewPaneContainer = viewsService.registerViewPaneContainer((instantiationService as any).createInstance(viewContainer.ctorDescriptor!.ctor, ...(viewContainer.ctorDescriptor!.staticArguments || [])));
const viewPaneContainer = (instantiationService as any).createInstance(viewContainer.ctorDescriptor!.ctor, ...(viewContainer.ctorDescriptor!.staticArguments || []));
super(viewContainer.id, viewPaneContainer, telemetryService, storageService, instantiationService, themeService, contextMenuService, extensionService, contextService);
that.registerViewPaneContainer(this.viewPaneContainer);
}
}
Registry.as<PanelRegistry>(PanelExtensions.Panels).registerPanel(PanelDescriptor.create(
......@@ -742,9 +738,10 @@ registerSingleton(IViewsService, ViewsService);
viewContainer.order,
viewContainer.focusCommand?.id,
));
};
}
const registerViewlet = (viewContainer: ViewContainer): void => {
private registerViewlet(viewContainer: ViewContainer): void {
const that = this;
class PaneContainerViewlet extends Viewlet {
constructor(
@IConfigurationService configurationService: IConfigurationService,
......@@ -756,37 +753,35 @@ registerSingleton(IViewsService, ViewsService);
@IThemeService themeService: IThemeService,
@IContextMenuService contextMenuService: IContextMenuService,
@IExtensionService extensionService: IExtensionService,
@IViewsService viewsService: ViewsService
) {
// Use composite's instantiation service to get the editor progress service for any editors instantiated within the composite
const viewPaneContainer = viewsService.registerViewPaneContainer((instantiationService as any).createInstance(viewContainer.ctorDescriptor!.ctor, ...(viewContainer.ctorDescriptor!.staticArguments || [])));
const viewPaneContainer = (instantiationService as any).createInstance(viewContainer.ctorDescriptor!.ctor, ...(viewContainer.ctorDescriptor!.staticArguments || []));
super(viewContainer.id, viewPaneContainer, telemetryService, storageService, instantiationService, themeService, contextMenuService, extensionService, contextService, layoutService, configurationService);
that.registerViewPaneContainer(this.viewPaneContainer);
}
}
const viewletDescriptor = ViewletDescriptor.create(
Registry.as<ViewletRegistry>(ViewletExtensions.Viewlets).registerViewlet(ViewletDescriptor.create(
PaneContainerViewlet,
viewContainer.id,
viewContainer.name,
isString(viewContainer.icon) ? viewContainer.icon : undefined,
viewContainer.order,
viewContainer.icon instanceof URI ? viewContainer.icon : undefined
);
));
}
}
Registry.as<ViewletRegistry>(ViewletExtensions.Viewlets).registerViewlet(viewletDescriptor);
export function createFileIconThemableTreeContainerScope(container: HTMLElement, themeService: IThemeService): IDisposable {
addClass(container, 'file-icon-themable-tree');
addClass(container, 'show-file-icons');
const onDidChangeFileIconTheme = (theme: IFileIconTheme) => {
toggleClass(container, 'align-icons-and-twisties', theme.hasFileIcons && !theme.hasFolderIcons);
toggleClass(container, 'hide-arrows', theme.hidesExplorerArrows === true);
};
const viewContainerRegistry = Registry.as<IViewContainersRegistry>(ViewExtensions.ViewContainersRegistry);
viewContainerRegistry.getViewContainers(ViewContainerLocation.Panel).forEach(viewContainer => registerPanel(viewContainer));
viewContainerRegistry.onDidRegister(({ viewContainer, viewContainerLocation }) => {
switch (viewContainerLocation) {
case ViewContainerLocation.Panel:
registerPanel(viewContainer);
return;
case ViewContainerLocation.Sidebar:
if (viewContainer.ctorDescriptor) {
registerViewlet(viewContainer);
}
return;
}
});
})();
onDidChangeFileIconTheme(themeService.getFileIconTheme());
return themeService.onDidFileIconThemeChange(onDidChangeFileIconTheme);
}
registerSingleton(IViewsService, ViewsService);
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册