提交 5d04ca2e 编写于 作者: B Benjamin Pasero

labels - adopt for open editors view

上级 33475542
......@@ -25,6 +25,22 @@ import { getIconClasses, getConfiguredLangId } from 'vs/editor/common/services/g
import { Disposable, dispose, IDisposable } from 'vs/base/common/lifecycle';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
export interface IResourceLabel {
name: string;
description?: string;
resource?: uri;
}
export interface IResourceLabelOptions extends IIconLabelValueOptions {
fileKind?: FileKind;
fileDecorations?: { colors: boolean, badges: boolean, data?: IDecorationData };
}
export interface IFileLabelOptions extends IResourceLabelOptions {
hideLabel?: boolean;
hidePath?: boolean;
}
export interface IResourceLabelHandle extends IDisposable {
readonly element: HTMLElement;
......@@ -396,17 +412,6 @@ class ResourceLabelWidget extends IconLabel {
}
}
export interface IResourceLabel {
name: string;
description?: string;
resource?: uri;
}
export interface IResourceLabelOptions extends IIconLabelValueOptions {
fileKind?: FileKind;
fileDecorations?: { colors: boolean, badges: boolean, data?: IDecorationData };
}
export class ResourceLabel extends IconLabel {
private _onDidRender = this._register(new Emitter<void>());
......@@ -620,22 +625,6 @@ export class ResourceLabel extends IconLabel {
}
}
export class EditorLabel extends ResourceLabel {
setEditor(editor: IEditorInput, options?: IResourceLabelOptions): void {
this.setLabel({
resource: toResource(editor, { supportSideBySide: true }),
name: editor.getName(),
description: editor.getDescription()
}, options);
}
}
export interface IFileLabelOptions extends IResourceLabelOptions {
hideLabel?: boolean;
hidePath?: boolean;
}
export class FileLabel extends ResourceLabel {
constructor(
......
......@@ -26,7 +26,7 @@ import { IThemeService } from 'vs/platform/theme/common/themeService';
import { badgeBackground, badgeForeground, contrastBorder } from 'vs/platform/theme/common/colorRegistry';
import { WorkbenchList } from 'vs/platform/list/browser/listService';
import { IListVirtualDelegate, IListRenderer, IListContextMenuEvent } from 'vs/base/browser/ui/list/list';
import { EditorLabel } from 'vs/workbench/browser/labels';
import { ResourceLabels, IResourceLabelHandle } from 'vs/workbench/browser/labels';
import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IEditorService, SIDE_GROUP, ACTIVE_GROUP } from 'vs/workbench/services/editor/common/editorService';
......@@ -51,6 +51,7 @@ export class OpenEditorsView extends ViewletPanel {
private listRefreshScheduler: RunOnceScheduler;
private structuralRefreshDelay: number;
private list: WorkbenchList<OpenEditor | IEditorGroup>;
private labels: ResourceLabels;
private contributedContextMenu: IMenu;
private needsRefresh: boolean;
private resourceContext: ResourceContextKey;
......@@ -213,14 +214,19 @@ export class OpenEditorsView extends ViewletPanel {
if (this.list) {
this.list.dispose();
}
if (this.labels) {
this.labels.clear();
}
this.labels = this.instantiationService.createInstance(ResourceLabels);
this.list = this.instantiationService.createInstance(WorkbenchList, container, delegate, [
new EditorGroupRenderer(this.keybindingService, this.instantiationService, this.editorGroupService),
new OpenEditorRenderer(getSelectedElements, this.instantiationService, this.keybindingService, this.configurationService, this.editorGroupService)
new OpenEditorRenderer(this.labels, getSelectedElements, this.instantiationService, this.keybindingService, this.configurationService, this.editorGroupService)
], {
identityProvider: { getId: (element: OpenEditor | IEditorGroup) => element instanceof OpenEditor ? element.getId() : element.id.toString() },
selectOnMouseDown: false /* disabled to better support DND */
}) as WorkbenchList<OpenEditor | IEditorGroup>;
this.disposables.push(this.list);
this.disposables.push(this.labels);
this.contributedContextMenu = this.menuService.createMenu(MenuId.OpenEditorsContext, this.list.contextKeyService);
this.disposables.push(this.contributedContextMenu);
......@@ -478,7 +484,7 @@ export class OpenEditorsView extends ViewletPanel {
interface IOpenEditorTemplateData {
container: HTMLElement;
root: EditorLabel;
root: IResourceLabelHandle;
actionBar: ActionBar;
actionRunner: OpenEditorActionRunner;
openEditor: OpenEditor;
......@@ -619,6 +625,7 @@ class OpenEditorRenderer implements IListRenderer<OpenEditor, IOpenEditorTemplat
private transfer = LocalSelectionTransfer.getInstance<OpenEditor>();
constructor(
private labels: ResourceLabels,
private getSelectedElements: () => Array<OpenEditor | IEditorGroup>,
private instantiationService: IInstantiationService,
private keybindingService: IKeybindingService,
......@@ -643,7 +650,7 @@ class OpenEditorRenderer implements IListRenderer<OpenEditor, IOpenEditorTemplat
const key = this.keybindingService.lookupKeybinding(closeEditorAction.id);
editorTemplate.actionBar.push(closeEditorAction, { icon: true, label: false, keybinding: key ? key.getLabel() : void 0 });
editorTemplate.root = this.instantiationService.createInstance(EditorLabel, container, void 0);
editorTemplate.root = this.labels.create(container);
editorTemplate.toDispose = [];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册