first wiring of update-call, #1396

This commit is contained in:
Johannes Rieken
2016-08-25 11:17:12 +02:00
parent 77e2cf8c43
commit 043ff9f76e
5 changed files with 30 additions and 13 deletions

View File

@@ -4,29 +4,35 @@
*--------------------------------------------------------------------------------------------*/
'use strict';
import {TPromise} from 'vs/base/common/winjs.base';
import {IDisposable, dispose} from 'vs/base/common/lifecycle';
import {IThreadService} from 'vs/workbench/services/thread/common/threadService';
import {IWorkbenchConfigurationService} from 'vs/workbench/services/configuration/common/configuration';
import {ExtHostContext, ExtHostConfigurationShape} from './extHost.protocol';
import {IConfigurationEditingService, ConfigurationTarget, ConfigurationEditingResult} from 'vs/workbench/services/configuration/common/configurationEditing';
import {MainThreadConfigurationShape, ExtHostContext} from './extHost.protocol';
export class MainThreadConfiguration {
export class MainThreadConfiguration extends MainThreadConfigurationShape {
private _configurationService: IWorkbenchConfigurationService;
private _configurationEditingService: IConfigurationEditingService;
private _toDispose: IDisposable;
private _proxy: ExtHostConfigurationShape;
constructor(
@IConfigurationEditingService configurationEditingService: IConfigurationEditingService,
@IWorkbenchConfigurationService configurationService: IWorkbenchConfigurationService,
@IThreadService threadService: IThreadService
) {
this._configurationService = configurationService;
this._proxy = threadService.get(ExtHostContext.ExtHostConfiguration);
this._toDispose = this._configurationService.onDidUpdateConfiguration(event => this._proxy.$acceptConfigurationChanged(event.config));
this._proxy.$acceptConfigurationChanged(this._configurationService.getConfiguration());
super();
this._configurationEditingService = configurationEditingService;
const proxy = threadService.get(ExtHostContext.ExtHostConfiguration);
this._toDispose = configurationService.onDidUpdateConfiguration(event => proxy.$acceptConfigurationChanged(event.config));
proxy.$acceptConfigurationChanged(configurationService.getConfiguration());
}
public dispose(): void {
this._toDispose = dispose(this._toDispose);
}
$updateConfigurationOption(target: ConfigurationTarget, key: string, value: any): TPromise<ConfigurationEditingResult> {
return this._configurationEditingService.writeConfiguration(target, [{ key, value }]);
}
}