提交 98bac768 编写于 作者: B Benjamin Pasero

debt - more cleanup of window services

上级 c7253643
......@@ -5,53 +5,33 @@
'use strict';
import { ElectronWindow } from 'vs/workbench/electron-browser/window';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import Event, { Emitter } from 'vs/base/common/event';
import { ipcRenderer as ipc, remote } from 'electron';
import { ipcRenderer as ipc } from 'electron';
const windowId = remote.getCurrentWindow().id;
export const IWindowIPCService = createDecorator<IWindowIPCService>('windowIPCService');
export interface IWindowServices {
windowService?: IWindowIPCService;
}
export const IBroadcastService = createDecorator<IBroadcastService>('broadcastService');
export interface IBroadcast {
channel: string;
payload: any;
}
export interface IWindowIPCService {
export interface IBroadcastService {
_serviceBrand: any;
getWindowId(): number;
getWindow(): ElectronWindow;
registerWindow(win: ElectronWindow): void;
broadcast(b: IBroadcast, target?: string): void;
onBroadcast: Event<IBroadcast>;
}
/**
* TODO@Joao: remove this service
* @deprecated
*/
export class WindowIPCService implements IWindowIPCService {
export class BroadcastService implements IBroadcastService {
public _serviceBrand: any;
private win: ElectronWindow;
private windowId: number;
private _onBroadcast: Emitter<IBroadcast>;
constructor() {
constructor(private windowId: number) {
this._onBroadcast = new Emitter<IBroadcast>();
this.windowId = windowId;
this.registerListeners();
}
......@@ -66,20 +46,8 @@ export class WindowIPCService implements IWindowIPCService {
return this._onBroadcast.event;
}
public getWindowId(): number {
return this.windowId;
}
public getWindow(): ElectronWindow {
return this.win;
}
public registerWindow(win: ElectronWindow): void {
this.win = win;
}
public broadcast(b: IBroadcast, target?: string): void {
ipc.send('vscode:broadcast', this.getWindowId(), target, {
ipc.send('vscode:broadcast', this.windowId, target, {
channel: b.channel,
payload: b.payload
});
......
......@@ -95,6 +95,8 @@ export interface IWindowService {
maximizeWindow(): TPromise<void>;
unmaximizeWindow(): TPromise<void>;
onWindowTitleDoubleClick(): TPromise<void>;
showMessageBox(options: Electron.ShowMessageBoxOptions): number;
showSaveDialog(options: Electron.SaveDialogOptions, callback?: (fileName: string) => void): string;
}
export type MenuBarVisibility = 'default' | 'visible' | 'toggle' | 'hidden';
......
......@@ -8,6 +8,7 @@
import { TPromise } from 'vs/base/common/winjs.base';
import { IWindowService, IWindowsService } from 'vs/platform/windows/common/windows';
import { ITelemetryData } from 'vs/platform/telemetry/common/telemetry';
import { remote } from 'electron';
export class WindowService implements IWindowService {
......@@ -98,4 +99,15 @@ export class WindowService implements IWindowService {
return this.windowsService.setDocumentEdited(this.windowId, flag);
}
showMessageBox(options: Electron.ShowMessageBoxOptions): number {
return remote.dialog.showMessageBox(remote.getCurrentWindow(), options);
}
showSaveDialog(options: Electron.SaveDialogOptions, callback?: (fileName: string) => void): string {
if (callback) {
return remote.dialog.showSaveDialog(remote.getCurrentWindow(), options, callback);
}
return remote.dialog.showSaveDialog(remote.getCurrentWindow(), options); // https://github.com/electron/electron/issues/4936
}
}
......@@ -11,9 +11,8 @@ import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { IPartService } from 'vs/workbench/services/part/common/partService';
import { CommonEditorRegistry } from 'vs/editor/common/editorCommonExtensions';
import { IWindowIPCService } from 'vs/workbench/services/window/electron-browser/windowService';
import { NoEditorsVisibleContext, InZenModeContext } from 'vs/workbench/electron-browser/workbench';
import { IWindowsService } from 'vs/platform/windows/common/windows';
import { IWindowsService, IWindowService } from 'vs/platform/windows/common/windows';
import { IListService, ListFocusContext } from 'vs/platform/list/browser/listService';
import { List } from 'vs/base/browser/ui/list/listWidget';
import errors = require('vs/base/common/errors');
......@@ -366,8 +365,8 @@ export function registerCommands(): void {
when: NoEditorsVisibleContext,
primary: KeyMod.CtrlCmd | KeyCode.KEY_W,
handler: accessor => {
const windowService = accessor.get(IWindowIPCService);
windowService.getWindow().close();
const windowService = accessor.get(IWindowService);
windowService.closeWindow();
}
});
......
......@@ -19,7 +19,6 @@ import { ILifecycleService, ShutdownEvent } from 'vs/platform/lifecycle/common/l
import { IWindowsService, IWindowService } from 'vs/platform/windows/common/windows';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IWindowIPCService } from 'vs/workbench/services/window/electron-browser/windowService';
import { ChildProcess, fork } from 'child_process';
import { ipcRenderer as ipc } from 'electron';
import product from 'vs/platform/node/product';
......@@ -35,6 +34,7 @@ import { IInitData, IWorkspaceData } from 'vs/workbench/api/node/extHost.protoco
import { MainProcessExtensionService } from 'vs/workbench/api/electron-browser/mainThreadExtensionService';
import { IWorkspaceConfigurationService } from 'vs/workbench/services/configuration/common/configuration';
import { ICrashReporterService } from 'vs/workbench/services/crashReporter/common/crashReporterService';
import { IBroadcastService } from "vs/platform/broadcast/electron-browser/broadcastService";
export const EXTENSION_LOG_BROADCAST_CHANNEL = 'vscode:extensionLog';
export const EXTENSION_ATTACH_BROADCAST_CHANNEL = 'vscode:extensionAttach';
......@@ -91,7 +91,7 @@ export class ExtensionHostProcessWorker {
@IMessageService private messageService: IMessageService,
@IWindowsService private windowsService: IWindowsService,
@IWindowService private windowService: IWindowService,
@IWindowIPCService private windowIpcService: IWindowIPCService,
@IBroadcastService private broadcastService: IBroadcastService,
@ILifecycleService lifecycleService: ILifecycleService,
@IInstantiationService private instantiationService: IInstantiationService,
@IEnvironmentService private environmentService: IEnvironmentService,
......@@ -122,7 +122,7 @@ export class ExtensionHostProcessWorker {
AMD_ENTRYPOINT: 'vs/workbench/node/extensionHostProcess',
PIPE_LOGGING: 'true',
VERBOSE_LOGGING: true,
VSCODE_WINDOW_ID: String(this.windowIpcService.getWindowId()),
VSCODE_WINDOW_ID: String(this.windowService.getCurrentWindowId()),
VSCODE_IPC_HOOK_EXTHOST: hook,
ELECTRON_NO_ASAR: '1'
}),
......@@ -185,7 +185,7 @@ export class ExtensionHostProcessWorker {
// Notify debugger that we are ready to attach to the process if we run a development extension
if (this.isExtensionDevelopmentHost && port) {
this.windowIpcService.broadcast({
this.broadcastService.broadcast({
channel: EXTENSION_ATTACH_BROADCAST_CHANNEL,
payload: { port }
}, this.environmentService.extensionDevelopmentPath /* target */);
......@@ -327,7 +327,7 @@ export class ExtensionHostProcessWorker {
// Broadcast to other windows if we are in development mode
else if (!this.environmentService.isBuilt || this.isExtensionDevelopmentHost) {
this.windowIpcService.broadcast({
this.broadcastService.broadcast({
channel: EXTENSION_LOG_BROADCAST_CHANNEL,
payload: logEntry
}, this.environmentService.extensionDevelopmentPath /* target */);
......@@ -370,7 +370,7 @@ export class ExtensionHostProcessWorker {
// Expected development extension termination: When the extension host goes down we also shutdown the window
else if (!this.isExtensionDevelopmentTestFromCli) {
this.windowIpcService.getWindow().close();
this.windowService.closeWindow();
}
// When CLI testing make sure to exit with proper exit code
......@@ -394,7 +394,7 @@ export class ExtensionHostProcessWorker {
// If the extension development host was started without debugger attached we need
// to communicate this back to the main side to terminate the debug session
if (this.isExtensionDevelopmentHost && !this.isExtensionDevelopmentTestFromCli && !this.isExtensionDevelopmentDebug) {
this.windowIpcService.broadcast({
this.broadcastService.broadcast({
channel: EXTENSION_TERMINATE_BROADCAST_CHANNEL,
payload: true
}, this.environmentService.extensionDevelopmentPath /* target */);
......
......@@ -31,7 +31,6 @@ import { ElectronWindow } from 'vs/workbench/electron-browser/window';
import { resolveWorkbenchCommonProperties, getOrCreateMachineId } from 'vs/platform/telemetry/node/workbenchCommonProperties';
import { machineIdIpcChannel } from 'vs/platform/telemetry/node/commonProperties';
import { WorkspaceStats } from 'vs/workbench/services/telemetry/common/workspaceStats';
import { IWindowIPCService, WindowIPCService } from 'vs/workbench/services/window/electron-browser/windowService';
import { IWindowsService, IWindowService, IWindowConfiguration } from 'vs/platform/windows/common/windows';
import { WindowsChannelClient } from 'vs/platform/windows/common/windowsIpc';
import { WindowService } from 'vs/platform/windows/electron-browser/windowService';
......@@ -100,6 +99,7 @@ import { registerThemingParticipant, ITheme, ICssStyleCollector } from 'vs/platf
import { foreground, selectionBackground, focusBorder, scrollbarShadow, scrollbarSliderActiveBackground, scrollbarSliderBackground, scrollbarSliderHoverBackground, listHighlightForeground, inputPlaceholderForeground } from 'vs/platform/theme/common/colorRegistry';
import { TextMateService } from 'vs/workbench/services/textMate/electron-browser/TMSyntax';
import { ITextMateService } from 'vs/workbench/services/textMate/electron-browser/textMateService';
import { IBroadcastService, BroadcastService } from "vs/platform/broadcast/electron-browser/broadcastService";
/**
* Services that we require for the Shell
......@@ -129,7 +129,7 @@ export class WorkbenchShell {
private telemetryService: ITelemetryService;
private extensionService: MainProcessExtensionService;
private windowsService: IWindowsService;
private windowIPCService: IWindowIPCService;
private broadcastService: IBroadcastService;
private timerService: ITimerService;
private themeService: WorkbenchThemeService;
private lifecycleService: LifecycleService;
......@@ -190,8 +190,7 @@ export class WorkbenchShell {
});
// Window
const activeWindow = this.workbench.getInstantiationService().createInstance(ElectronWindow, currentWindow, this.container);
this.windowIPCService.registerWindow(activeWindow);
this.workbench.getInstantiationService().createInstance(ElectronWindow, currentWindow, this.container);
// Handle case where workbench is not starting up properly
const timeoutHandle = setTimeout(() => {
......@@ -256,9 +255,8 @@ export class WorkbenchShell {
const instantiationService: IInstantiationService = new InstantiationService(serviceCollection, true);
// TODO@joao remove this
this.windowIPCService = instantiationService.createInstance<IWindowIPCService>(WindowIPCService);
serviceCollection.set(IWindowIPCService, this.windowIPCService);
this.broadcastService = new BroadcastService(currentWindow.id);
serviceCollection.set(IBroadcastService, this.broadcastService);
const mainProcessClient = new ElectronIPCClient(String(`window${currentWindow.id}`));
disposables.push(mainProcessClient);
......@@ -267,10 +265,10 @@ export class WorkbenchShell {
this.windowsService = new WindowsChannelClient(windowsChannel);
serviceCollection.set(IWindowsService, this.windowsService);
serviceCollection.set(IWindowService, new SyncDescriptor(WindowService, this.windowIPCService.getWindowId()));
serviceCollection.set(IWindowService, new SyncDescriptor(WindowService, currentWindow.id));
const sharedProcess = this.windowsService.whenSharedProcessReady()
.then(() => connectNet(this.environmentService.sharedIPCHandle, `window:${this.windowIPCService.getWindowId()}`));
.then(() => connectNet(this.environmentService.sharedIPCHandle, `window:${currentWindow.id}`));
sharedProcess
.done(client => client.registerChannel('choice', instantiationService.createInstance(ChoiceChannel)));
......@@ -385,7 +383,7 @@ export class WorkbenchShell {
serviceCollection.set(IUpdateService, new SyncDescriptor(UpdateChannelClient, updateChannel));
const urlChannel = mainProcessClient.getChannel('url');
serviceCollection.set(IURLService, new SyncDescriptor(URLChannelClient, urlChannel, this.windowIPCService.getWindowId()));
serviceCollection.set(IURLService, new SyncDescriptor(URLChannelClient, urlChannel, currentWindow.id));
return [instantiationService, serviceCollection];
}
......
......@@ -29,7 +29,6 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IWorkspaceConfigurationService } from 'vs/workbench/services/configuration/common/configuration';
import { IWindowsService, IWindowService, IWindowSettings, IWindowConfiguration, IPath, IOpenFileRequest } from 'vs/platform/windows/common/windows';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IWindowIPCService } from 'vs/workbench/services/window/electron-browser/windowService';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IConfigurationEditingService, ConfigurationTarget } from 'vs/workbench/services/configuration/common/configurationEditing';
......@@ -43,11 +42,9 @@ import { IExtensionService } from 'vs/platform/extensions/common/extensions';
import { KeyboardMapperFactory } from 'vs/workbench/services/keybinding/electron-browser/keybindingService';
import { Themable, EDITOR_DRAG_AND_DROP_BACKGROUND } from 'vs/workbench/common/theme';
import { remote, ipcRenderer as ipc, webFrame } from 'electron';
import { ipcRenderer as ipc, webFrame } from 'electron';
import { activeContrastBorder } from 'vs/platform/theme/common/colorRegistry';
const dialog = remote.dialog;
const TextInputActions: IAction[] = [
new Action('undo', nls.localize('undo', "Undo"), null, true, () => document.execCommand('undo') && TPromise.as(true)),
new Action('redo', nls.localize('redo', "Redo"), null, true, () => document.execCommand('redo') && TPromise.as(true)),
......@@ -69,7 +66,6 @@ export class ElectronWindow extends Themable {
constructor(
win: Electron.BrowserWindow,
shellContainer: HTMLElement,
@IWindowIPCService private windowIPCService: IWindowIPCService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@IEditorGroupService private editorGroupService: IEditorGroupService,
@IPartService private partService: IPartService,
......@@ -143,7 +139,7 @@ export class ElectronWindow extends Themable {
.on(DOM.EventType.DROP, (e: DragEvent) => {
DOM.EventHelper.stop(e, true);
this.focus(); // make sure this window has focus so that the open call reaches the right window!
this.windowService.focusWindow(); // make sure this window has focus so that the open call reaches the right window!
// Ask the user when opening a potential large number of folders
let doOpen = true;
......@@ -250,7 +246,7 @@ export class ElectronWindow extends Themable {
// Emit event when vscode has loaded
this.partService.joinCreation().then(() => {
ipc.send('vscode:workbenchLoaded', this.windowIPCService.getWindowId());
ipc.send('vscode:workbenchLoaded', this.windowService.getCurrentWindowId());
});
// Message support
......@@ -463,24 +459,4 @@ export class ElectronWindow extends Themable {
return stat(resource.fsPath).then(stats => stats.isDirectory() ? true : false, error => false);
})).then(res => res.some(res => !!res));
}
public close(): void {
this.win.close();
}
public showMessageBox(options: Electron.ShowMessageBoxOptions): number {
return dialog.showMessageBox(this.win, options);
}
public showSaveDialog(options: Electron.SaveDialogOptions, callback?: (fileName: string) => void): string {
if (callback) {
return dialog.showSaveDialog(this.win, options, callback);
}
return dialog.showSaveDialog(this.win, options); // https://github.com/electron/electron/issues/4936
}
public focus(): TPromise<void> {
return this.windowService.focusWindow();
}
}
......@@ -25,7 +25,7 @@ import { IExtensionService } from 'vs/platform/extensions/common/extensions';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { FileChangesEvent, FileChangeType, IFileService } from 'vs/platform/files/common/files';
import { IMessageService, CloseAction } from 'vs/platform/message/common/message';
import { IWindowsService } from 'vs/platform/windows/common/windows';
import { IWindowsService, IWindowService } from 'vs/platform/windows/common/windows';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { TelemetryService } from 'vs/platform/telemetry/common/telemetryService';
import { TelemetryAppenderClient } from 'vs/platform/telemetry/common/telemetryIpc';
......@@ -48,8 +48,8 @@ import { ITextFileService } from 'vs/workbench/services/textfile/common/textfile
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IWindowIPCService, IBroadcast } from 'vs/workbench/services/window/electron-browser/windowService';
import { ILogEntry, EXTENSION_LOG_BROADCAST_CHANNEL, EXTENSION_ATTACH_BROADCAST_CHANNEL, EXTENSION_TERMINATE_BROADCAST_CHANNEL } from 'vs/workbench/electron-browser/extensionHost';
import { IBroadcastService, IBroadcast } from "vs/platform/broadcast/electron-browser/broadcastService";
const DEBUG_BREAKPOINTS_KEY = 'debug.breakpoint';
const DEBUG_BREAKPOINTS_ACTIVATED_KEY = 'debug.breakpointactivated';
......@@ -91,7 +91,8 @@ export class DebugService implements debug.IDebugService {
@IMessageService private messageService: IMessageService,
@IPartService private partService: IPartService,
@IWindowsService private windowsService: IWindowsService,
@IWindowIPCService private windowService: IWindowIPCService,
@IWindowService private windowService: IWindowService,
@IBroadcastService private broadcastService: IBroadcastService,
@ITelemetryService private telemetryService: ITelemetryService,
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IContextKeyService contextKeyService: IContextKeyService,
......@@ -144,7 +145,7 @@ export class DebugService implements debug.IDebugService {
lifecycleService.onShutdown(this.store, this);
lifecycleService.onShutdown(this.dispose, this);
this.toDispose.push(this.windowService.onBroadcast(this.onBroadcast, this));
this.toDispose.push(this.broadcastService.onBroadcast(this.onBroadcast, this));
this.toDispose.push(this.configurationService.onDidUpdateConfiguration((event) => {
if (event.sourceConfig) {
const names = this.configurationManager.getConfigurationNames();
......@@ -276,7 +277,7 @@ export class DebugService implements debug.IDebugService {
this.focusStackFrameAndEvaluate(stackFrameToFocus).done(null, errors.onUnexpectedError);
if (thread.stoppedDetails) {
this.windowService.getWindow().focus();
this.windowService.focusWindow();
aria.alert(nls.localize('debuggingPaused', "Debugging paused, reason {0}, {1} {2}", thread.stoppedDetails.reason, stackFrameToFocus.source ? stackFrameToFocus.source.name : '', stackFrameToFocus.range.startLineNumber));
}
......
......@@ -12,7 +12,6 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { IPartService } from 'vs/workbench/services/part/common/partService';
import { IWindowIPCService } from 'vs/workbench/services/window/electron-browser/windowService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IConfigurationEditingService, ConfigurationTarget } from 'vs/workbench/services/configuration/common/configurationEditing';
import { IQuickOpenService, IPickOpenEntry, IPickOptions } from 'vs/platform/quickOpen/common/quickOpen';
......@@ -26,6 +25,7 @@ import Severity from 'vs/base/common/severity';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { TERMINAL_DEFAULT_SHELL_WINDOWS } from "vs/workbench/parts/terminal/electron-browser/terminal";
import { TerminalPanel } from "vs/workbench/parts/terminal/electron-browser/terminalPanel";
import { IWindowService } from "vs/platform/windows/common/windows";
export class TerminalService extends AbstractTerminalService implements ITerminalService {
private _configHelper: TerminalConfigHelper;
......@@ -38,7 +38,7 @@ export class TerminalService extends AbstractTerminalService implements ITermina
@IPartService _partService: IPartService,
@ILifecycleService _lifecycleService: ILifecycleService,
@IInstantiationService private _instantiationService: IInstantiationService,
@IWindowIPCService private _windowService: IWindowIPCService,
@IWindowService private _windowService: IWindowService,
@IQuickOpenService private _quickOpenService: IQuickOpenService,
@IConfigurationEditingService private _configurationEditingService: IConfigurationEditingService,
@IChoiceService private _choiceService: IChoiceService,
......@@ -220,7 +220,7 @@ export class TerminalService extends AbstractTerminalService implements ITermina
noLink: true,
cancelId
};
return this._windowService.getWindow().showMessageBox(opts) === cancelId;
return this._windowService.showMessageBox(opts) === cancelId;
}
public setContainers(panelContainer: HTMLElement, terminalContainer: HTMLElement): void {
......
......@@ -10,9 +10,9 @@ import { toErrorMessage } from 'vs/base/common/errorMessage';
import { ILifecycleService, ShutdownEvent, ShutdownReason, StartupKind, LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import { IMessageService } from 'vs/platform/message/common/message';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { IWindowIPCService } from 'vs/workbench/services/window/electron-browser/windowService';
import { ipcRenderer as ipc } from 'electron';
import Event, { Emitter } from 'vs/base/common/event';
import { IWindowService } from "vs/platform/windows/common/windows";
export class LifecycleService implements ILifecycleService {
......@@ -29,7 +29,7 @@ export class LifecycleService implements ILifecycleService {
constructor(
@IMessageService private _messageService: IMessageService,
@IWindowIPCService private _windowService: IWindowIPCService,
@IWindowService private _windowService: IWindowService,
@IStorageService private _storageService: IStorageService
) {
this._registerListeners();
......@@ -73,7 +73,7 @@ export class LifecycleService implements ILifecycleService {
}
private _registerListeners(): void {
const windowId = this._windowService.getWindowId();
const windowId = this._windowService.getCurrentWindowId();
// Main side indicates that window is about to unload, check for vetos
ipc.on('vscode:beforeUnload', (event, reply: { okChannel: string, cancelChannel: string, reason: ShutdownReason }) => {
......
......@@ -5,7 +5,6 @@
'use strict';
import { IWindowIPCService } from 'vs/workbench/services/window/electron-browser/windowService';
import nls = require('vs/nls');
import product from 'vs/platform/node/product';
import { TPromise } from 'vs/base/common/winjs.base';
......@@ -14,12 +13,13 @@ import { IConfirmation, Severity, IChoiceService } from 'vs/platform/message/com
import { isWindows, isLinux } from 'vs/base/common/platform';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { Action } from 'vs/base/common/actions';
import { IWindowService } from "vs/platform/windows/common/windows";
export class MessageService extends WorkbenchMessageService implements IChoiceService {
constructor(
container: HTMLElement,
@IWindowIPCService private windowService: IWindowIPCService,
@IWindowService private windowService: IWindowService,
@ITelemetryService telemetryService: ITelemetryService
) {
super(container, telemetryService);
......@@ -98,7 +98,7 @@ export class MessageService extends WorkbenchMessageService implements IChoiceSe
opts.noLink = true;
opts.title = opts.title || product.nameLong;
const result = this.windowService.getWindow().showMessageBox(opts);
const result = this.windowService.showMessageBox(opts);
return isLinux ? opts.buttons.length - result - 1 : result;
}
......
......@@ -21,14 +21,13 @@ import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IModeService } from 'vs/editor/common/services/modeService';
import { IWindowIPCService } from 'vs/workbench/services/window/electron-browser/windowService';
import { ModelBuilder } from 'vs/workbench/services/textfile/electron-browser/modelBuilder';
import product from 'vs/platform/node/product';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IMessageService } from 'vs/platform/message/common/message';
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
import { IWindowsService } from 'vs/platform/windows/common/windows';
import { IWindowsService, IWindowService } from 'vs/platform/windows/common/windows';
import { IHistoryService } from 'vs/workbench/services/history/common/history';
export class TextFileService extends AbstractTextFileService {
......@@ -44,7 +43,7 @@ export class TextFileService extends AbstractTextFileService {
@ITelemetryService telemetryService: ITelemetryService,
@IConfigurationService configurationService: IConfigurationService,
@IModeService private modeService: IModeService,
@IWindowIPCService private windowService: IWindowIPCService,
@IWindowService private windowService: IWindowService,
@IEnvironmentService environmentService: IEnvironmentService,
@IMessageService messageService: IMessageService,
@IBackupFileService backupFileService: IBackupFileService,
......@@ -132,7 +131,7 @@ export class TextFileService extends AbstractTextFileService {
opts.defaultId = 2;
}
const choice = this.windowService.getWindow().showMessageBox(opts);
const choice = this.windowService.showMessageBox(opts);
return buttons[choice].result;
}
......@@ -146,7 +145,7 @@ export class TextFileService extends AbstractTextFileService {
}
public promptForPath(defaultPath?: string): string {
return this.windowService.getWindow().showSaveDialog(this.getSaveDialogOptions(defaultPath ? paths.normalize(defaultPath, true) : void 0));
return this.windowService.showSaveDialog(this.getSaveDialogOptions(defaultPath ? paths.normalize(defaultPath, true) : void 0));
}
private getSaveDialogOptions(defaultPath?: string): Electron.SaveDialogOptions {
......
......@@ -14,7 +14,6 @@ import * as objects from 'vs/base/common/objects';
import { IExtensionService } from 'vs/platform/extensions/common/extensions';
import { ExtensionsRegistry, ExtensionMessageCollector } from 'vs/platform/extensions/common/extensionsRegistry';
import { IWorkbenchThemeService, IColorTheme, IFileIconTheme, ExtensionData, IThemeExtensionPoint, VS_LIGHT_THEME, VS_DARK_THEME, VS_HC_THEME, COLOR_THEME_SETTING, ICON_THEME_SETTING, CUSTOM_COLORS_SETTING, DEPRECATED_CUSTOM_COLORS_SETTING } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { IWindowIPCService } from 'vs/workbench/services/window/electron-browser/windowService';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { Registry } from 'vs/platform/registry/common/platform';
......@@ -40,6 +39,7 @@ import colorThemeSchema = require('vs/workbench/services/themes/common/colorThem
import fileIconThemeSchema = require('vs/workbench/services/themes/common/fileIconThemeSchema');
import { IDisposable } from 'vs/base/common/lifecycle';
import { getParseErrorMessage } from 'vs/base/common/jsonErrorMessages';
import { IBroadcastService } from "vs/platform/broadcast/electron-browser/broadcastService";
// implementation
......@@ -202,7 +202,7 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
container: HTMLElement,
@IExtensionService private extensionService: IExtensionService,
@IStorageService private storageService: IStorageService,
@IWindowIPCService private windowService: IWindowIPCService,
@IBroadcastService private broadcastService: IBroadcastService,
@IConfigurationService private configurationService: IConfigurationService,
@IEnvironmentService private environmentService: IEnvironmentService,
@IMessageService private messageService: IMessageService,
......@@ -449,7 +449,7 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
if (settingsTarget !== ConfigurationTarget.WORKSPACE) {
let background = newTheme.getColor(editorBackground).toRGBHex(); // only take RGB, its what is used in the initial CSS
let data = { id: newTheme.id, background: background };
this.windowService.broadcast({ channel: 'vscode:changeColorTheme', payload: JSON.stringify(data) });
this.broadcastService.broadcast({ channel: 'vscode:changeColorTheme', payload: JSON.stringify(data) });
}
// remember theme data for a quick restore
this.storageService.store(PERSISTED_THEME_STORAGE_KEY, newTheme.toStorageData());
......
......@@ -912,6 +912,14 @@ export class TestWindowService implements IWindowService {
onWindowTitleDoubleClick(): TPromise<void> {
return TPromise.as(void 0);
}
showMessageBox(options: Electron.ShowMessageBoxOptions): number {
return 0;
}
showSaveDialog(options: Electron.SaveDialogOptions, callback?: (fileName: string) => void): string {
return void 0;
}
}
export class TestLifecycleService implements ILifecycleService {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册