| 93 | |
| 94 | @singleton() |
| 95 | export class SearchService |
| 96 | extends Component<ISearchProps> |
| 97 | implements ISearchService |
| 98 | { |
| 99 | protected state: ISearchProps; |
| 100 | private builtinService: IBuiltinService; |
| 101 | constructor() { |
| 102 | super(); |
| 103 | this.state = container.resolve(SearchModel); |
| 104 | this.builtinService = container.resolve(BuiltinService); |
| 105 | } |
| 106 | |
| 107 | public setValidateInfo(info: string | ISearchProps['validationInfo']) { |
| 108 | this.setState({ |
| 109 | validationInfo: |
| 110 | typeof info === 'string' |
| 111 | ? { |
| 112 | type: 'info', |
| 113 | text: info, |
| 114 | } |
| 115 | : info, |
| 116 | }); |
| 117 | } |
| 118 | |
| 119 | public setSearchValue(value?: string) { |
| 120 | this.setState({ |
| 121 | value, |
| 122 | }); |
| 123 | } |
| 124 | |
| 125 | public setReplaceValue(value?: string) { |
| 126 | this.setState({ |
| 127 | replaceValue: value, |
| 128 | }); |
| 129 | } |
| 130 | |
| 131 | public setResult(value?: ITreeNodeItemProps[]) { |
| 132 | this.setState({ |
| 133 | result: value || [], |
| 134 | }); |
| 135 | } |
| 136 | |
| 137 | public toggleMode(status: boolean) { |
| 138 | this.setState({ |
| 139 | replaceMode: status, |
| 140 | }); |
| 141 | } |
| 142 | |
| 143 | public toggleCaseSensitive() { |
| 144 | const { isCaseSensitive } = this.state; |
| 145 | const { SEARCH_CASE_SENSITIVE_COMMAND_ID } = |
| 146 | this.builtinService.getConstants(); |
| 147 | if (SEARCH_CASE_SENSITIVE_COMMAND_ID) { |
| 148 | this.setState({ |
| 149 | isCaseSensitive: !isCaseSensitive, |
| 150 | }); |
| 151 | this.updateStatus( |
| 152 | SEARCH_CASE_SENSITIVE_COMMAND_ID, |
nothing calls this directly
no outgoing calls
no test coverage detected