提交 ce565938 编写于 作者: S Sandeep Somavarapu

Clean up Search viewlet - Pattern input widget

上级 13248eab
......@@ -6,6 +6,7 @@
import nls = require('vs/nls');
import strings = require('vs/base/common/strings');
import { $ } from 'vs/base/browser/builder';
import { Widget } from 'vs/base/browser/ui/widget';
import {IExpression, splitGlobAware} from 'vs/base/common/glob';
import { Checkbox } from 'vs/base/browser/ui/checkbox/checkbox';
import { IContextViewProvider } from 'vs/base/browser/ui/contextview/contextview';
......@@ -18,57 +19,56 @@ export interface IOptions {
ariaLabel?: string;
}
export class PatternInput {
export class PatternInputWidget extends Widget {
static OPTION_CHANGE: string = 'optionChange';
private contextViewProvider: IContextViewProvider;
private onOptionChange: (event: Event) => void;
private width: number;
private placeholder: string;
private ariaLabel: string;
private listenersToRemove: any[];
private toDispose: any[];
private pattern: Checkbox;
public domNode: HTMLElement;
private domNode: HTMLElement;
private inputNode: HTMLInputElement;
private inputBox: InputBox;
constructor(parent: HTMLElement, contextViewProvider: IContextViewProvider, options: IOptions = Object.create(null)) {
this.contextViewProvider = contextViewProvider;
constructor(parent: HTMLElement, private contextViewProvider: IContextViewProvider, options: IOptions = Object.create(null)) {
super();
this.onOptionChange = null;
this.width = options.width || 100;
this.placeholder = options.placeholder || '';
this.ariaLabel = options.ariaLabel || nls.localize('defaultLabel', "input");
this.listenersToRemove = [];
this.toDispose = [];
this.pattern = null;
this.domNode = null;
this.inputNode = null;
this.inputBox = null;
this.buildDomNode();
this.render();
if (Boolean(parent)) {
parent.appendChild(this.domNode);
}
parent.appendChild(this.domNode);
}
public destroy(): void {
public dispose(): void {
super.dispose();
this.pattern.dispose();
this.listenersToRemove.forEach((element) => {
this.toDispose.forEach((element) => {
element();
});
this.listenersToRemove = [];
this.toDispose = [];
}
public on(eventType: string, handler: (event: Event) => void): PatternInput {
public on(eventType: string, handler: (event: Event) => void): PatternInputWidget {
switch (eventType) {
case 'keydown':
case 'keyup':
$(this.inputBox.inputElement).on(eventType, handler);
break;
case PatternInput.OPTION_CHANGE:
case PatternInputWidget.OPTION_CHANGE:
this.onOptionChange = handler;
break;
}
......@@ -140,7 +140,7 @@ export class PatternInput {
this.inputBox.width = w;
}
private buildDomNode(): void {
private render(): void {
this.domNode = document.createElement('div');
this.domNode.style.width = this.width + 'px';
$(this.domNode).addClass('monaco-findInput');
......@@ -201,4 +201,4 @@ export class PatternInput {
)
}, true);
}
}
}
\ No newline at end of file
......@@ -49,7 +49,7 @@ import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
import {IKeybindingService, IKeybindingContextKey} from 'vs/platform/keybinding/common/keybindingService';
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
import {KeyCode, CommonKeybindings} from 'vs/base/common/keyCodes';
import { PatternInput } from 'vs/workbench/parts/search/browser/patternInputWidget';
import { PatternInputWidget } from 'vs/workbench/parts/search/browser/patternInputWidget';
import { SearchRenderer, SearchDataSource, SearchSorter, SearchController, SearchAccessibilityProvider, SearchFilter } from 'vs/workbench/parts/search/browser/searchResultsView';
import { RefreshAction, SelectOrRemoveAction, CollapseAllAction, ClearSearchResultsAction, ConfigureGlobalExclusionsAction } from 'vs/workbench/parts/search/browser/searchActions';
......@@ -74,10 +74,10 @@ export class SearchViewlet extends Viewlet {
private findInput: FindInput;
private size: Dimension;
private queryDetails: HTMLElement;
private inputPatternExclusions: PatternInput;
private inputPatternExclusions: PatternInputWidget;
private inputPatternGlobalExclusions: InputBox;
private inputPatternGlobalExclusionsContainer: Builder;
private inputPatternIncludes: PatternInput;
private inputPatternIncludes: PatternInputWidget;
private results: Builder;
constructor(
......@@ -211,7 +211,7 @@ export class SearchViewlet extends Viewlet {
let title = nls.localize('searchScope.includes', "files to include");
builder.element('h4', { text: title });
this.inputPatternIncludes = new PatternInput(builder.getContainer(), this.contextViewService, {
this.inputPatternIncludes = new PatternInputWidget(builder.getContainer(), this.contextViewService, {
ariaLabel: nls.localize('label.includes', 'Search Include Patterns')
});
......@@ -241,7 +241,7 @@ export class SearchViewlet extends Viewlet {
let title = nls.localize('searchScope.excludes', "files to exclude");
builder.element('h4', { text: title });
this.inputPatternExclusions = new PatternInput(builder.getContainer(), this.contextViewService, {
this.inputPatternExclusions = new PatternInputWidget(builder.getContainer(), this.contextViewService, {
ariaLabel: nls.localize('label.excludes', 'Search Exclude Patterns')
});
......@@ -910,6 +910,9 @@ export class SearchViewlet extends Viewlet {
this.tree.dispose();
}
this.inputPatternIncludes.dispose();
this.inputPatternExclusions.dispose();
this.disposeModel();
super.dispose();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册