33 * Licensed under the MIT License. See License.txt in the project root for license information.
44 *--------------------------------------------------------------------------------------------*/
55
6- import 'vs/css!./media/replFilter ' ;
6+ import 'vs/css!./media/treeFilter ' ;
77import * as DOM from 'vs/base/browser/dom' ;
88import { BaseActionViewItem } from 'vs/base/browser/ui/actionbar/actionViewItems' ;
99import { Delayer } from 'vs/base/common/async' ;
@@ -16,7 +16,8 @@ import { Event, Emitter } from 'vs/base/common/event';
1616import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent' ;
1717import { KeyCode } from 'vs/base/common/keyCodes' ;
1818import { ContextScopedHistoryInputBox } from 'vs/platform/browser/contextScopedHistoryWidget' ;
19- import { localize } from 'vs/nls' ;
19+ import { attachInputBoxStyler } from 'vs/platform/theme/common/styler' ;
20+ import { IThemeService } from 'vs/platform/theme/common/themeService' ;
2021
2122export interface IReplFiltersChangeEvent {
2223 filterText ?: boolean ;
@@ -29,7 +30,7 @@ export interface IReplFiltersOptions {
2930 layout : DOM . Dimension ;
3031}
3132
32- export class ReplFilterState extends Disposable {
33+ export class TreeFilterState extends Disposable {
3334
3435 private readonly _onDidChange : Emitter < IReplFiltersChangeEvent > = this . _register ( new Emitter < IReplFiltersChangeEvent > ( ) ) ;
3536 readonly onDidChange : Event < IReplFiltersChangeEvent > = this . _onDidChange . event ;
@@ -66,16 +67,18 @@ export class ReplFilterState extends Disposable {
6667 }
6768}
6869
69- export class ReplFilterActionViewItem extends BaseActionViewItem {
70+ export class TreeFilterPanelActionViewItem extends BaseActionViewItem {
7071
7172 private delayedFilterUpdate : Delayer < void > ;
7273 private container : HTMLElement | undefined ;
7374 private filterInputBox : HistoryInputBox | undefined ;
7475
7576 constructor (
7677 action : IAction ,
77- private filters : ReplFilterState ,
78+ private placeholder : string ,
79+ private filters : TreeFilterState ,
7880 @IInstantiationService private readonly instantiationService : IInstantiationService ,
81+ @IThemeService private readonly themeService : IThemeService ,
7982 @IContextViewService private readonly contextViewService : IContextViewService ) {
8083 super ( null , action ) ;
8184 this . delayedFilterUpdate = new Delayer < void > ( 200 ) ;
@@ -84,12 +87,14 @@ export class ReplFilterActionViewItem extends BaseActionViewItem {
8487
8588 render ( container : HTMLElement ) : void {
8689 this . container = container ;
87- DOM . addClass ( this . container , 'repl- panel-action-filter-container' ) ;
90+ DOM . addClass ( this . container , 'panel-action-tree -filter-container' ) ;
8891
8992 this . element = DOM . append ( this . container , DOM . $ ( '' ) ) ;
9093 this . element . className = this . class ;
9194 this . createInput ( this . element ) ;
9295 this . updateClass ( ) ;
96+
97+ this . adjustInputBox ( ) ;
9398 }
9499
95100 focus ( ) : void {
@@ -106,9 +111,10 @@ export class ReplFilterActionViewItem extends BaseActionViewItem {
106111
107112 private createInput ( container : HTMLElement ) : void {
108113 this . filterInputBox = this . _register ( this . instantiationService . createInstance ( ContextScopedHistoryInputBox , container , this . contextViewService , {
109- placeholder : localize ( 'workbench.debug.filter. placeholder' , "Filter. E.g.: text, !exclude" ) ,
114+ placeholder : this . placeholder ,
110115 history : this . filters . filterHistory
111116 } ) ) ;
117+ this . _register ( attachInputBoxStyler ( this . filterInputBox , this . themeService ) ) ;
112118 this . filterInputBox . value = this . filters . filterText ;
113119 this . _register ( this . filterInputBox . onDidChange ( ( ) => this . delayedFilterUpdate . trigger ( ( ) => this . onDidInputChange ( this . filterInputBox ! ) ) ) ) ;
114120 this . _register ( this . filters . onDidChange ( ( event : IReplFiltersChangeEvent ) => {
@@ -150,31 +156,34 @@ export class ReplFilterActionViewItem extends BaseActionViewItem {
150156 }
151157
152158 private onInputKeyDown ( event : StandardKeyboardEvent ) {
153- let handled = false ;
154159 if ( event . equals ( KeyCode . Escape ) ) {
155160 this . clearFilterText ( ) ;
156- handled = true ;
157- }
158- if ( handled ) {
159161 event . stopPropagation ( ) ;
160162 event . preventDefault ( ) ;
161163 }
162164 }
163165
166+ private adjustInputBox ( ) : void {
167+ if ( this . element && this . filterInputBox ) {
168+ this . filterInputBox . inputElement . style . paddingRight = DOM . hasClass ( this . element , 'small' ) ? '25px' : '150px' ;
169+ }
170+ }
171+
164172 protected updateClass ( ) : void {
165173 if ( this . element && this . container ) {
166174 this . element . className = this . class ;
167175 DOM . toggleClass ( this . container , 'grow' , DOM . hasClass ( this . element , 'grow' ) ) ;
176+ this . adjustInputBox ( ) ;
168177 }
169178 }
170179
171180 protected get class ( ) : string {
172181 if ( this . filters . layout . width > 800 ) {
173- return 'repl- panel-action-filter grow' ;
182+ return 'panel-action-tree -filter grow' ;
174183 } else if ( this . filters . layout . width < 600 ) {
175- return 'repl- panel-action-filter small' ;
184+ return 'panel-action-tree -filter small' ;
176185 } else {
177- return 'repl- panel-action-filter' ;
186+ return 'panel-action-tree -filter' ;
178187 }
179188 }
180189}
0 commit comments