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

icons: adopt in problems view

上级 4284156b
......@@ -7,26 +7,33 @@
import 'vs/css!./iconlabel';
import dom = require('vs/base/browser/dom');
import {HighlightedLabel} from 'vs/base/browser/ui/highlightedlabel/highlightedLabel';
import {IMatch} from 'vs/base/common/filters';
export interface IIconLabelCreationOptions {
supportHighlights?: boolean;
}
export interface IIconLabelOptions {
title?: string;
extraClasses?: string[];
italic?: boolean;
matches?: IMatch[];
}
export class IconLabel {
private domNode: HTMLElement;
private labelNode: HTMLElement;
private labelNode: HTMLElement|HighlightedLabel;
private descriptionNode: HTMLElement;
constructor(container: HTMLElement, label?: string, description?: string, options?: IIconLabelOptions) {
constructor(container: HTMLElement, options?: IIconLabelCreationOptions) {
this.domNode = dom.append(container, dom.$('.monaco-icon-label'));
this.labelNode = dom.append(this.domNode, dom.$('a.label-name'));
this.descriptionNode = dom.append(this.domNode, dom.$('span.label-description'));
if (label) {
this.setValue(label, description, options);
if (options && options.supportHighlights) {
this.labelNode = new HighlightedLabel(dom.append(this.domNode, dom.$('a.label-name')));
} else {
this.labelNode = dom.append(this.domNode, dom.$('a.label-name'));
}
this.descriptionNode = dom.append(this.domNode, dom.$('span.label-description'));
}
public getHTMLElement(): HTMLElement {
......@@ -34,7 +41,13 @@ export class IconLabel {
}
public setValue(label?: string, description?: string, options?: IIconLabelOptions): void {
this.labelNode.textContent = label || '';
const labelNode = this.labelNode;
if (labelNode instanceof HighlightedLabel) {
labelNode.set(label || '', options ? options.matches : void 0);
} else {
labelNode.textContent = label || '';
}
this.descriptionNode.textContent = description || '';
this.domNode.title = options && options.title ? options.title : '';
......@@ -52,4 +65,11 @@ export class IconLabel {
this.domNode.className = classes.join(' ');
}
public dispose(): void {
const labelNode = this.labelNode;
if (labelNode instanceof HighlightedLabel) {
labelNode.dispose();
}
}
}
\ No newline at end of file
......@@ -7,7 +7,7 @@
import uri from 'vs/base/common/uri';
import paths = require('vs/base/common/paths');
import {IconLabel, IIconLabelOptions} from 'vs/base/browser/ui/iconLabel/iconLabel';
import {IconLabel, IIconLabelOptions, IIconLabelCreationOptions} from 'vs/base/browser/ui/iconLabel/iconLabel';
import {IExtensionService} from 'vs/platform/extensions/common/extensions';
import {IModeService} from 'vs/editor/common/services/modeService';
import {IEditorInput} from 'vs/platform/editor/common/editor';
......@@ -34,12 +34,13 @@ export class ResourceLabel extends IconLabel {
constructor(
container: HTMLElement,
options: IIconLabelCreationOptions,
@IExtensionService private extensionService: IExtensionService,
@IWorkspaceContextService protected contextService: IWorkspaceContextService,
@IConfigurationService private configurationService: IConfigurationService,
@IModeService private modeService: IModeService
) {
super(container);
super(container, options);
this.toDispose = [];
......@@ -85,8 +86,9 @@ export class ResourceLabel extends IconLabel {
}
const italic = this.options && this.options.italic;
const matches = this.options && this.options.matches;
this.setValue(this.label.name, this.label.description, { title, extraClasses, italic });
this.setValue(this.label.name, this.label.description, { title, extraClasses, italic, matches });
}
protected getIconClasses(arg1?: uri | string): string[] {
......@@ -129,6 +131,8 @@ export class ResourceLabel extends IconLabel {
}
public dispose(): void {
super.dispose();
this.toDispose = dispose(this.toDispose);
this.label = void 0;
this.options = void 0;
......
......@@ -41,7 +41,7 @@ export class NoTabsTitleControl extends TitleControl {
this.titleContainer.appendChild(this.titleDecoration);
// Editor Label
this.editorLabel = this.instantiationService.createInstance(EditorLabel, this.titleContainer);
this.editorLabel = this.instantiationService.createInstance(EditorLabel, this.titleContainer, void 0);
this.toDispose.push(this.editorLabel);
this.toDispose.push(DOM.addDisposableListener(this.editorLabel.getHTMLElement(), DOM.EventType.CLICK, (e: MouseEvent) => this.onTitleLabelClick(e)));
......
......@@ -339,7 +339,7 @@ export class TabsTitleControl extends TitleControl {
tabContainers.push(tabContainer);
// Tab Editor Label
const editorLabel = this.instantiationService.createInstance(EditorLabel, tabContainer);
const editorLabel = this.instantiationService.createInstance(EditorLabel, tabContainer, void 0);
this.editorLabels.push(editorLabel);
// Tab Close
......
......@@ -295,7 +295,7 @@ export class FileRenderer extends ActionsRenderer implements IRenderer {
}
private renderLabel(container: Builder, stat: FileStat): IElementCallback {
const label = this.instantiationService.createInstance(FileLabel, container.getHTMLElement());
const label = this.instantiationService.createInstance(FileLabel, container.getHTMLElement(), void 0);
const extraClasses = ['explorer-item'];
label.setFile(stat.resource, { hidePath: true, isFolder: stat.isDirectory, extraClasses });
......
......@@ -158,7 +158,7 @@ export class Renderer implements IRenderer {
editorTemplate.container = container;
editorTemplate.actionBar = new ActionBar(container);
editorTemplate.actionBar.push(this.actionProvider.getOpenEditorActions(), { icon: true, label: false });
editorTemplate.root = this.instantiationService.createInstance(EditorLabel, container);
editorTemplate.root = this.instantiationService.createInstance(EditorLabel, container, void 0);
return editorTemplate;
}
......
......@@ -168,6 +168,7 @@ export class MarkersPanel extends Panel {
private createTree(parent: HTMLElement): void {
this.treeContainer = dom.append(parent, dom.$('.tree-container'));
dom.addClass(this.treeContainer, 'show-file-icons');
var actionProvider = this.instantiationService.createInstance(ActionProvider);
var renderer = this.instantiationService.createInstance(Viewer.Renderer, this.getActionRunner(), actionProvider);
let controller = this.instantiationService.createInstance(Controller, this.rangeHighlightDecorations);
......
......@@ -12,11 +12,12 @@ import Severity from 'vs/base/common/severity';
import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
import { ActionProvider } from 'vs/workbench/parts/markers/browser/markersActionProvider';
import { CountBadge } from 'vs/base/browser/ui/countBadge/countBadge';
import { FileLabel } from 'vs/base/browser/ui/fileLabel/fileLabel';
import { FileLabel } from 'vs/workbench/browser/labels';
import { HighlightedLabel } from 'vs/base/browser/ui/highlightedlabel/highlightedLabel';
import { IMarker } from 'vs/platform/markers/common/markers';
import { MarkersModel, Resource, Marker } from 'vs/workbench/parts/markers/common/markersModel';
import Messages from 'vs/workbench/parts/markers/common/messages';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
interface IResourceTemplateData {
file: FileLabel;
......@@ -70,7 +71,8 @@ export class Renderer implements IRenderer {
constructor(private actionRunner: IActionRunner,
private actionProvider:ActionProvider,
@IWorkspaceContextService private contextService: IWorkspaceContextService
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IInstantiationService private instantiationService: IInstantiationService
) {
}
......@@ -101,7 +103,7 @@ export class Renderer implements IRenderer {
private renderResourceTemplate(container: HTMLElement): IResourceTemplateData {
var data: IResourceTemplateData = Object.create(null);
const resourceLabelContainer = dom.append(container, dom.$('.resource-label-container'));
data.file = new FileLabel(resourceLabelContainer, null, this.contextService);
data.file = this.instantiationService.createInstance(FileLabel, resourceLabelContainer, { supportHighlights: true });
// data.statistics= new MarkersStatisticsWidget(dom.append(container, dom.emmet('.marker-stats')));
......@@ -130,7 +132,7 @@ export class Renderer implements IRenderer {
}
private renderResourceElement(tree: ITree, element: Resource, templateData: IResourceTemplateData) {
templateData.file.setValue(element.uri, element.matches);
templateData.file.setFile(element.uri, { matches: element.matches });
// templateData.statistics.setStatistics(element.statistics);
templateData.count.setCount(element.markers.length);
}
......
......@@ -140,7 +140,7 @@ export class SearchRenderer extends ActionsRenderer {
let widget: LeftRightWidget;
leftRenderer = (left: HTMLElement): any => {
const label = this.instantiationService.createInstance(FileLabel, left);
const label = this.instantiationService.createInstance(FileLabel, left, void 0);
label.setFile(fileMatch.resource());
return () => label.dispose();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册