1+ package com .xwintop .xJavaFxTool .controller .littleTools ;
2+
3+ import com .xwintop .xJavaFxTool .services .littleTools .FileSearchToolService ;
4+ import com .xwintop .xJavaFxTool .utils .JavaFxViewUtil ;
5+ import com .xwintop .xJavaFxTool .view .littleTools .FileSearchToolView ;
6+ import com .xwintop .xcore .util .javafx .FileChooserUtil ;
7+ import javafx .collections .FXCollections ;
8+ import javafx .collections .ObservableList ;
9+ import javafx .event .ActionEvent ;
10+ import javafx .fxml .FXML ;
11+ import lombok .Getter ;
12+ import lombok .Setter ;
13+ import lombok .extern .slf4j .Slf4j ;
14+
15+ import java .io .File ;
16+ import java .net .URL ;
17+ import java .util .Map ;
18+ import java .util .ResourceBundle ;
19+
20+ /**
21+ * @ClassName: FileSearchToolController
22+ * @Description: 文件搜索工具
23+ * @author: xufeng
24+ * @date: 2019/7/18 10:21
25+ */
26+
27+ @ Getter
28+ @ Setter
29+ @ Slf4j
30+ public class FileSearchToolController extends FileSearchToolView {
31+ private FileSearchToolService fileSearchToolService = new FileSearchToolService (this );
32+ private ObservableList <Map <String , String >> searchResultTableData = FXCollections .observableArrayList ();
33+
34+ @ Override
35+ public void initialize (URL location , ResourceBundle resources ) {
36+ initView ();
37+ initEvent ();
38+ initService ();
39+ }
40+
41+ private void initView () {
42+ JavaFxViewUtil .setTableColumnMapValueFactory (fileNameTableColumn , "fileName" , false );
43+ JavaFxViewUtil .setTableColumnMapValueFactory (absolutePathTableColumn , "absolutePath" , false );
44+ JavaFxViewUtil .setTableColumnMapValueFactory (fileSizeTableColumn , "fileSize" , false );
45+ JavaFxViewUtil .setTableColumnMapValueFactory (lastModifiedTableColumn , "lastModified" , false );
46+ searchResultTableVIew .setItems (searchResultTableData );
47+ }
48+
49+ private void initEvent () {
50+ FileChooserUtil .setOnDrag (searchDirectoryTextField , FileChooserUtil .FileType .FOLDER );
51+ }
52+
53+ private void initService () {
54+ }
55+
56+ public void searchContentAction () {
57+
58+ }
59+
60+ @ FXML
61+ private void refreshIndexAction (ActionEvent event ) {
62+ }
63+
64+ @ FXML
65+ private void searchDirectoryAction (ActionEvent event ) {
66+ File file = FileChooserUtil .chooseDirectory ();
67+ if (file != null ) {
68+ searchDirectoryTextField .setText (file .getPath ());
69+ }
70+ }
71+ }
0 commit comments