提交 3385ec73 编写于 作者: B Benjamin Pasero

debt - declarative context view service

上级 c4de96ce
......@@ -686,4 +686,10 @@ export class SimpleLayoutService implements ILayoutService {
return this._dimension;
}
get container(): HTMLElement {
return this._container;
}
constructor(private _container: HTMLElement) { }
}
......@@ -197,9 +197,9 @@ export class DynamicStandaloneServices extends Disposable {
let keybindingService = ensure(IKeybindingService, () => this._register(new StandaloneKeybindingService(contextKeyService, commandService, telemetryService, notificationService, domElement)));
let layoutService = ensure(ILayoutService, () => new SimpleLayoutService());
let layoutService = ensure(ILayoutService, () => new SimpleLayoutService(domElement));
let contextViewService = ensure(IContextViewService, () => this._register(new ContextViewService(domElement, telemetryService, new NullLogService(), layoutService)));
let contextViewService = ensure(IContextViewService, () => this._register(new ContextViewService(layoutService)));
ensure(IContextMenuService, () => this._register(new ContextMenuService(domElement, telemetryService, notificationService, contextViewService, keybindingService, themeService)));
......
......@@ -5,10 +5,9 @@
import { IContextViewService, IContextViewDelegate } from './contextView';
import { ContextView } from 'vs/base/browser/ui/contextview/contextview';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { ILogService } from 'vs/platform/log/common/log';
import { Disposable } from 'vs/base/common/lifecycle';
import { ILayoutService } from 'vs/platform/layout/browser/layoutService';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
export class ContextViewService extends Disposable implements IContextViewService {
_serviceBrand: any;
......@@ -16,14 +15,11 @@ export class ContextViewService extends Disposable implements IContextViewServic
private contextView: ContextView;
constructor(
container: HTMLElement,
@ITelemetryService telemetryService: ITelemetryService,
@ILogService private readonly logService: ILogService,
@ILayoutService readonly layoutService: ILayoutService
) {
super();
this.contextView = this._register(new ContextView(container));
this.contextView = this._register(new ContextView(layoutService.container));
this.layout();
this._register(layoutService.onLayout(() => this.layout()));
......@@ -32,12 +28,10 @@ export class ContextViewService extends Disposable implements IContextViewServic
// ContextView
setContainer(container: HTMLElement): void {
this.logService.trace('ContextViewService#setContainer');
this.contextView.setContainer(container);
}
showContextView(delegate: IContextViewDelegate): void {
this.logService.trace('ContextViewService#showContextView');
this.contextView.show(delegate);
}
......@@ -46,7 +40,8 @@ export class ContextViewService extends Disposable implements IContextViewServic
}
hideContextView(data?: any): void {
this.logService.trace('ContextViewService#hideContextView');
this.contextView.hide(data);
}
}
\ No newline at end of file
}
registerSingleton(IContextViewService, ContextViewService, true);
\ No newline at end of file
......@@ -22,6 +22,11 @@ export interface ILayoutService {
*/
readonly dimension: IDimension;
/**
* Container of the application.
*/
readonly container: HTMLElement;
/**
* An event that is emitted when the container is layed out. The
* event carries the dimensions of the container as part of it.
......
......@@ -39,7 +39,6 @@ import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { LifecyclePhase, StartupKind, ILifecycleService, WillShutdownEvent } from 'vs/platform/lifecycle/common/lifecycle';
import { IWindowService, IWindowConfiguration, IPath, MenuBarVisibility, getTitleBarStyle, IWindowsService } from 'vs/platform/windows/common/windows';
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { NotificationService } from 'vs/workbench/services/notification/common/notificationService';
......@@ -50,7 +49,6 @@ import { registerNotificationCommands } from 'vs/workbench/browser/parts/notific
import { NotificationsToasts } from 'vs/workbench/browser/parts/notifications/notificationsToasts';
import { IEditorService, IResourceEditor } from 'vs/workbench/services/editor/common/editorService';
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { ContextViewService } from 'vs/platform/contextview/browser/contextViewService';
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { Sizing, Direction, Grid, View } from 'vs/base/browser/ui/grid/grid';
import { WorkbenchLegacyLayout } from 'vs/workbench/browser/legacyLayout';
......@@ -151,7 +149,7 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
private parts: Map<string, Part> = new Map<string, Part>();
constructor(
private container: HTMLElement,
private parent: HTMLElement,
private configuration: IWindowConfiguration,
private serviceCollection: ServiceCollection,
@IInstantiationService instantiationService: IInstantiationService,
......@@ -364,9 +362,6 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
const localizationsChannel = getDelayedChannel(sharedProcess.then(c => c.getChannel('localizations')));
serviceCollection.set(ILocalizationsService, new SyncDescriptor(LocalizationsChannelClient, [localizationsChannel]));
// Context view service
serviceCollection.set(IContextViewService, new SyncDescriptor(ContextViewService, [this.workbench], true));
// Contributed services
const contributedServices = getServices();
for (let contributedService of contributedServices) {
......@@ -489,7 +484,7 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
this.instantiationService.invokeFunction(accessor => this.createNotificationsHandlers(accessor));
// Add Workbench to DOM
this.container.appendChild(this.workbench);
this.parent.appendChild(this.workbench);
}
private createTitlebarPart(): void {
......@@ -690,6 +685,8 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
private _dimension: IDimension;
get dimension(): IDimension { return this._dimension; }
get container(): HTMLElement { return this.workbench; }
private workbenchGrid: Grid<View> | WorkbenchLegacyLayout;
private titleBarPartView: View;
......@@ -1283,7 +1280,7 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
} else {
this.workbenchGrid = this.instantiationService.createInstance(
WorkbenchLegacyLayout,
this.container,
this.parent,
this.workbench,
{
titlebar: titleBar,
......@@ -1299,7 +1296,7 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
layout(options?: ILayoutOptions): void {
if (!this.disposed) {
this._dimension = getClientArea(this.container);
this._dimension = getClientArea(this.parent);
if (this.workbenchGrid instanceof Grid) {
position(this.workbench, 0, 0, 0, 0, 'relative');
......@@ -1615,7 +1612,7 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
// Layout
if (!skipLayout) {
if (this.workbenchGrid instanceof Grid) {
const dimensions = getClientArea(this.container);
const dimensions = getClientArea(this.parent);
this.workbenchGrid.layout(dimensions.width, dimensions.height);
} else {
this.workbenchGrid.layout();
......
......@@ -450,6 +450,8 @@ export class TestLayoutService implements IWorkbenchLayoutService {
dimension: IDimension = { width: 800, height: 600 };
container: HTMLElement = window.document.body;
onZenModeChange: Event<boolean> = Event.None;
onLayout = Event.None;
......
......@@ -98,6 +98,7 @@ import 'vs/workbench/services/commands/common/commandService';
import 'vs/workbench/services/themes/browser/workbenchThemeService';
import 'vs/workbench/services/extensions/electron-browser/extensionService';
import 'vs/workbench/services/contextmenu/electron-browser/contextmenuService';
import 'vs/platform/contextview/browser/contextViewService';
registerSingleton(IMenuService, MenuService, true);
registerSingleton(IListService, ListService, true);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册