Skip to content

Commit

Permalink
debt - move workbench to browser
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Mar 8, 2019
1 parent 16635b8 commit 53c5277
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { ITitleService } from 'vs/workbench/services/title/common/titleService';
import { IInstantiationService, ServicesAccessor, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
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 } from 'vs/platform/windows/common/windows';
import { IWindowService, IPath, MenuBarVisibility, getTitleBarStyle } from 'vs/platform/windows/common/windows';
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';
Expand All @@ -62,6 +62,10 @@ import { Part } from 'vs/workbench/browser/part';
import { IStatusbarService } from 'vs/platform/statusbar/common/statusbar';
import { IActivityBarService } from 'vs/workbench/services/activityBar/browser/activityBarService';

export interface IWorkbenchOptions {
hasInitialFilesToOpen: boolean;
}

enum Settings {
MENUBAR_VISIBLE = 'window.menuBarVisibility',
ACTIVITYBAR_VISIBLE = 'workbench.activityBar.visible',
Expand Down Expand Up @@ -115,7 +119,7 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {

constructor(
private parent: HTMLElement,
private configuration: IWindowConfiguration,
private options: IWorkbenchOptions,
private serviceCollection: ServiceCollection,
@IInstantiationService instantiationService: IInstantiationService,
@IWorkspaceContextService contextService: IWorkspaceContextService,
Expand Down Expand Up @@ -191,9 +195,6 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {

private doStartup(): Promise<void> {

// Logging
this.logService.trace('workbench configuration', JSON.stringify(this.configuration));

// Configure emitter leak warning threshold
setGlobalLeakWarningThreshold(175);

Expand Down Expand Up @@ -302,13 +303,6 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
});
}

private hasInitialFilesToOpen(): boolean {
return !!(
(this.configuration.filesToCreate && this.configuration.filesToCreate.length > 0) ||
(this.configuration.filesToOpen && this.configuration.filesToOpen.length > 0) ||
(this.configuration.filesToDiff && this.configuration.filesToDiff.length > 0));
}

private registerListeners(accessor: ServicesAccessor): void {
const lifecycleService = accessor.get(ILifecycleService);
const storageService = accessor.get(IStorageService);
Expand Down Expand Up @@ -409,7 +403,7 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
private createEditorPart(): void {
const editorContainer = this.createPart(Parts.EDITOR_PART, 'main', 'editor');

this.parts.get(Parts.EDITOR_PART).create(editorContainer, { restorePreviousState: !this.hasInitialFilesToOpen() });
this.parts.get(Parts.EDITOR_PART).create(editorContainer, { restorePreviousState: !this.options.hasInitialFilesToOpen });
}

private createStatusbarPart(): void {
Expand Down Expand Up @@ -885,7 +879,7 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
const backupFileService = accessor.get(IBackupFileService);

// Files to open, diff or create
if (this.hasInitialFilesToOpen()) {
if (this.options.hasInitialFilesToOpen) {

// Files to diff is exclusive
const filesToDiff = this.toInputs(configuration.filesToDiff, false);
Expand Down
14 changes: 12 additions & 2 deletions src/vs/workbench/electron-browser/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as fs from 'fs';
import * as gracefulFs from 'graceful-fs';
import { createHash } from 'crypto';
import { importEntries, mark } from 'vs/base/common/performance';
import { Workbench } from 'vs/workbench/electron-browser/workbench';
import { Workbench, IWorkbenchOptions } from 'vs/workbench/browser/workbench';
import { ElectronWindow } from 'vs/workbench/electron-browser/window';
import { setZoomLevel, setZoomFactor, setFullscreen } from 'vs/base/browser/browser';
import { domContentLoaded, addDisposableListener, EventType, scheduleAtNextAnimationFrame } from 'vs/base/browser/dom';
Expand Down Expand Up @@ -102,6 +102,13 @@ class CodeRendererMain extends Disposable {
});
}

private hasInitialFilesToOpen(): boolean {
return !!(
(this.configuration.filesToCreate && this.configuration.filesToCreate.length > 0) ||
(this.configuration.filesToOpen && this.configuration.filesToOpen.length > 0) ||
(this.configuration.filesToDiff && this.configuration.filesToDiff.length > 0));
}

open(): Promise<void> {
const electronMainClient = this._register(new ElectronIPCClient(`window:${this.configuration.windowId}`));

Expand All @@ -116,7 +123,7 @@ class CodeRendererMain extends Disposable {
this.workbench = instantiationService.createInstance(
Workbench,
document.body,
this.configuration,
{ hasInitialFilesToOpen: this.hasInitialFilesToOpen() } as IWorkbenchOptions,
services
);

Expand All @@ -142,6 +149,9 @@ class CodeRendererMain extends Disposable {
if (this.configuration['export-default-configuration']) {
instantiationService.createInstance(DefaultConfigurationExportHelper);
}

// Logging
instantiationService.invokeFunction(accessor => accessor.get(ILogService).trace('workbench configuration', JSON.stringify(this.configuration)));
});
});
}
Expand Down

0 comments on commit 53c5277

Please sign in to comment.