提交 84b046ce 编写于 作者: B Benjamin Pasero

debt - introduce ILayoutService

This allows to declare more services declaratively.
上级 2f62d285
...@@ -43,6 +43,7 @@ import { ITelemetryInfo, ITelemetryService } from 'vs/platform/telemetry/common/ ...@@ -43,6 +43,7 @@ import { ITelemetryInfo, ITelemetryService } from 'vs/platform/telemetry/common/
import { IWorkspace, IWorkspaceContextService, IWorkspaceFolder, IWorkspaceFoldersChangeEvent, WorkbenchState, WorkspaceFolder } from 'vs/platform/workspace/common/workspace'; import { IWorkspace, IWorkspaceContextService, IWorkspaceFolder, IWorkspaceFoldersChangeEvent, WorkbenchState, WorkspaceFolder } from 'vs/platform/workspace/common/workspace';
import { ISingleFolderWorkspaceIdentifier, IWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; import { ISingleFolderWorkspaceIdentifier, IWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
import { IAccessibilityService, AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility'; import { IAccessibilityService, AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility';
import { ILayoutService, IDimension } from 'vs/platform/layout/browser/layoutService';
export class SimpleModel implements IResolvedTextEditorModel { export class SimpleModel implements IResolvedTextEditorModel {
...@@ -671,3 +672,18 @@ export class SimpleUriLabelService implements ILabelService { ...@@ -671,3 +672,18 @@ export class SimpleUriLabelService implements ILabelService {
return ''; return '';
} }
} }
export class SimpleLayoutService implements ILayoutService {
_serviceBrand: any;
public onLayout = Event.None;
private _dimension: IDimension;
get dimension(): IDimension {
if (!this._dimension) {
this._dimension = dom.getClientArea(window.document.body);
}
return this._dimension;
}
}
...@@ -13,7 +13,7 @@ import { ModeServiceImpl } from 'vs/editor/common/services/modeServiceImpl'; ...@@ -13,7 +13,7 @@ import { ModeServiceImpl } from 'vs/editor/common/services/modeServiceImpl';
import { IModelService } from 'vs/editor/common/services/modelService'; import { IModelService } from 'vs/editor/common/services/modelService';
import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl'; import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
import { ITextResourceConfigurationService, ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration'; import { ITextResourceConfigurationService, ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration';
import { SimpleBulkEditService, SimpleConfigurationService, SimpleDialogService, SimpleNotificationService, SimpleProgressService, SimpleResourceConfigurationService, SimpleResourcePropertiesService, SimpleUriLabelService, SimpleWorkspaceContextService, StandaloneCommandService, StandaloneKeybindingService, StandaloneTelemetryService, BrowserAccessibilityService } from 'vs/editor/standalone/browser/simpleServices'; import { SimpleBulkEditService, SimpleConfigurationService, SimpleDialogService, SimpleNotificationService, SimpleProgressService, SimpleResourceConfigurationService, SimpleResourcePropertiesService, SimpleUriLabelService, SimpleWorkspaceContextService, StandaloneCommandService, StandaloneKeybindingService, StandaloneTelemetryService, BrowserAccessibilityService, SimpleLayoutService } from 'vs/editor/standalone/browser/simpleServices';
import { StandaloneCodeEditorServiceImpl } from 'vs/editor/standalone/browser/standaloneCodeServiceImpl'; import { StandaloneCodeEditorServiceImpl } from 'vs/editor/standalone/browser/standaloneCodeServiceImpl';
import { StandaloneThemeServiceImpl } from 'vs/editor/standalone/browser/standaloneThemeServiceImpl'; import { StandaloneThemeServiceImpl } from 'vs/editor/standalone/browser/standaloneThemeServiceImpl';
import { IStandaloneThemeService } from 'vs/editor/standalone/common/standaloneThemeService'; import { IStandaloneThemeService } from 'vs/editor/standalone/common/standaloneThemeService';
...@@ -46,6 +46,7 @@ import { IMarkerDecorationsService } from 'vs/editor/common/services/markersDeco ...@@ -46,6 +46,7 @@ import { IMarkerDecorationsService } from 'vs/editor/common/services/markersDeco
import { MarkerDecorationsService } from 'vs/editor/common/services/markerDecorationsServiceImpl'; import { MarkerDecorationsService } from 'vs/editor/common/services/markerDecorationsServiceImpl';
import { ISuggestMemoryService, SuggestMemoryService } from 'vs/editor/contrib/suggest/suggestMemory'; import { ISuggestMemoryService, SuggestMemoryService } from 'vs/editor/contrib/suggest/suggestMemory';
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility'; import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
import { ILayoutService } from 'vs/platform/layout/browser/layoutService';
export interface IEditorOverrideServices { export interface IEditorOverrideServices {
[index: string]: any; [index: string]: any;
...@@ -196,7 +197,9 @@ export class DynamicStandaloneServices extends Disposable { ...@@ -196,7 +197,9 @@ export class DynamicStandaloneServices extends Disposable {
let keybindingService = ensure(IKeybindingService, () => this._register(new StandaloneKeybindingService(contextKeyService, commandService, telemetryService, notificationService, domElement))); let keybindingService = ensure(IKeybindingService, () => this._register(new StandaloneKeybindingService(contextKeyService, commandService, telemetryService, notificationService, domElement)));
let contextViewService = ensure(IContextViewService, () => this._register(new ContextViewService(domElement, telemetryService, new NullLogService()))); let layoutService = ensure(ILayoutService, () => new SimpleLayoutService());
let contextViewService = ensure(IContextViewService, () => this._register(new ContextViewService(domElement, telemetryService, new NullLogService(), layoutService)));
ensure(IContextMenuService, () => this._register(new ContextMenuService(domElement, telemetryService, notificationService, contextViewService, keybindingService, themeService))); ensure(IContextMenuService, () => this._register(new ContextMenuService(domElement, telemetryService, notificationService, contextViewService, keybindingService, themeService)));
......
...@@ -8,6 +8,7 @@ import { ContextView } from 'vs/base/browser/ui/contextview/contextview'; ...@@ -8,6 +8,7 @@ import { ContextView } from 'vs/base/browser/ui/contextview/contextview';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { ILogService } from 'vs/platform/log/common/log'; import { ILogService } from 'vs/platform/log/common/log';
import { Disposable } from 'vs/base/common/lifecycle'; import { Disposable } from 'vs/base/common/lifecycle';
import { ILayoutService } from 'vs/platform/layout/browser/layoutService';
export class ContextViewService extends Disposable implements IContextViewService { export class ContextViewService extends Disposable implements IContextViewService {
_serviceBrand: any; _serviceBrand: any;
...@@ -17,11 +18,15 @@ export class ContextViewService extends Disposable implements IContextViewServic ...@@ -17,11 +18,15 @@ export class ContextViewService extends Disposable implements IContextViewServic
constructor( constructor(
container: HTMLElement, container: HTMLElement,
@ITelemetryService telemetryService: ITelemetryService, @ITelemetryService telemetryService: ITelemetryService,
@ILogService private readonly logService: ILogService @ILogService private readonly logService: ILogService,
@ILayoutService readonly layoutService: ILayoutService
) { ) {
super(); super();
this.contextView = this._register(new ContextView(container)); this.contextView = this._register(new ContextView(container));
this.layout();
this._register(layoutService.onLayout(() => this.layout()));
} }
// ContextView // ContextView
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Event } from 'vs/base/common/event';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
export const ILayoutService = createDecorator<ILayoutService>('layoutService');
export interface IDimension {
width: number;
height: number;
}
export interface ILayoutService {
_serviceBrand: any;
/**
* The dimensions of the container.
*/
readonly dimension: IDimension;
/**
* An event that is emitted when the container is layed out. The
* event carries the dimensions of the container as part of it.
*/
readonly onLayout: Event<IDimension>;
}
\ No newline at end of file
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { QuickOpenController } from 'vs/workbench/browser/parts/quickopen/quickOpenController';
import { QuickInputService } from 'vs/workbench/browser/parts/quickinput/quickInput';
import { Sash, ISashEvent, IVerticalSashLayoutProvider, IHorizontalSashLayoutProvider, Orientation } from 'vs/base/browser/ui/sash/sash'; import { Sash, ISashEvent, IVerticalSashLayoutProvider, IHorizontalSashLayoutProvider, Orientation } from 'vs/base/browser/ui/sash/sash';
import { IPartService, Position, ILayoutOptions, Parts } from 'vs/workbench/services/part/common/partService'; import { IPartService, Position, ILayoutOptions, Parts } from 'vs/workbench/services/part/common/partService';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet'; import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
...@@ -14,8 +12,6 @@ import { Disposable } from 'vs/base/common/lifecycle'; ...@@ -14,8 +12,6 @@ import { Disposable } from 'vs/base/common/lifecycle';
import { IThemeService } from 'vs/platform/theme/common/themeService'; import { IThemeService } from 'vs/platform/theme/common/themeService';
import { isMacintosh } from 'vs/base/common/platform'; import { isMacintosh } from 'vs/base/common/platform';
import { memoize } from 'vs/base/common/decorators'; import { memoize } from 'vs/base/common/decorators';
import { NotificationsCenter } from 'vs/workbench/browser/parts/notifications/notificationsCenter';
import { NotificationsToasts } from 'vs/workbench/browser/parts/notifications/notificationsToasts';
import { Dimension, getClientArea, size, position, hide, show } from 'vs/base/browser/dom'; import { Dimension, getClientArea, size, position, hide, show } from 'vs/base/browser/dom';
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService'; import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { EditorPart } from 'vs/workbench/browser/parts/editor/editorPart'; import { EditorPart } from 'vs/workbench/browser/parts/editor/editorPart';
...@@ -78,10 +74,6 @@ export class WorkbenchLegacyLayout extends Disposable implements IVerticalSashLa ...@@ -78,10 +74,6 @@ export class WorkbenchLegacyLayout extends Disposable implements IVerticalSashLa
panel: PanelPart, panel: PanelPart,
statusbar: StatusbarPart statusbar: StatusbarPart
}, },
private quickopen: QuickOpenController,
private quickInput: QuickInputService,
private notificationsCenter: NotificationsCenter,
private notificationsToasts: NotificationsToasts,
@IStorageService private readonly storageService: IStorageService, @IStorageService private readonly storageService: IStorageService,
@IContextViewService private readonly contextViewService: IContextViewService, @IContextViewService private readonly contextViewService: IContextViewService,
@IPartService private readonly partService: IPartService, @IPartService private readonly partService: IPartService,
...@@ -626,16 +618,6 @@ export class WorkbenchLegacyLayout extends Disposable implements IVerticalSashLa ...@@ -626,16 +618,6 @@ export class WorkbenchLegacyLayout extends Disposable implements IVerticalSashLa
show(statusbarContainer); show(statusbarContainer);
} }
// Quick open
this.quickopen.layout(this.workbenchSize);
// Quick input
this.quickInput.layout(this.workbenchSize);
// Notifications
this.notificationsCenter.layout(this.workbenchSize);
this.notificationsToasts.layout(this.workbenchSize);
// Sashes // Sashes
this.sashXOne.layout(); this.sashXOne.layout();
if (panelPosition === Position.BOTTOM) { if (panelPosition === Position.BOTTOM) {
......
...@@ -43,6 +43,8 @@ import { getIconClass } from 'vs/workbench/browser/parts/quickinput/quickInputUt ...@@ -43,6 +43,8 @@ import { getIconClass } from 'vs/workbench/browser/parts/quickinput/quickInputUt
import { IEditorOptions } from 'vs/editor/common/config/editorOptions'; import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
import { IStorageService } from 'vs/platform/storage/common/storage'; import { IStorageService } from 'vs/platform/storage/common/storage';
import { IAccessibilityService, AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility'; import { IAccessibilityService, AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { ILayoutService } from 'vs/platform/layout/browser/layoutService';
const $ = dom.$; const $ = dom.$;
...@@ -816,7 +818,6 @@ export class QuickInputService extends Component implements IQuickInputService { ...@@ -816,7 +818,6 @@ export class QuickInputService extends Component implements IQuickInputService {
private static readonly MAX_WIDTH = 600; // Max total width of quick open widget private static readonly MAX_WIDTH = 600; // Max total width of quick open widget
private idPrefix = 'quickInput_'; // Constant since there is still only one. private idPrefix = 'quickInput_'; // Constant since there is still only one.
private layoutDimensions: dom.Dimension;
private titleBar: HTMLElement; private titleBar: HTMLElement;
private filterContainer: HTMLElement; private filterContainer: HTMLElement;
private visibleCountContainer: HTMLElement; private visibleCountContainer: HTMLElement;
...@@ -846,12 +847,14 @@ export class QuickInputService extends Component implements IQuickInputService { ...@@ -846,12 +847,14 @@ export class QuickInputService extends Component implements IQuickInputService {
@IContextKeyService private readonly contextKeyService: IContextKeyService, @IContextKeyService private readonly contextKeyService: IContextKeyService,
@IThemeService themeService: IThemeService, @IThemeService themeService: IThemeService,
@IStorageService storageService: IStorageService, @IStorageService storageService: IStorageService,
@IAccessibilityService private readonly accessibilityService: IAccessibilityService @IAccessibilityService private readonly accessibilityService: IAccessibilityService,
@ILayoutService private readonly layoutService: ILayoutService
) { ) {
super(QuickInputService.ID, themeService, storageService); super(QuickInputService.ID, themeService, storageService);
this.inQuickOpenContext = InQuickOpenContextKey.bindTo(contextKeyService); this.inQuickOpenContext = InQuickOpenContextKey.bindTo(contextKeyService);
this._register(this.quickOpenService.onShow(() => this.inQuickOpen('quickOpen', true))); this._register(this.quickOpenService.onShow(() => this.inQuickOpen('quickOpen', true)));
this._register(this.quickOpenService.onHide(() => this.inQuickOpen('quickOpen', false))); this._register(this.quickOpenService.onHide(() => this.inQuickOpen('quickOpen', false)));
this._register(this.layoutService.onLayout(dimension => this.layout(dimension)));
this.registerKeyModsListeners(); this.registerKeyModsListeners();
} }
...@@ -1400,17 +1403,16 @@ export class QuickInputService extends Component implements IQuickInputService { ...@@ -1400,17 +1403,16 @@ export class QuickInputService extends Component implements IQuickInputService {
} }
layout(dimension: dom.Dimension): void { layout(dimension: dom.Dimension): void {
this.layoutDimensions = dimension;
this.updateLayout(); this.updateLayout();
} }
private updateLayout() { private updateLayout() {
if (this.layoutDimensions && this.ui) { if (this.ui) {
const titlebarOffset = this.partService.getTitleBarOffset(); const titlebarOffset = this.partService.getTitleBarOffset();
this.ui.container.style.top = `${titlebarOffset}px`; this.ui.container.style.top = `${titlebarOffset}px`;
const style = this.ui.container.style; const style = this.ui.container.style;
const width = Math.min(this.layoutDimensions.width * 0.62 /* golden cut */, QuickInputService.MAX_WIDTH); const width = Math.min(this.layoutService.dimension.width * 0.62 /* golden cut */, QuickInputService.MAX_WIDTH);
style.width = width + 'px'; style.width = width + 'px';
style.marginLeft = '-' + (width / 2) + 'px'; style.marginLeft = '-' + (width / 2) + 'px';
...@@ -1467,3 +1469,5 @@ export class BackAction extends Action { ...@@ -1467,3 +1469,5 @@ export class BackAction extends Action {
return Promise.resolve(); return Promise.resolve();
} }
} }
registerSingleton(IQuickInputService, QuickInputService, true);
\ No newline at end of file
...@@ -50,6 +50,8 @@ import { timeout } from 'vs/base/common/async'; ...@@ -50,6 +50,8 @@ import { timeout } from 'vs/base/common/async';
import { IQuickInputService, IQuickPickItem } from 'vs/platform/quickinput/common/quickInput'; import { IQuickInputService, IQuickPickItem } from 'vs/platform/quickinput/common/quickInput';
import { CancellationTokenSource, CancellationToken } from 'vs/base/common/cancellation'; import { CancellationTokenSource, CancellationToken } from 'vs/base/common/cancellation';
import { IStorageService } from 'vs/platform/storage/common/storage'; import { IStorageService } from 'vs/platform/storage/common/storage';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { ILayoutService } from 'vs/platform/layout/browser/layoutService';
const HELP_PREFIX = '?'; const HELP_PREFIX = '?';
...@@ -73,7 +75,6 @@ export class QuickOpenController extends Component implements IQuickOpenService ...@@ -73,7 +75,6 @@ export class QuickOpenController extends Component implements IQuickOpenService
private lastInputValue: string; private lastInputValue: string;
private lastSubmittedInputValue: string; private lastSubmittedInputValue: string;
private quickOpenWidget: QuickOpenWidget; private quickOpenWidget: QuickOpenWidget;
private dimension: Dimension;
private mapResolvedHandlersToPrefix: { [prefix: string]: Promise<QuickOpenHandler>; } = Object.create(null); private mapResolvedHandlersToPrefix: { [prefix: string]: Promise<QuickOpenHandler>; } = Object.create(null);
private mapContextKeyToContext: { [id: string]: IContextKey<boolean>; } = Object.create(null); private mapContextKeyToContext: { [id: string]: IContextKey<boolean>; } = Object.create(null);
private handlerOnOpenCalled: { [prefix: string]: boolean; } = Object.create(null); private handlerOnOpenCalled: { [prefix: string]: boolean; } = Object.create(null);
...@@ -94,7 +95,8 @@ export class QuickOpenController extends Component implements IQuickOpenService ...@@ -94,7 +95,8 @@ export class QuickOpenController extends Component implements IQuickOpenService
@IPartService private readonly partService: IPartService, @IPartService private readonly partService: IPartService,
@IEnvironmentService private readonly environmentService: IEnvironmentService, @IEnvironmentService private readonly environmentService: IEnvironmentService,
@IThemeService themeService: IThemeService, @IThemeService themeService: IThemeService,
@IStorageService storageService: IStorageService @IStorageService storageService: IStorageService,
@ILayoutService private readonly layoutService: ILayoutService
) { ) {
super(QuickOpenController.ID, themeService, storageService); super(QuickOpenController.ID, themeService, storageService);
...@@ -109,6 +111,7 @@ export class QuickOpenController extends Component implements IQuickOpenService ...@@ -109,6 +111,7 @@ export class QuickOpenController extends Component implements IQuickOpenService
this._register(this.configurationService.onDidChangeConfiguration(() => this.updateConfiguration())); this._register(this.configurationService.onDidChangeConfiguration(() => this.updateConfiguration()));
this._register(this.partService.onTitleBarVisibilityChange(() => this.positionQuickOpenWidget())); this._register(this.partService.onTitleBarVisibilityChange(() => this.positionQuickOpenWidget()));
this._register(browser.onDidChangeZoomLevel(() => this.positionQuickOpenWidget())); this._register(browser.onDidChangeZoomLevel(() => this.positionQuickOpenWidget()));
this._register(this.layoutService.onLayout(dimension => this.layout(dimension)));
} }
private updateConfiguration(): void { private updateConfiguration(): void {
...@@ -195,9 +198,7 @@ export class QuickOpenController extends Component implements IQuickOpenService ...@@ -195,9 +198,7 @@ export class QuickOpenController extends Component implements IQuickOpenService
} }
// Layout // Layout
if (this.dimension) { this.quickOpenWidget.layout(this.layoutService.dimension);
this.quickOpenWidget.layout(this.dimension);
}
// Show quick open with prefix or editor history // Show quick open with prefix or editor history
if (!this.quickOpenWidget.isVisible() || quickNavigateConfiguration) { if (!this.quickOpenWidget.isVisible() || quickNavigateConfiguration) {
...@@ -624,9 +625,8 @@ export class QuickOpenController extends Component implements IQuickOpenService ...@@ -624,9 +625,8 @@ export class QuickOpenController extends Component implements IQuickOpenService
} }
layout(dimension: Dimension): void { layout(dimension: Dimension): void {
this.dimension = dimension;
if (this.quickOpenWidget) { if (this.quickOpenWidget) {
this.quickOpenWidget.layout(this.dimension); this.quickOpenWidget.layout(dimension);
} }
} }
} }
...@@ -863,3 +863,5 @@ export class RemoveFromEditorHistoryAction extends Action { ...@@ -863,3 +863,5 @@ export class RemoveFromEditorHistoryAction extends Action {
}); });
} }
} }
registerSingleton(IQuickOpenService, QuickOpenController, true);
\ No newline at end of file
...@@ -29,9 +29,6 @@ import { EditorPart } from 'vs/workbench/browser/parts/editor/editorPart'; ...@@ -29,9 +29,6 @@ import { EditorPart } from 'vs/workbench/browser/parts/editor/editorPart';
import { IActionBarRegistry, Extensions as ActionBarExtensions } from 'vs/workbench/browser/actions'; import { IActionBarRegistry, Extensions as ActionBarExtensions } from 'vs/workbench/browser/actions';
import { PanelRegistry, Extensions as PanelExtensions } from 'vs/workbench/browser/panel'; import { PanelRegistry, Extensions as PanelExtensions } from 'vs/workbench/browser/panel';
import { ViewletRegistry, Extensions as ViewletExtensions } from 'vs/workbench/browser/viewlet'; import { ViewletRegistry, Extensions as ViewletExtensions } from 'vs/workbench/browser/viewlet';
import { QuickOpenController } from 'vs/workbench/browser/parts/quickopen/quickOpenController';
import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
import { QuickInputService } from 'vs/workbench/browser/parts/quickinput/quickInput';
import { getServices } from 'vs/platform/instantiation/common/extensions'; import { getServices } from 'vs/platform/instantiation/common/extensions';
import { Position, Parts, IPartService, ILayoutOptions } from 'vs/workbench/services/part/common/partService'; import { Position, Parts, IPartService, ILayoutOptions } from 'vs/workbench/services/part/common/partService';
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace'; import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
...@@ -46,9 +43,7 @@ import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet'; ...@@ -46,9 +43,7 @@ import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { IFileService } from 'vs/platform/files/common/files'; import { IFileService } from 'vs/platform/files/common/files';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService'; import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { ITitleService } from 'vs/workbench/services/title/common/titleService'; import { ITitleService } from 'vs/workbench/services/title/common/titleService';
import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen'; import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { IHistoryService } from 'vs/workbench/services/history/common/history';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { LifecyclePhase, StartupKind, ILifecycleService, WillShutdownEvent } from 'vs/platform/lifecycle/common/lifecycle'; import { LifecyclePhase, StartupKind, ILifecycleService, WillShutdownEvent } from 'vs/platform/lifecycle/common/lifecycle';
...@@ -97,12 +92,11 @@ import { IModelService } from 'vs/editor/common/services/modelService'; ...@@ -97,12 +92,11 @@ import { IModelService } from 'vs/editor/common/services/modelService';
import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl'; import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
import { IUntitledEditorService, UntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService'; import { IUntitledEditorService, UntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
import { ILocalizationsService } from 'vs/platform/localizations/common/localizations'; import { ILocalizationsService } from 'vs/platform/localizations/common/localizations';
import { HistoryService } from 'vs/workbench/services/history/browser/history';
import { WorkbenchThemeService } from 'vs/workbench/services/themes/browser/workbenchThemeService'; import { WorkbenchThemeService } from 'vs/workbench/services/themes/browser/workbenchThemeService';
import { IProductService } from 'vs/platform/product/common/product'; import { IProductService } from 'vs/platform/product/common/product';
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility'; import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
import { WorkbenchContextKeysHandler } from 'vs/workbench/browser/contextkeys'; import { WorkbenchContextKeysHandler } from 'vs/workbench/browser/contextkeys';
import { ServicesAccessor } from 'vs/editor/browser/editorExtensions'; import { ILayoutService, IDimension } from 'vs/platform/layout/browser/layoutService';
// import@node // import@node
import { getDelayedChannel } from 'vs/base/parts/ipc/node/ipc'; import { getDelayedChannel } from 'vs/base/parts/ipc/node/ipc';
...@@ -203,12 +197,6 @@ export class Workbench extends Disposable implements IPartService { ...@@ -203,12 +197,6 @@ export class Workbench extends Disposable implements IPartService {
private editorPart: EditorPart; private editorPart: EditorPart;
private statusbarPart: StatusbarPart; private statusbarPart: StatusbarPart;
private quickOpen: QuickOpenController;
private quickInput: QuickInputService;
private notificationsCenter: NotificationsCenter;
private notificationsToasts: NotificationsToasts;
constructor( constructor(
private container: HTMLElement, private container: HTMLElement,
private configuration: IWindowConfiguration, private configuration: IWindowConfiguration,
...@@ -358,6 +346,7 @@ export class Workbench extends Disposable implements IPartService { ...@@ -358,6 +346,7 @@ export class Workbench extends Disposable implements IPartService {
// Parts // Parts
serviceCollection.set(IPartService, this); // TODO@Ben use SyncDescriptor serviceCollection.set(IPartService, this); // TODO@Ben use SyncDescriptor
serviceCollection.set(ILayoutService, this); // TODO@Ben use SyncDescriptor
// Labels // Labels
serviceCollection.set(ILabelService, new SyncDescriptor(LabelService, undefined, true)); serviceCollection.set(ILabelService, new SyncDescriptor(LabelService, undefined, true));
...@@ -502,17 +491,6 @@ export class Workbench extends Disposable implements IPartService { ...@@ -502,17 +491,6 @@ export class Workbench extends Disposable implements IPartService {
this.titlebarPart = this.instantiationService.createInstance(TitlebarPart, Identifiers.TITLEBAR_PART); this.titlebarPart = this.instantiationService.createInstance(TitlebarPart, Identifiers.TITLEBAR_PART);
serviceCollection.set(ITitleService, this.titlebarPart); // TODO@Ben use SyncDescriptor serviceCollection.set(ITitleService, this.titlebarPart); // TODO@Ben use SyncDescriptor
// History
serviceCollection.set(IHistoryService, new SyncDescriptor(HistoryService));
// Quick open service (quick open controller)
this.quickOpen = this.instantiationService.createInstance(QuickOpenController);
serviceCollection.set(IQuickOpenService, this.quickOpen); // TODO@Ben use SyncDescriptor
// Quick input service
this.quickInput = this.instantiationService.createInstance(QuickInputService);
serviceCollection.set(IQuickInputService, this.quickInput); // TODO@Ben use SyncDescriptor
// Contributed services // Contributed services
const contributedServices = getServices(); const contributedServices = getServices();
for (let contributedService of contributedServices) { for (let contributedService of contributedServices) {
...@@ -692,30 +670,26 @@ export class Workbench extends Disposable implements IPartService { ...@@ -692,30 +670,26 @@ export class Workbench extends Disposable implements IPartService {
private createNotificationsHandlers(accessor: ServicesAccessor): void { private createNotificationsHandlers(accessor: ServicesAccessor): void {
const notificationService = accessor.get(INotificationService) as NotificationService; const notificationService = accessor.get(INotificationService) as NotificationService;
// Notifications Center // Instantiate Notification components
this.notificationsCenter = this._register(this.instantiationService.createInstance(NotificationsCenter, this.workbench, notificationService.model)); const notificationsCenter = this._register(this.instantiationService.createInstance(NotificationsCenter, this.workbench, notificationService.model));
const notificationsToasts = this._register(this.instantiationService.createInstance(NotificationsToasts, this.workbench, notificationService.model));
// Notifications Toasts
this.notificationsToasts = this._register(this.instantiationService.createInstance(NotificationsToasts, this.workbench, notificationService.model));
// Notifications Alerts
this._register(this.instantiationService.createInstance(NotificationsAlerts, notificationService.model)); this._register(this.instantiationService.createInstance(NotificationsAlerts, notificationService.model));
// Notifications Status
const notificationsStatus = this.instantiationService.createInstance(NotificationsStatus, notificationService.model); const notificationsStatus = this.instantiationService.createInstance(NotificationsStatus, notificationService.model);
// Eventing // Visibility
this._register(this.notificationsCenter.onDidChangeVisibility(() => { this._register(notificationsCenter.onDidChangeVisibility(() => {
notificationsStatus.update(notificationsCenter.isVisible);
// Update status notificationsToasts.update(notificationsCenter.isVisible);
notificationsStatus.update(this.notificationsCenter.isVisible); }));
// Update toasts // Layout
this.notificationsToasts.update(this.notificationsCenter.isVisible); this._register(this.onLayout(dimension => {
notificationsCenter.layout(dimension);
notificationsToasts.layout(dimension);
})); }));
// Register Commands // Register Commands
registerNotificationCommands(this.notificationsCenter, this.notificationsToasts); registerNotificationCommands(notificationsCenter, notificationsToasts);
} }
private restoreWorkbench(): Promise<void> { private restoreWorkbench(): Promise<void> {
...@@ -828,6 +802,12 @@ export class Workbench extends Disposable implements IPartService { ...@@ -828,6 +802,12 @@ export class Workbench extends Disposable implements IPartService {
private readonly _onZenMode: Emitter<boolean> = this._register(new Emitter<boolean>()); private readonly _onZenMode: Emitter<boolean> = this._register(new Emitter<boolean>());
get onZenModeChange(): Event<boolean> { return this._onZenMode.event; } get onZenModeChange(): Event<boolean> { return this._onZenMode.event; }
private readonly _onLayout = this._register(new Emitter<IDimension>());
get onLayout(): Event<IDimension> { return this._onLayout.event; }
private _dimension: IDimension;
get dimension(): IDimension { return this._dimension; }
private workbenchGrid: Grid<View> | WorkbenchLegacyLayout; private workbenchGrid: Grid<View> | WorkbenchLegacyLayout;
private titleBarPartView: View; private titleBarPartView: View;
...@@ -837,7 +817,6 @@ export class Workbench extends Disposable implements IPartService { ...@@ -837,7 +817,6 @@ export class Workbench extends Disposable implements IPartService {
private editorPartView: View; private editorPartView: View;
private statusBarPartView: View; private statusBarPartView: View;
private contextViewService: IContextViewService;
private windowService: IWindowService; private windowService: IWindowService;
private readonly state = { private readonly state = {
...@@ -1035,7 +1014,6 @@ export class Workbench extends Disposable implements IPartService { ...@@ -1035,7 +1014,6 @@ export class Workbench extends Disposable implements IPartService {
const environmentService = accessor.get(IEnvironmentService); const environmentService = accessor.get(IEnvironmentService);
this.windowService = accessor.get(IWindowService); this.windowService = accessor.get(IWindowService);
this.contextViewService = accessor.get(IContextViewService);
// Fullscreen // Fullscreen
this.state.fullscreen = isFullscreen(); this.state.fullscreen = isFullscreen();
...@@ -1406,38 +1384,30 @@ export class Workbench extends Disposable implements IPartService { ...@@ -1406,38 +1384,30 @@ export class Workbench extends Disposable implements IPartService {
sidebar: this.sidebarPart, sidebar: this.sidebarPart,
panel: this.panelPart, panel: this.panelPart,
statusbar: this.statusbarPart, statusbar: this.statusbarPart,
}, }
this.quickOpen,
this.quickInput,
this.notificationsCenter,
this.notificationsToasts
); );
} }
} }
layout(options?: ILayoutOptions): void { layout(options?: ILayoutOptions): void {
this.contextViewService.layout();
if (!this.disposed) { if (!this.disposed) {
this._dimension = getClientArea(this.container);
if (this.workbenchGrid instanceof Grid) { if (this.workbenchGrid instanceof Grid) {
const dimensions = getClientArea(this.container);
position(this.workbench, 0, 0, 0, 0, 'relative'); position(this.workbench, 0, 0, 0, 0, 'relative');
size(this.workbench, dimensions.width, dimensions.height); size(this.workbench, this._dimension.width, this._dimension.height);
// Layout the grid // Layout the grid widget
this.workbenchGrid.layout(dimensions.width, dimensions.height); this.workbenchGrid.layout(this._dimension.width, this._dimension.height);
// Layout non-view ui components // Layout grid views
this.quickInput.layout(dimensions);
this.quickOpen.layout(dimensions);
this.notificationsCenter.layout(dimensions);
this.notificationsToasts.layout(dimensions);
// Layout Grid
this.layoutGrid(); this.layoutGrid();
} else { } else {
this.workbenchGrid.layout(options); this.workbenchGrid.layout(options);
} }
// Emit as event
this._onLayout.fire(this._dimension);
} }
} }
......
...@@ -30,6 +30,7 @@ import { EditorServiceImpl } from 'vs/workbench/browser/parts/editor/editor'; ...@@ -30,6 +30,7 @@ import { EditorServiceImpl } from 'vs/workbench/browser/parts/editor/editor';
import { IPartService } from 'vs/workbench/services/part/common/partService'; import { IPartService } from 'vs/workbench/services/part/common/partService';
import { IContextKeyService, RawContextKey, IContextKey } from 'vs/platform/contextkey/common/contextkey'; import { IContextKeyService, RawContextKey, IContextKey } from 'vs/platform/contextkey/common/contextkey';
import { coalesce } from 'vs/base/common/arrays'; import { coalesce } from 'vs/base/common/arrays';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
/** /**
* Stores the selection & view state of an editor and allows to compare it to other selection states. * Stores the selection & view state of an editor and allows to compare it to other selection states.
...@@ -971,3 +972,5 @@ export class HistoryService extends Disposable implements IHistoryService { ...@@ -971,3 +972,5 @@ export class HistoryService extends Disposable implements IHistoryService {
return undefined; return undefined;
} }
} }
registerSingleton(IHistoryService, HistoryService);
\ No newline at end of file
...@@ -74,6 +74,9 @@ import 'vs/workbench/services/textmodelResolver/common/textModelResolverService' ...@@ -74,6 +74,9 @@ import 'vs/workbench/services/textmodelResolver/common/textModelResolverService'
import 'vs/workbench/services/textfile/common/textFileService'; import 'vs/workbench/services/textfile/common/textFileService';
import 'vs/workbench/services/dialogs/electron-browser/dialogService'; import 'vs/workbench/services/dialogs/electron-browser/dialogService';
import 'vs/workbench/services/backup/node/backupFileService'; import 'vs/workbench/services/backup/node/backupFileService';
import 'vs/workbench/services/history/browser/history';
import 'vs/workbench/browser/parts/quickinput/quickInput';
import 'vs/workbench/browser/parts/quickopen/quickOpenController';
registerSingleton(IMenuService, MenuService, true); registerSingleton(IMenuService, MenuService, true);
registerSingleton(IListService, ListService, true); registerSingleton(IListService, ListService, true);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册