Skip to content

Commit 540cfbd

Browse files
author
Benjamin Pasero
committed
use correct theme
1 parent fec6d40 commit 540cfbd

4 files changed

Lines changed: 36 additions & 27 deletions

File tree

src/vs/workbench/browser/part.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import 'vs/css!./media/part';
99
import { Dimension, Builder } from 'vs/base/browser/builder';
1010
import { WorkbenchComponent } from 'vs/workbench/common/component';
11-
import { IThemeService } from 'vs/platform/theme/common/themeService';
11+
import { IThemeService, ITheme, ICssStyleCollector } from 'vs/platform/theme/common/themeService';
1212

1313
export interface IPartOptions {
1414
hasTitle?: boolean;
@@ -32,9 +32,11 @@ export abstract class Part extends WorkbenchComponent {
3232
super(id, themeService);
3333
}
3434

35-
protected onThemeChange(): void {
35+
protected onThemeChange(theme: ITheme, collector: ICssStyleCollector): void {
36+
37+
// only call if our create() method has been called
3638
if (this.parent) {
37-
this.updateStyles(); // only call if our create() method has been called
39+
super.onThemeChange(theme, collector);
3840
}
3941
}
4042

src/vs/workbench/common/component.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import { IDisposable, dispose, Disposable } from 'vs/base/common/lifecycle';
88
import { Scope, Memento } from 'vs/workbench/common/memento';
99
import { IStorageService } from 'vs/platform/storage/common/storage';
10-
import { IThemeService } from 'vs/platform/theme/common/themeService';
10+
import { IThemeService, ITheme, ICssStyleCollector } from 'vs/platform/theme/common/themeService';
1111

1212
/**
1313
* Base class of any core/ui component in the workbench. Examples include services, extensions, parts, viewlets and quick open.
@@ -39,6 +39,7 @@ export class WorkbenchComponent extends Disposable implements IWorkbenchComponen
3939
private _toUnbind: IDisposable[];
4040
private id: string;
4141
private componentMemento: Memento;
42+
private theme: ITheme;
4243

4344
constructor(
4445
id: string,
@@ -49,23 +50,26 @@ export class WorkbenchComponent extends Disposable implements IWorkbenchComponen
4950
this._toUnbind = [];
5051
this.id = id;
5152
this.componentMemento = new Memento(this.id);
53+
this.theme = themeService.getTheme();
5254

5355
// Hook up to theme changes
54-
this.toUnbind.push(this.themeService.onThemeChange(() => this.onThemeChange()));
56+
this.toUnbind.push(this.themeService.onThemeChange((theme, collector) => this.onThemeChange(theme, collector)));
5557
}
5658

57-
protected getColor(id: string): string {
58-
return this.themeService.getTheme().getColor(id).toString();
59-
}
59+
protected onThemeChange(theme: ITheme, collector: ICssStyleCollector): void {
60+
this.theme = theme;
6061

61-
protected onThemeChange(): void {
62-
this.updateStyles();
62+
this.updateStyles(collector);
6363
}
6464

65-
protected updateStyles(): void {
65+
protected updateStyles(collector: ICssStyleCollector): void {
6666
// Subclasses to override
6767
}
6868

69+
protected getColor(id: string): string {
70+
return this.theme.getColor(id).toString();
71+
}
72+
6973
protected get toUnbind() {
7074
return this._toUnbind;
7175
}

src/vs/workbench/test/browser/part.test.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,7 @@ import { IWorkspaceContextService, WorkspaceContextService } from 'vs/platform/w
1313
import { IStorageService } from 'vs/platform/storage/common/storage';
1414
import { StorageService, InMemoryLocalStorage } from 'vs/platform/storage/common/storageService';
1515
import { TestWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
16-
import { IThemeService, ITheme, IThemingParticipant } from 'vs/platform/theme/common/themeService';
17-
import { IDisposable } from 'vs/base/common/lifecycle';
18-
19-
class TestThemeService implements IThemeService {
20-
21-
_serviceBrand: any;
22-
23-
getTheme(): ITheme {
24-
throw new Error('Method not implemented.');
25-
}
26-
27-
onThemeChange(participant: IThemingParticipant): IDisposable {
28-
return { dispose: () => { } };
29-
}
30-
}
16+
import { TestThemeService } from 'vs/workbench/test/workbenchTestServices';
3117

3218
class MyPart extends Part {
3319

src/vs/workbench/test/workbenchTestServices.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import { RawTextSource, IRawTextSource } from 'vs/editor/common/model/textSource
5252
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
5353
import { IThemeService, ITheme, IThemingParticipant } from 'vs/platform/theme/common/themeService';
5454
import { IDisposable } from 'vs/base/common/lifecycle';
55+
import { Color } from "vs/base/common/color";
5556

5657
export function createFileInput(instantiationService: IInstantiationService, resource: URI): FileEditorInput {
5758
return instantiationService.createInstance(FileEditorInput, resource, void 0);
@@ -973,12 +974,28 @@ export class TestWindowsService implements IWindowsService {
973974
}
974975
}
975976

977+
export class TestTheme implements ITheme {
978+
selector: string;
979+
label: string;
980+
type: 'light' | 'dark' | 'hc';
981+
982+
getColor(color: string, useDefault?: boolean): Color {
983+
throw new Error('Method not implemented.');
984+
}
985+
986+
isDefault(color: string): boolean {
987+
throw new Error('Method not implemented.');
988+
}
989+
}
990+
991+
const testTheme = new TestTheme();
992+
976993
export class TestThemeService implements IThemeService {
977994

978995
_serviceBrand: any;
979996

980997
getTheme(): ITheme {
981-
throw new Error('Method not implemented.');
998+
return testTheme;
982999
}
9831000

9841001
onThemeChange(participant: IThemingParticipant): IDisposable {

0 commit comments

Comments
 (0)