提交 16752652 编写于 作者: B Benjamin Pasero

💄

上级 4c12a685
......@@ -7,7 +7,7 @@ import { TPromise } from 'vs/base/common/winjs.base';
import { Dimension, Builder } from 'vs/base/browser/builder';
import { IAction, IActionRunner, ActionRunner } from 'vs/base/common/actions';
import { IActionItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { WorkbenchComponent } from 'vs/workbench/common/component';
import { Component } from 'vs/workbench/common/component';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { AsyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { IComposite } from 'vs/workbench/common/composite';
......@@ -25,7 +25,7 @@ import { IThemeService } from 'vs/platform/theme/common/themeService';
* layout(), focus(), dispose(). During use of the workbench, a composite will often receive a setVisible,
* layout and focus call, but only one create and dispose call.
*/
export abstract class Composite extends WorkbenchComponent implements IComposite {
export abstract class Composite extends Component implements IComposite {
private _telemetryData: any = {};
private visible: boolean;
private parent: Builder;
......
......@@ -7,7 +7,7 @@
import 'vs/css!./media/part';
import { Dimension, Builder } from 'vs/base/browser/builder';
import { WorkbenchComponent } from 'vs/workbench/common/component';
import { Component } from 'vs/workbench/common/component';
import { IThemeService, ITheme, ICssStyleCollector } from 'vs/platform/theme/common/themeService';
export interface IPartOptions {
......@@ -18,7 +18,7 @@ export interface IPartOptions {
* Parts are layed out in the workbench and have their own layout that arranges an optional title
* and mandatory content area to show content.
*/
export abstract class Part extends WorkbenchComponent {
export abstract class Part extends Component {
private parent: Builder;
private titleArea: Builder;
private contentArea: Builder;
......
......@@ -33,9 +33,9 @@ import { IEditorStacksModel, IStacksModelChangeEvent, IEditorGroup, EditorOption
import { extractResources } from 'vs/base/browser/dnd';
import { IWindowService } from 'vs/platform/windows/common/windows';
import { getCodeEditor } from 'vs/editor/common/services/codeEditorService';
import { WorkbenchComponent } from 'vs/workbench/common/component';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { editorBackground } from 'vs/platform/theme/common/colorRegistry';
import { Themable } from 'vs/workbench/common/theme';
export enum Rochade {
NONE,
......@@ -85,7 +85,7 @@ export interface IEditorGroupsControl {
/**
* Helper class to manage multiple side by side editors for the editor part.
*/
export class EditorGroupsControl extends WorkbenchComponent implements IEditorGroupsControl, IVerticalSashLayoutProvider, IHorizontalSashLayoutProvider {
export class EditorGroupsControl extends Themable implements IEditorGroupsControl, IVerticalSashLayoutProvider, IHorizontalSashLayoutProvider {
private static TITLE_AREA_CONTROL_KEY = '__titleAreaControl';
private static PROGRESS_BAR_CONTROL_KEY = '__progressBar';
......@@ -144,7 +144,7 @@ export class EditorGroupsControl extends WorkbenchComponent implements IEditorGr
@IWindowService private windowService: IWindowService,
@IThemeService themeService: IThemeService
) {
super('workbench.parts.editor.groups', themeService);
super(themeService);
this.stacks = editorGroupService.getStacksModel();
......
......@@ -41,7 +41,7 @@ import { LinkedMap } from 'vs/base/common/map';
import { DelegatingWorkbenchEditorService } from 'vs/workbench/services/editor/browser/editorService';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { INACTIVE_TAB_BACKGROUND, ACTIVE_TAB_BACKGROUND } from 'vs/workbench/browser/styles';
import { INACTIVE_TAB_BACKGROUND, ACTIVE_TAB_BACKGROUND } from 'vs/workbench/common/theme';
interface IEditorInputLabel {
editor: IEditorInput;
......
......@@ -38,7 +38,7 @@ import { createActionItem, fillInActions } from 'vs/platform/actions/browser/men
import { IMenuService, MenuId, IMenu, ExecuteCommandAction } from 'vs/platform/actions/common/actions';
import { ResourceContextKey } from 'vs/workbench/common/resourceContextKey';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { WorkbenchComponent } from 'vs/workbench/common/component';
import { Themable } from 'vs/workbench/common/theme';
export interface IToolbarActions {
primary: IAction[];
......@@ -58,7 +58,7 @@ export interface ITitleAreaControl {
dispose(): void;
}
export abstract class TitleControl extends WorkbenchComponent implements ITitleAreaControl {
export abstract class TitleControl extends Themable implements ITitleAreaControl {
private static draggedEditor: IEditorIdentifier;
......@@ -103,7 +103,7 @@ export abstract class TitleControl extends WorkbenchComponent implements ITitleA
@IQuickOpenService protected quickOpenService: IQuickOpenService,
@IThemeService protected themeService: IThemeService
) {
super('workbench.parts.editor.title', themeService);
super(themeService);
this.stacks = editorGroupService.getStacksModel();
this.mapActionsToEditors = Object.create(null);
......
......@@ -25,7 +25,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { ActionsOrientation, ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
import { ClosePanelAction, PanelAction, ToggleMaximizedPanelAction } from 'vs/workbench/browser/parts/panel/panelActions';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { PANEL_BACKGROUND } from 'vs/workbench/browser/styles';
import { PANEL_BACKGROUND } from 'vs/workbench/common/theme';
export class PanelPart extends CompositePart<Panel> implements IPanelService {
......
......@@ -32,7 +32,7 @@ import { IModeService } from 'vs/editor/common/services/modeService';
import { getIconClasses } from 'vs/workbench/browser/labels';
import { IModelService } from 'vs/editor/common/services/modelService';
import { EditorInput, toResource, IWorkbenchEditorConfiguration } from 'vs/workbench/common/editor';
import { WorkbenchComponent } from 'vs/workbench/common/component';
import { Component } from 'vs/workbench/common/component';
import Event, { Emitter } from 'vs/base/common/event';
import { IPartService } from 'vs/workbench/services/part/common/partService';
import { KeyMod } from 'vs/base/common/keyCodes';
......@@ -73,7 +73,7 @@ interface IInternalPickOptions {
onDidType?: (value: string) => any;
}
export class QuickOpenController extends WorkbenchComponent implements IQuickOpenService {
export class QuickOpenController extends Component implements IQuickOpenService {
private static MAX_SHORT_RESPONSE_TIME = 500;
......
......@@ -27,7 +27,7 @@ import { getCodeEditor } from 'vs/editor/common/services/codeEditorService';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { Action } from 'vs/base/common/actions';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { STATUS_BAR_BACKGROUND, STATUS_BAR_FOREGROUND, STATUS_BAR_NO_FOLDER_BACKGROUND } from 'vs/workbench/browser/styles';
import { STATUS_BAR_BACKGROUND, STATUS_BAR_FOREGROUND, STATUS_BAR_NO_FOLDER_BACKGROUND } from 'vs/workbench/common/theme';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
export class StatusbarPart extends Part implements IStatusbarService {
......
......@@ -4,10 +4,11 @@
*--------------------------------------------------------------------------------------------*/
'use strict';
import { IDisposable, dispose, Disposable } from 'vs/base/common/lifecycle';
import { IDisposable } from 'vs/base/common/lifecycle';
import { Scope, Memento } from 'vs/workbench/common/memento';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { IThemeService, ITheme, ICssStyleCollector } from 'vs/platform/theme/common/themeService';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { Themable } from 'vs/workbench/common/theme';
/**
* Base class of any core/ui component in the workbench. Examples include services, extensions, parts, viewlets and quick open.
......@@ -28,50 +29,20 @@ export interface IWorkbenchComponent extends IDisposable {
* because dispose() is being called for this purpose and shutdown() has a chance to be vetoed by the user.
*/
shutdown(): void;
/**
* Called when the UI component is being removed from the container. Free up resources from here.
*/
dispose(): void;
}
export class WorkbenchComponent extends Disposable implements IWorkbenchComponent {
private _toUnbind: IDisposable[];
export class Component extends Themable implements IWorkbenchComponent {
private id: string;
private componentMemento: Memento;
private theme: ITheme;
constructor(
id: string,
protected themeService: IThemeService
themeService: IThemeService
) {
super();
super(themeService);
this._toUnbind = [];
this.id = id;
this.componentMemento = new Memento(this.id);
this.theme = themeService.getTheme();
// Hook up to theme changes
this.toUnbind.push(this.themeService.onThemeChange((theme, collector) => this.onThemeChange(theme, collector)));
}
protected onThemeChange(theme: ITheme, collector: ICssStyleCollector): void {
this.theme = theme;
this.updateStyles(theme, collector);
}
protected updateStyles(theme: ITheme, collector: ICssStyleCollector): void {
// Subclasses to override
}
protected getColor(id: string): string {
return this.theme.getColor(id).toString();
}
protected get toUnbind() {
return this._toUnbind;
}
public getId(): string {
......@@ -107,10 +78,4 @@ export class WorkbenchComponent extends Disposable implements IWorkbenchComponen
// Save Memento
this.saveMemento();
}
public dispose(): void {
this._toUnbind = dispose(this._toUnbind);
super.dispose();
}
}
\ No newline at end of file
......@@ -5,6 +5,8 @@
import nls = require('vs/nls');
import { registerColor, editorBackground } from 'vs/platform/theme/common/colorRegistry';
import { IDisposable, Disposable, dispose } from 'vs/base/common/lifecycle';
import { IThemeService, ITheme, ICssStyleCollector } from 'vs/platform/theme/common/themeService';
// < --- Tabs --- >
......@@ -48,4 +50,48 @@ export const STATUS_BAR_NO_FOLDER_BACKGROUND = registerColor('statusBarNoFolderB
dark: '#68217A',
light: '#68217A',
hc: '#00000000'
}, nls.localize('statusBarNoFolderBackground', "Status bar background color when no folder is opened. The status bar is shown in the bottom of the window"));
\ No newline at end of file
}, nls.localize('statusBarNoFolderBackground', "Status bar background color when no folder is opened. The status bar is shown in the bottom of the window"));
/**
* Base class for all themable workbench components.
*/
export class Themable extends Disposable {
private _toUnbind: IDisposable[];
private theme: ITheme;
constructor(
protected themeService: IThemeService
) {
super();
this._toUnbind = [];
this.theme = themeService.getTheme();
// Hook up to theme changes
this._toUnbind.push(this.themeService.onThemeChange((theme, collector) => this.onThemeChange(theme, collector)));
}
protected get toUnbind() {
return this._toUnbind;
}
protected onThemeChange(theme: ITheme, collector: ICssStyleCollector): void {
this.theme = theme;
this.updateStyles(theme, collector);
}
protected updateStyles(theme: ITheme, collector: ICssStyleCollector): void {
// Subclasses to override
}
protected getColor(id: string): string {
return this.theme.getColor(id).toString();
}
public dispose(): void {
this._toUnbind = dispose(this._toUnbind);
super.dispose();
}
}
\ No newline at end of file
......@@ -8,10 +8,9 @@ import { localize } from 'vs/nls';
import { registerColor } from 'vs/platform/theme/common/colorRegistry';
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
import { IPartService, Parts } from 'vs/workbench/services/part/common/partService';
import { WorkbenchComponent } from 'vs/workbench/common/component';
import { IDebugService, State } from 'vs/workbench/parts/debug/common/debug';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { STATUS_BAR_NO_FOLDER_BACKGROUND, STATUS_BAR_BACKGROUND } from 'vs/workbench/browser/styles';
import { STATUS_BAR_NO_FOLDER_BACKGROUND, STATUS_BAR_BACKGROUND, Themable } from 'vs/workbench/common/theme';
// colors for theming
......@@ -21,7 +20,7 @@ export const STATUS_BAR_DEBUGGING_BACKGROUND = registerColor('statusBarDebugging
hc: '#CC6633'
}, localize('statusBarDebuggingBackground', "Status bar background color when a program is being debugged. The status bar is shown in the bottom of the window"));
export class StatusBarColorProvider extends WorkbenchComponent implements IWorkbenchContribution {
export class StatusBarColorProvider extends Themable implements IWorkbenchContribution {
private static ID = 'debug.statusbarColorProvider';
constructor(
......@@ -30,7 +29,7 @@ export class StatusBarColorProvider extends WorkbenchComponent implements IWorkb
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IPartService private partService: IPartService
) {
super(StatusBarColorProvider.ID, themeService);
super(themeService);
this.registerListeners();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册