提交 129016f0 编写于 作者: B Benjamin Pasero

labels - adopt for search view

上级 5d04ca2e
......@@ -45,7 +45,14 @@ export interface IResourceLabelHandle extends IDisposable {
readonly element: HTMLElement;
/**
* Most basic method to apply a label.
* Most generic way to apply a label directly.
*/
setValue(label?: string, description?: string, options?: IIconLabelValueOptions): void;
/**
* Convinient method to apply a label by passing a resource along.
*
* Note: for file resources consider to use the #setFile() method instead.
*/
setLabel(label: IResourceLabel, options?: IResourceLabelOptions): void;
......@@ -117,6 +124,7 @@ export class ResourceLabels extends Disposable {
// Only expose a handle to the outside
const label: IResourceLabelHandle = {
element: widget.element,
setValue: (label?: string, description?: string, options?: IIconLabelValueOptions) => widget.setValue(label, description, options),
setLabel: (label: IResourceLabel, options?: IResourceLabelOptions) => widget.setLabel(label, options),
setEditor: (editor: IEditorInput, options?: IResourceLabelOptions) => widget.setEditor(editor, options),
setFile: (resource: uri, options?: IFileLabelOptions) => widget.setFile(resource, options),
......
......@@ -23,7 +23,7 @@ import { ISearchConfigurationProperties } from 'vs/platform/search/common/search
import { attachBadgeStyler } from 'vs/platform/theme/common/styler';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { FileLabel } from 'vs/workbench/browser/labels';
import { IResourceLabelHandle, ResourceLabels } from 'vs/workbench/browser/labels';
import { RemoveAction, ReplaceAction, ReplaceAllAction, ReplaceAllInFolderAction } from 'vs/workbench/parts/search/browser/searchActions';
import { SearchView } from 'vs/workbench/parts/search/browser/searchView';
import { FileMatch, FolderMatch, Match, RenderableMatch, searchMatchComparer, SearchModel } from 'vs/workbench/parts/search/common/searchModel';
......@@ -35,14 +35,14 @@ export class SearchSorter implements ISorter {
}
interface IFolderMatchTemplate {
label: FileLabel;
label: IResourceLabelHandle;
badge: CountBadge;
actions: ActionBar;
}
interface IFileMatchTemplate {
el: HTMLElement;
label: FileLabel;
label: IResourceLabelHandle;
badge: CountBadge;
actions: ActionBar;
}
......@@ -84,6 +84,7 @@ export class FolderMatchRenderer extends Disposable implements ITreeRenderer<Fol
constructor(
private searchModel: SearchModel,
private searchView: SearchView,
private labels: ResourceLabels,
@IInstantiationService private instantiationService: IInstantiationService,
@IThemeService private themeService: IThemeService,
@IWorkspaceContextService protected contextService: IWorkspaceContextService
......@@ -93,7 +94,7 @@ export class FolderMatchRenderer extends Disposable implements ITreeRenderer<Fol
renderTemplate(container: HTMLElement): IFolderMatchTemplate {
let folderMatchElement = DOM.append(container, DOM.$('.foldermatch'));
const label = this.instantiationService.createInstance(FileLabel, folderMatchElement, void 0);
const label = this.labels.create(folderMatchElement);
const badge = new CountBadge(DOM.append(folderMatchElement, DOM.$('.badge')));
this._register(attachBadgeStyler(badge, this.themeService));
const actionBarContainer = DOM.append(folderMatchElement, DOM.$('.actionBarContainer'));
......@@ -146,6 +147,7 @@ export class FileMatchRenderer extends Disposable implements ITreeRenderer<FileM
constructor(
private searchModel: SearchModel,
private searchView: SearchView,
private labels: ResourceLabels,
@IInstantiationService private instantiationService: IInstantiationService,
@IThemeService private themeService: IThemeService,
@IWorkspaceContextService protected contextService: IWorkspaceContextService
......@@ -155,7 +157,7 @@ export class FileMatchRenderer extends Disposable implements ITreeRenderer<FileM
renderTemplate(container: HTMLElement): IFileMatchTemplate {
let fileMatchElement = DOM.append(container, DOM.$('.filematch'));
const label = this.instantiationService.createInstance(FileLabel, fileMatchElement, void 0);
const label = this.labels.create(fileMatchElement);
const badge = new CountBadge(DOM.append(fileMatchElement, DOM.$('.badge')));
this._register(attachBadgeStyler(badge, this.themeService));
const actionBarContainer = DOM.append(fileMatchElement, DOM.$('.actionBarContainer'));
......
......@@ -62,6 +62,7 @@ import { IEditorGroupsService } from 'vs/workbench/services/group/common/editorG
import { IPartService } from 'vs/workbench/services/part/common/partService';
import { IPreferencesService, ISettingsEditorOptions } from 'vs/workbench/services/preferences/common/preferences';
import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
import { ResourceLabels } from 'vs/workbench/browser/labels';
const $ = dom.$;
......@@ -136,6 +137,7 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
private contextMenu: IMenu;
private tree: WorkbenchObjectTree<RenderableMatch>;
private labels: ResourceLabels;
private viewletState: object;
private globalMemento: object;
private messagesElement: HTMLElement;
......@@ -584,18 +586,19 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
}
};
this.tree = <WorkbenchObjectTree<RenderableMatch, any>>this.instantiationService.createInstance(WorkbenchObjectTree,
this.labels = this._register(this.instantiationService.createInstance(ResourceLabels));
this.tree = this._register(<WorkbenchObjectTree<RenderableMatch, any>>this.instantiationService.createInstance(WorkbenchObjectTree,
this.resultsElement,
delegate,
[
this._register(this.instantiationService.createInstance(FolderMatchRenderer, this.viewModel, this)),
this._register(this.instantiationService.createInstance(FileMatchRenderer, this.viewModel, this)),
this._register(this.instantiationService.createInstance(FolderMatchRenderer, this.viewModel, this, this.labels)),
this._register(this.instantiationService.createInstance(FileMatchRenderer, this.viewModel, this, this.labels)),
this._register(this.instantiationService.createInstance(MatchRenderer, this.viewModel, this)),
],
{
identityProvider,
accessibilityProvider: this.instantiationService.createInstance(SearchAccessibilityProvider, this.viewModel)
});
}));
this._register(this.tree.onContextMenu(e => this.onContextMenu(e)));
const resourceNavigator = this._register(new TreeResourceNavigator2(this.tree, { openOnFocus: true }));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册