├── .gitignore
├── .idea
├── codeStyleSettings.xml
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── description.html
├── encodings.xml
├── gradle.xml
├── inspectionProfiles
│ ├── Project_Default.xml
│ └── profiles_settings.xml
├── libraries
│ ├── commons_io_commons_io_2_5.xml
│ ├── org_controlsfx_controlsfx_8_40_12.xml
│ ├── org_hamcrest_hamcrest_all_1_3.xml
│ ├── org_jgrapht_jgrapht_core_1_0_0.xml
│ └── org_json_json_20160810.xml
├── misc.xml
├── modules.xml
├── uiDesigner.xml
├── vcs.xml
└── workspace.xml
├── DolphinExplorer.iml
├── README.md
├── _config.yml
├── lib
├── annotations-1.0.0.jar
├── commons-io-2.5-javadoc.jar
├── commons-io-2.5-sources.jar
├── commons-io-2.5.jar
├── controlsfx-8.40.12-javadoc.jar
├── controlsfx-8.40.12-sources.jar
├── controlsfx-8.40.12.jar
├── hamcrest-all-1.3-javadoc.jar
├── hamcrest-all-1.3-sources.jar
├── hamcrest-all-1.3.jar
├── jgrapht-core-1.0.0-javadoc.jar
├── jgrapht-core-1.0.0-sources.jar
├── jgrapht-core-1.0.0.jar
├── json-20160810-javadoc.jar
├── json-20160810-sources.jar
└── json-20160810.jar
├── out
└── production
│ └── DolphinExplorer
│ └── com
│ └── konv
│ └── dolphinexplorer
│ ├── DialogHelper.class
│ ├── FileHelper.class
│ ├── FileView.class
│ ├── ListView$1.class
│ ├── ListView$2.class
│ ├── ListView.class
│ ├── Main.class
│ ├── StringHelper.class
│ ├── SystemIconsHelper$AttachmentListCell.class
│ ├── SystemIconsHelper.class
│ ├── TextEditor.class
│ ├── WatchServiceHelper.class
│ └── dolphin.png
└── src
└── com
└── konv
└── dolphinexplorer
├── DialogHelper.java
├── FileHelper.java
├── FileView.java
├── ListView.java
├── Main.java
├── StringHelper.java
├── SystemIconsHelper.java
├── TextEditor.java
├── WatchServiceHelper.java
├── dolphin.png
└── test
└── ApplicationTest.java
/.gitignore:
--------------------------------------------------------------------------------
1 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
2 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
3 |
4 | # User-specific stuff:
5 | .idea/workspace.xml
6 | .idea/tasks.xml
7 |
8 | # Sensitive or high-churn files:
9 | .idea/dataSources/
10 | .idea/dataSources.ids
11 | .idea/dataSources.xml
12 | .idea/dataSources.local.xml
13 | .idea/sqlDataSources.xml
14 | .idea/dynamic.xml
15 | .idea/uiDesigner.xml
16 |
17 | # Gradle:
18 | .idea/gradle.xml
19 | .idea/libraries
20 |
21 | # Mongo Explorer plugin:
22 | .idea/mongoSettings.xml
23 |
24 | ## File-based project format:
25 | *.iws
26 |
27 | ## Plugin-specific files:
28 |
29 | # IntelliJ
30 | /out/
31 |
32 | # mpeltonen/sbt-idea plugin
33 | .idea_modules/
34 |
35 | # JIRA plugin
36 | atlassian-ide-plugin.xml
37 |
38 | # Crashlytics plugin (for Android Studio and IntelliJ)
39 | com_crashlytics_export_strings.xml
40 | crashlytics.properties
41 | crashlytics-build.properties
42 | fabric.properties
--------------------------------------------------------------------------------
/.idea/codeStyleSettings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/description.html:
--------------------------------------------------------------------------------
1 | Simple JavaFX 2.0 application that includes simple .fxml file with attached controller and Main class to quick start. Artifact to build JavaFX application is provided.
2 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/libraries/commons_io_commons_io_2_5.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/libraries/org_controlsfx_controlsfx_8_40_12.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/libraries/org_hamcrest_hamcrest_all_1_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/libraries/org_jgrapht_jgrapht_core_1_0_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/libraries/org_json_json_20160810.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/uiDesigner.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | -
6 |
7 |
8 | -
9 |
10 |
11 | -
12 |
13 |
14 | -
15 |
16 |
17 | -
18 |
19 |
20 |
21 |
22 |
23 | -
24 |
25 |
26 |
27 |
28 |
29 | -
30 |
31 |
32 |
33 |
34 |
35 | -
36 |
37 |
38 |
39 |
40 |
41 | -
42 |
43 |
44 |
45 |
46 | -
47 |
48 |
49 |
50 |
51 | -
52 |
53 |
54 |
55 |
56 | -
57 |
58 |
59 |
60 |
61 | -
62 |
63 |
64 |
65 |
66 | -
67 |
68 |
69 |
70 |
71 | -
72 |
73 |
74 | -
75 |
76 |
77 |
78 |
79 | -
80 |
81 |
82 |
83 |
84 | -
85 |
86 |
87 |
88 |
89 | -
90 |
91 |
92 |
93 |
94 | -
95 |
96 |
97 |
98 |
99 | -
100 |
101 |
102 | -
103 |
104 |
105 | -
106 |
107 |
108 | -
109 |
110 |
111 | -
112 |
113 |
114 |
115 |
116 | -
117 |
118 |
119 | -
120 |
121 |
122 |
123 |
124 |
125 |
126 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/workspace.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 | true
146 | DEFINITION_ORDER
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 | Declaration redundancyJava
170 |
171 |
172 | Encapsulation issuesJava
173 |
174 |
175 | HTML
176 |
177 |
178 | Java
179 |
180 |
181 |
182 |
183 | WeakerAccess
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 |
435 |
436 |
437 |
438 |
439 |
440 |
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 |
449 |
450 |
451 |
452 |
453 |
454 |
455 |
456 |
457 |
458 |
459 |
460 |
461 |
462 |
463 |
464 |
465 |
466 |
467 |
468 |
469 |
470 |
471 |
472 |
473 |
474 |
475 |
476 |
477 |
478 |
479 |
480 |
481 |
482 |
483 |
484 |
485 |
486 |
487 |
488 |
489 |
490 |
491 |
492 |
493 |
494 |
495 |
496 |
497 |
498 |
499 |
500 |
501 |
502 |
503 |
504 |
505 |
506 |
507 |
508 |
509 |
510 |
511 |
512 |
513 |
514 |
515 |
516 |
517 |
518 |
519 |
520 |
521 |
522 |
523 |
524 |
525 |
526 |
527 |
528 |
529 |
530 |
531 |
532 |
533 |
534 |
535 |
536 |
537 |
538 |
539 |
540 |
541 |
542 |
543 |
544 |
545 |
546 |
547 |
548 |
549 |
550 |
551 |
552 | 1359379246138
553 |
554 |
555 | 1359379246138
556 |
557 |
558 |
559 |
560 |
561 |
562 |
563 |
564 |
565 |
566 |
567 |
568 |
569 |
570 |
571 |
572 |
573 |
574 |
575 |
576 |
577 |
578 |
579 |
580 |
581 |
582 |
583 |
584 |
585 |
586 |
587 |
588 |
589 |
590 |
591 |
592 |
593 |
594 |
595 |
596 |
597 |
598 |
599 |
600 |
601 |
602 |
603 |
604 |
605 |
606 |
607 |
608 |
609 |
610 |
611 |
612 |
613 |
614 |
615 |
616 |
617 |
618 |
619 |
620 |
621 |
622 |
623 |
624 |
625 |
626 |
627 |
628 |
629 |
630 |
631 |
632 |
633 |
634 |
635 |
636 |
637 |
638 |
639 |
640 |
641 |
642 |
643 |
644 |
645 |
646 |
647 |
648 |
649 |
650 |
651 |
652 |
653 |
654 |
655 |
656 |
657 |
658 |
659 |
660 |
661 |
662 |
663 |
664 |
665 |
666 |
667 |
668 |
669 |
670 |
671 |
672 |
673 |
674 |
675 |
676 |
677 |
678 |
679 |
680 |
681 |
682 |
683 |
684 |
685 |
686 |
687 |
688 |
689 |
690 |
691 |
692 |
693 |
694 |
695 |
696 |
697 |
698 |
699 |
700 |
701 |
702 |
703 |
704 |
705 |
706 |
707 |
708 |
709 |
710 |
711 |
712 |
713 |
714 |
715 |
716 |
717 |
718 |
719 |
720 |
721 |
722 |
723 |
724 |
725 |
726 |
727 |
728 |
729 |
730 |
731 |
732 |
733 |
734 |
735 |
736 |
737 |
738 |
739 |
740 |
741 |
742 |
743 |
744 |
745 |
746 |
747 |
748 |
749 |
750 |
751 |
752 |
753 |
754 |
755 |
756 |
757 |
758 |
759 |
760 |
761 |
762 |
763 |
764 |
765 |
766 |
767 |
768 |
769 |
770 | JAVA
771 | com.konv.dolphinexplorer
772 |
773 | com.konv.dolphinexplorer.StringHelper
774 | com.konv.dolphinexplorer.SystemIconsHelper
775 | com.konv.dolphinexplorer.FileView
776 | com.konv.dolphinexplorer.Main
777 | com.konv.dolphinexplorer.DialogHelper
778 | com.konv.dolphinexplorer.ListView
779 | com.konv.dolphinexplorer.WatchServiceHelper
780 | com.konv.dolphinexplorer.FileHelper
781 | com.konv.dolphinexplorer.TextEditor
782 | com.konv.dolphinexplorer.test
783 |
784 |
785 |
786 |
787 |
788 |
789 |
790 |
791 |
792 |
793 |
794 |
795 |
796 |
797 |
798 |
799 |
800 |
801 |
802 |
803 |
804 |
805 |
806 |
807 |
808 |
809 |
810 | All
811 | private
812 |
813 |
814 |
815 |
816 |
817 |
818 |
819 |
820 |
821 |
822 |
823 |
824 |
825 |
826 |
827 |
828 |
829 |
830 |
831 |
832 |
833 |
834 |
835 |
836 |
837 |
838 |
839 |
840 |
841 |
842 |
843 |
844 |
845 |
846 |
847 |
848 |
849 |
850 |
851 |
852 |
853 |
854 |
855 |
856 |
857 |
858 |
859 |
860 |
861 |
862 |
863 |
864 |
865 |
866 |
867 |
868 |
869 |
870 |
871 |
872 |
873 |
874 |
875 |
876 |
877 |
878 |
879 |
880 |
881 |
882 |
883 |
884 |
885 |
886 |
887 |
888 |
889 |
890 |
891 |
892 |
893 |
894 |
895 |
896 |
897 |
898 |
899 |
900 |
901 |
902 |
903 |
904 |
905 |
906 |
907 |
908 |
909 |
910 |
911 |
912 |
913 |
914 |
915 |
916 |
917 |
918 |
919 |
920 |
921 |
922 |
923 |
924 |
925 |
926 |
927 |
928 |
929 |
930 |
931 |
932 |
933 |
934 |
935 |
936 |
937 |
938 |
939 |
940 |
941 |
942 |
943 |
944 |
945 |
946 |
947 |
948 |
949 |
950 |
951 |
952 |
953 |
954 |
955 |
956 |
957 |
958 |
959 |
960 |
961 |
962 |
963 |
964 |
965 |
966 |
967 |
968 |
969 |
970 |
971 |
972 |
973 |
974 |
975 |
976 |
977 |
978 |
979 |
980 |
981 |
982 |
983 |
984 |
985 |
986 |
987 |
988 |
989 |
990 |
991 |
992 |
993 |
994 |
995 |
996 |
997 |
998 |
999 |
1000 |
1001 |
1002 |
1003 |
1004 |
1005 |
1006 |
1007 |
1008 |
1009 |
1010 |
1011 |
1012 |
1013 |
1014 |
1015 |
1016 |
1017 |
1018 |
1019 |
1020 |
1021 |
1022 |
1023 |
1024 |
1025 |
1026 |
1027 |
1028 |
1029 |
1030 |
1031 |
1032 |
1033 |
1034 |
1035 |
1036 |
1037 |
1038 |
1039 |
1040 |
1041 |
1042 |
1043 |
1044 |
1045 |
1046 |
1047 |
1048 |
1049 |
1050 |
1051 |
1052 |
1053 |
1054 |
1055 |
1056 |
1057 |
1058 |
1059 |
1060 |
1061 |
1062 |
1063 |
1064 |
1065 |
1066 |
1067 |
1068 |
1069 |
1070 |
1071 |
1072 |
1073 |
1074 |
1075 |
1076 |
1077 |
1078 |
1079 |
1080 |
1081 |
1082 |
1083 |
1084 |
1085 |
1086 |
1087 |
1088 |
1089 |
1090 |
1091 |
1092 |
1093 |
1094 |
1095 |
1096 |
1097 |
1098 |
1099 |
1100 |
1101 |
1102 |
1103 |
1104 |
1105 |
1106 |
1107 |
1108 |
1109 |
1110 |
1111 |
1112 |
1113 |
1114 |
1115 |
1116 |
1117 |
1118 |
1119 |
1120 |
1121 |
1122 |
1123 |
1124 |
1125 |
1126 |
1127 |
1128 |
1129 |
1130 |
1131 |
1132 |
1133 |
1134 |
1135 |
1136 |
1137 |
1138 |
1139 |
1140 |
1141 |
1142 |
1143 |
1144 |
1145 |
1146 |
1147 |
1148 |
1149 | DolphinExplorer
1150 |
1151 |
1152 |
1153 |
1154 |
1155 |
1156 |
1157 |
1158 |
1159 |
1160 |
1161 | No facets are configured
1162 |
1163 |
1164 |
1165 |
1166 |
1167 |
1168 |
1169 |
1170 |
1171 |
1172 |
1173 | scala-sdk-2.12.0-RC2
1174 |
1175 |
1176 |
1177 |
1178 |
1179 |
1180 |
1181 |
1182 |
1183 |
1184 |
1185 | 1.8
1186 |
1187 |
1188 |
1189 |
1190 |
1191 |
1192 |
1193 |
1194 |
1195 |
1196 |
1197 | DolphinExplorer
1198 |
1199 |
1200 |
1201 |
1202 |
1203 |
1204 |
1205 |
1206 |
1207 |
1208 |
1209 | 1.8
1210 |
1211 |
1212 |
1213 |
1214 |
1215 |
1216 |
1217 |
1218 |
1219 |
1220 |
1221 | commons-io:commons-io:2.5
1222 |
1223 |
1224 |
1225 |
1226 |
1227 |
1228 |
1229 |
1230 |
1231 |
1232 |
1233 |
1234 |
1235 |
1236 |
1237 |
1238 |
1239 |
1240 |
1241 |
1242 |
1243 |
1244 |
--------------------------------------------------------------------------------
/DolphinExplorer.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # File Manager
2 |
3 | ## Overview
4 | File Manager supports all basic file operations.
5 | Main window contains two panes in order to copy and move selected items between them.
6 | Advanced operations are available via text fields above panes.
7 |
8 | ## Main window
9 | 
10 | Main window contains two panes with corresponding text fields.
11 | Every text field shows current path and can be used to enter advanced quick commands.
12 |
13 | ## File operations
14 | * Create new directory
15 |
16 | * Create new file
17 |
18 | * Rename selected item
19 |
20 | * Delete selected items
21 |
22 | * Copy selected items to directory on other pane
23 |
24 | * Move selected items to directory on other pane
25 |
26 | 
27 |
28 | ## Advanced operations
29 | Advanced commands are entered to text fields and are applied to corresponding pane.
30 | **_< command> ::= < keyword> < argument>_**
31 | **_< argument> ::= < regex> | < word to find>_**
32 | For example, command **_copy .\*mus.\*_** copies all files that contains _mus_.
33 |
34 | 
35 |
36 | ##### SELECT
37 |
38 | Select all elements that matches regex or contains entered word .
39 | After selection it is possible to perform other actions.
40 | ##### MOVE
41 | Apply _SELECT_ with _moving_.
42 |
43 | ##### COPY
44 | Apply _SELECT_ with _copying_.
45 |
46 | ##### DELETE
47 |
48 | Apply _SELECT_ with _deletion_.
49 |
50 | ##### OPEN
51 |
52 | Apply _SELECT_ with opening all selected items with associated programs.
53 |
54 | ## HTML editor
55 | To open HTML files with build-in editor just press *F3* with selected file.
56 |
57 | 
58 |
59 | ## Words count
60 | To count words in selected .txt file, just press button *Count words*. New txt file file counted words will
61 | appear in the same directory.
62 |
63 | 
64 |
65 | ## Observing directory changes
66 | Background thread is used to watch active directories changes. Java Path API is used to do so in effective
67 | way instead of just pulling directory for changes every time interval.
68 |
69 | ## Hotkeys
70 | F3 - open with HTML editor
71 | F5 - copy
72 | F6 - move
73 | Delete - delete
74 | CTRL + N - new file
75 | CTRL + SHIFT + N - new directory
76 | SHIFT + D - focus corresponding text field
77 |
78 | ###### © 2016, Vitaliy Kononenko, K-24
79 |
--------------------------------------------------------------------------------
/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-cayman
--------------------------------------------------------------------------------
/lib/annotations-1.0.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/konvio/javafx-file-manager/9a246d2864a504401302322bc5d6b786dac817cc/lib/annotations-1.0.0.jar
--------------------------------------------------------------------------------
/lib/commons-io-2.5-javadoc.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/konvio/javafx-file-manager/9a246d2864a504401302322bc5d6b786dac817cc/lib/commons-io-2.5-javadoc.jar
--------------------------------------------------------------------------------
/lib/commons-io-2.5-sources.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/konvio/javafx-file-manager/9a246d2864a504401302322bc5d6b786dac817cc/lib/commons-io-2.5-sources.jar
--------------------------------------------------------------------------------
/lib/commons-io-2.5.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/konvio/javafx-file-manager/9a246d2864a504401302322bc5d6b786dac817cc/lib/commons-io-2.5.jar
--------------------------------------------------------------------------------
/lib/controlsfx-8.40.12-javadoc.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/konvio/javafx-file-manager/9a246d2864a504401302322bc5d6b786dac817cc/lib/controlsfx-8.40.12-javadoc.jar
--------------------------------------------------------------------------------
/lib/controlsfx-8.40.12-sources.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/konvio/javafx-file-manager/9a246d2864a504401302322bc5d6b786dac817cc/lib/controlsfx-8.40.12-sources.jar
--------------------------------------------------------------------------------
/lib/controlsfx-8.40.12.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/konvio/javafx-file-manager/9a246d2864a504401302322bc5d6b786dac817cc/lib/controlsfx-8.40.12.jar
--------------------------------------------------------------------------------
/lib/hamcrest-all-1.3-javadoc.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/konvio/javafx-file-manager/9a246d2864a504401302322bc5d6b786dac817cc/lib/hamcrest-all-1.3-javadoc.jar
--------------------------------------------------------------------------------
/lib/hamcrest-all-1.3-sources.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/konvio/javafx-file-manager/9a246d2864a504401302322bc5d6b786dac817cc/lib/hamcrest-all-1.3-sources.jar
--------------------------------------------------------------------------------
/lib/hamcrest-all-1.3.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/konvio/javafx-file-manager/9a246d2864a504401302322bc5d6b786dac817cc/lib/hamcrest-all-1.3.jar
--------------------------------------------------------------------------------
/lib/jgrapht-core-1.0.0-javadoc.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/konvio/javafx-file-manager/9a246d2864a504401302322bc5d6b786dac817cc/lib/jgrapht-core-1.0.0-javadoc.jar
--------------------------------------------------------------------------------
/lib/jgrapht-core-1.0.0-sources.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/konvio/javafx-file-manager/9a246d2864a504401302322bc5d6b786dac817cc/lib/jgrapht-core-1.0.0-sources.jar
--------------------------------------------------------------------------------
/lib/jgrapht-core-1.0.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/konvio/javafx-file-manager/9a246d2864a504401302322bc5d6b786dac817cc/lib/jgrapht-core-1.0.0.jar
--------------------------------------------------------------------------------
/lib/json-20160810-javadoc.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/konvio/javafx-file-manager/9a246d2864a504401302322bc5d6b786dac817cc/lib/json-20160810-javadoc.jar
--------------------------------------------------------------------------------
/lib/json-20160810-sources.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/konvio/javafx-file-manager/9a246d2864a504401302322bc5d6b786dac817cc/lib/json-20160810-sources.jar
--------------------------------------------------------------------------------
/lib/json-20160810.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/konvio/javafx-file-manager/9a246d2864a504401302322bc5d6b786dac817cc/lib/json-20160810.jar
--------------------------------------------------------------------------------
/out/production/DolphinExplorer/com/konv/dolphinexplorer/DialogHelper.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/konvio/javafx-file-manager/9a246d2864a504401302322bc5d6b786dac817cc/out/production/DolphinExplorer/com/konv/dolphinexplorer/DialogHelper.class
--------------------------------------------------------------------------------
/out/production/DolphinExplorer/com/konv/dolphinexplorer/FileHelper.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/konvio/javafx-file-manager/9a246d2864a504401302322bc5d6b786dac817cc/out/production/DolphinExplorer/com/konv/dolphinexplorer/FileHelper.class
--------------------------------------------------------------------------------
/out/production/DolphinExplorer/com/konv/dolphinexplorer/FileView.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/konvio/javafx-file-manager/9a246d2864a504401302322bc5d6b786dac817cc/out/production/DolphinExplorer/com/konv/dolphinexplorer/FileView.class
--------------------------------------------------------------------------------
/out/production/DolphinExplorer/com/konv/dolphinexplorer/ListView$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/konvio/javafx-file-manager/9a246d2864a504401302322bc5d6b786dac817cc/out/production/DolphinExplorer/com/konv/dolphinexplorer/ListView$1.class
--------------------------------------------------------------------------------
/out/production/DolphinExplorer/com/konv/dolphinexplorer/ListView$2.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/konvio/javafx-file-manager/9a246d2864a504401302322bc5d6b786dac817cc/out/production/DolphinExplorer/com/konv/dolphinexplorer/ListView$2.class
--------------------------------------------------------------------------------
/out/production/DolphinExplorer/com/konv/dolphinexplorer/ListView.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/konvio/javafx-file-manager/9a246d2864a504401302322bc5d6b786dac817cc/out/production/DolphinExplorer/com/konv/dolphinexplorer/ListView.class
--------------------------------------------------------------------------------
/out/production/DolphinExplorer/com/konv/dolphinexplorer/Main.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/konvio/javafx-file-manager/9a246d2864a504401302322bc5d6b786dac817cc/out/production/DolphinExplorer/com/konv/dolphinexplorer/Main.class
--------------------------------------------------------------------------------
/out/production/DolphinExplorer/com/konv/dolphinexplorer/StringHelper.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/konvio/javafx-file-manager/9a246d2864a504401302322bc5d6b786dac817cc/out/production/DolphinExplorer/com/konv/dolphinexplorer/StringHelper.class
--------------------------------------------------------------------------------
/out/production/DolphinExplorer/com/konv/dolphinexplorer/SystemIconsHelper$AttachmentListCell.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/konvio/javafx-file-manager/9a246d2864a504401302322bc5d6b786dac817cc/out/production/DolphinExplorer/com/konv/dolphinexplorer/SystemIconsHelper$AttachmentListCell.class
--------------------------------------------------------------------------------
/out/production/DolphinExplorer/com/konv/dolphinexplorer/SystemIconsHelper.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/konvio/javafx-file-manager/9a246d2864a504401302322bc5d6b786dac817cc/out/production/DolphinExplorer/com/konv/dolphinexplorer/SystemIconsHelper.class
--------------------------------------------------------------------------------
/out/production/DolphinExplorer/com/konv/dolphinexplorer/TextEditor.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/konvio/javafx-file-manager/9a246d2864a504401302322bc5d6b786dac817cc/out/production/DolphinExplorer/com/konv/dolphinexplorer/TextEditor.class
--------------------------------------------------------------------------------
/out/production/DolphinExplorer/com/konv/dolphinexplorer/WatchServiceHelper.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/konvio/javafx-file-manager/9a246d2864a504401302322bc5d6b786dac817cc/out/production/DolphinExplorer/com/konv/dolphinexplorer/WatchServiceHelper.class
--------------------------------------------------------------------------------
/out/production/DolphinExplorer/com/konv/dolphinexplorer/dolphin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/konvio/javafx-file-manager/9a246d2864a504401302322bc5d6b786dac817cc/out/production/DolphinExplorer/com/konv/dolphinexplorer/dolphin.png
--------------------------------------------------------------------------------
/src/com/konv/dolphinexplorer/DialogHelper.java:
--------------------------------------------------------------------------------
1 | package com.konv.dolphinexplorer;
2 |
3 | import javafx.scene.control.Alert;
4 | import javafx.scene.control.ButtonType;
5 | import javafx.scene.control.TextArea;
6 | import javafx.scene.control.TextInputDialog;
7 | import javafx.scene.image.Image;
8 | import javafx.scene.layout.Priority;
9 | import javafx.scene.layout.VBox;
10 | import javafx.stage.Stage;
11 | import org.jetbrains.annotations.Nullable;
12 |
13 | import java.io.PrintWriter;
14 | import java.io.StringWriter;
15 | import java.util.Optional;
16 |
17 | import static javafx.scene.control.Alert.AlertType;
18 |
19 | public class DialogHelper {
20 |
21 | public static void showAlert(AlertType alertType, String title, String header, String content) {
22 | Alert alert = new Alert(alertType);
23 | alert.setTitle(title);
24 | alert.setHeaderText(header);
25 | alert.setContentText(content);
26 |
27 | Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
28 | stage.getIcons().add(new Image(Main.class.getResourceAsStream("dolphin.png")));
29 |
30 | alert.showAndWait();
31 | }
32 |
33 | public static void showExpandableAlert(AlertType alertType, String title, String header, String content,
34 | String expandableContent) {
35 | Alert alert = new Alert(alertType);
36 | alert.setTitle(title);
37 | alert.setHeaderText(header);
38 | alert.setContentText(content);
39 |
40 | TextArea textArea = new TextArea(expandableContent);
41 | textArea.setEditable(false);
42 | textArea.setWrapText(true);
43 | textArea.setMaxWidth(Double.MAX_VALUE);
44 | textArea.setMaxHeight(Double.MAX_VALUE);
45 |
46 | VBox.setVgrow(textArea, Priority.ALWAYS);
47 | alert.getDialogPane().setExpandableContent(new VBox(textArea));
48 | alert.getDialogPane().setExpanded(true);
49 |
50 | Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
51 | stage.getIcons().add(new Image(Main.class.getResourceAsStream("dolphin.png")));
52 |
53 | alert.showAndWait();
54 | }
55 |
56 | public static boolean showConfirmationDialog(String title, String header, String content) {
57 | Alert alert = new Alert(AlertType.CONFIRMATION);
58 | alert.setTitle(title);
59 | alert.setHeaderText(header);
60 | alert.setContentText(content);
61 |
62 | Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
63 | stage.getIcons().add(new Image(Main.class.getResourceAsStream("dolphin.png")));
64 |
65 | Optional result = alert.showAndWait();
66 | return result.get() == ButtonType.OK;
67 | }
68 |
69 | public static boolean showExpandableConfirmationDialog(String title, String header, String content,
70 | String expandableContent) {
71 | Alert alert = new Alert(AlertType.CONFIRMATION);
72 | alert.setTitle(title);
73 | alert.setHeaderText(header);
74 | alert.setContentText(content);
75 |
76 | TextArea textArea = new TextArea(expandableContent);
77 | textArea.setEditable(false);
78 | textArea.setWrapText(true);
79 | textArea.setMaxWidth(Double.MAX_VALUE);
80 | textArea.setMaxHeight(Double.MAX_VALUE);
81 |
82 | VBox.setVgrow(textArea, Priority.ALWAYS);
83 | alert.getDialogPane().setExpandableContent(new VBox(textArea));
84 | alert.getDialogPane().setExpanded(true);
85 |
86 | Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
87 | stage.getIcons().add(new Image(Main.class.getResourceAsStream("dolphin.png")));
88 |
89 | Optional result = alert.showAndWait();
90 | return result.get() == ButtonType.OK;
91 | }
92 |
93 | @Nullable
94 | public static String showTextInputDialog(String title, String header, String content, String hint) {
95 | TextInputDialog dialog = new TextInputDialog(hint);
96 | dialog.setTitle(title);
97 | dialog.setHeaderText(header);
98 | dialog.setContentText(content);
99 |
100 | Stage stage = (Stage) dialog.getDialogPane().getScene().getWindow();
101 | stage.getIcons().add(new Image(Main.class.getResourceAsStream("dolphin.png")));
102 |
103 | Optional result = dialog.showAndWait();
104 | return result.isPresent() ? result.get() : null;
105 | }
106 |
107 | public static void showException(Exception e) {
108 | StringWriter stringWriter = new StringWriter();
109 | PrintWriter printWriter = new PrintWriter(stringWriter);
110 | e.printStackTrace(printWriter);
111 | String exceptionText = printWriter.toString();
112 |
113 | showExpandableAlert(AlertType.ERROR, "Dolphin Explorer", "Something went wrong", e.toString(), exceptionText);
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/src/com/konv/dolphinexplorer/FileHelper.java:
--------------------------------------------------------------------------------
1 | package com.konv.dolphinexplorer;
2 |
3 | import javafx.scene.control.Alert;
4 | import org.apache.commons.io.FileUtils;
5 |
6 | import java.io.File;
7 | import java.io.IOException;
8 | import java.nio.file.FileAlreadyExistsException;
9 | import java.nio.file.Files;
10 | import java.nio.file.Path;
11 | import java.util.ArrayList;
12 | import java.util.List;
13 |
14 | public class FileHelper {
15 |
16 | public static void copy(List source, Path target) {
17 | List uncopiable = new ArrayList<>();
18 | for (Path path : source) {
19 | try {
20 | File sourceFile = path.toFile();
21 | if (sourceFile.isDirectory()) {
22 | FileUtils.copyDirectoryToDirectory(sourceFile, target.toFile());
23 | } else {
24 | FileUtils.copyFileToDirectory(sourceFile, target.toFile());
25 | }
26 | } catch (Exception e) {
27 | uncopiable.add(path);
28 | }
29 | }
30 | if (uncopiable.size() > 0) {
31 | String sourceDirectory = uncopiable.get(0).getParent().toString();
32 | String content = "";
33 | for (Path path : uncopiable) {
34 | content += path.toString() + System.lineSeparator();
35 | }
36 | String message = "Some files were not copied properly";
37 | DialogHelper.showAlert(Alert.AlertType.INFORMATION, sourceDirectory, message, content);
38 | }
39 | }
40 |
41 | public static void move(List source, Path targetDirectory) {
42 | List unmovable = new ArrayList<>();
43 | for (Path path : source) {
44 | try {
45 | FileUtils.moveToDirectory(path.toFile(), targetDirectory.toFile(), false);
46 | } catch (Exception e) {
47 | unmovable.add(path);
48 | }
49 | }
50 | if (unmovable.size() > 0) {
51 | String sourceDirectory = unmovable.get(0).getParent().toString();
52 | String content = "";
53 | for (Path path : unmovable) {
54 | content += path.toString() + System.lineSeparator();
55 | }
56 | String message = "Some files were not moved properly";
57 | DialogHelper.showAlert(Alert.AlertType.INFORMATION, sourceDirectory, message, content);
58 | }
59 | }
60 |
61 | public static void delete(List source) {
62 | String sourceDirectory = source.get(0).getParent().toString();
63 |
64 | String filesToDelete = "";
65 | for (Path path : source) filesToDelete += path.toString() + System.lineSeparator();
66 | boolean isConfirmed = DialogHelper.showExpandableConfirmationDialog(sourceDirectory, "Delete",
67 | "Do you really want to delete selected files?", filesToDelete);
68 |
69 | if (isConfirmed) {
70 | List undeleted = new ArrayList<>();
71 | for (Path path : source) {
72 | try {
73 | if (path.toFile().isDirectory()) {
74 | FileUtils.deleteDirectory(path.toFile());
75 | } else {
76 | FileUtils.forceDelete(path.toFile());
77 | }
78 | } catch (Exception e) {
79 | undeleted.add(path);
80 | }
81 | }
82 | if (undeleted.size() > 0) {
83 | String content = "";
84 | for (Path path : undeleted) content += path.toString() + System.lineSeparator();
85 | String message = "Some files were not deleted";
86 | DialogHelper.showAlert(Alert.AlertType.INFORMATION, sourceDirectory, message, content);
87 | }
88 | }
89 | }
90 |
91 | public static void createDirectory(Path parent) {
92 | String title = parent.toString();
93 | String name = DialogHelper.showTextInputDialog(title, null, "New Directory", "My Directory");
94 | if (name != null) {
95 | Path path = parent.resolve(name);
96 | try {
97 | Files.createDirectory(path);
98 | } catch (FileAlreadyExistsException e) {
99 | DialogHelper.showAlert(Alert.AlertType.INFORMATION, title, "Directory already exists", path.toString());
100 | } catch (Exception e) {
101 | DialogHelper.showAlert(Alert.AlertType.INFORMATION, title, "Directory was not created", path.toString());
102 | }
103 | }
104 | }
105 |
106 | public static void createFile(Path parent) {
107 | String title = parent.toString();
108 | String name = DialogHelper.showTextInputDialog(title, null, "New File", "Text File.txt");
109 | if (name != null) {
110 | Path path = parent.resolve(name);
111 | try {
112 | Files.createFile(path);
113 | } catch (FileAlreadyExistsException e) {
114 | DialogHelper.showAlert(Alert.AlertType.INFORMATION, title, "File already exists", path.toString());
115 | } catch (Exception e) {
116 | DialogHelper.showAlert(Alert.AlertType.ERROR, title, "File was not created", path.toString());
117 | }
118 | }
119 | }
120 |
121 | public static void rename(Path source) {
122 | String title = "Rename";
123 | String name = DialogHelper.showTextInputDialog(title, null, "Enter New Name", source.getFileName().toString());
124 | if (name != null) {
125 | Path target = source.getParent().resolve(name);
126 | try {
127 | FileUtils.moveToDirectory(source.toFile(), target.toFile(), true);
128 | } catch (Exception e) {
129 | DialogHelper.showAlert(Alert.AlertType.INFORMATION, source.getParent().toString(), "File was not renamed",
130 | source.toString());
131 | }
132 | }
133 | }
134 | }
135 |
--------------------------------------------------------------------------------
/src/com/konv/dolphinexplorer/FileView.java:
--------------------------------------------------------------------------------
1 | package com.konv.dolphinexplorer;
2 |
3 | import javafx.scene.control.TextField;
4 | import javafx.scene.layout.HBox;
5 | import javafx.scene.layout.Priority;
6 | import javafx.scene.layout.VBox;
7 | import org.jetbrains.annotations.Nullable;
8 |
9 | import java.awt.*;
10 | import java.io.File;
11 | import java.io.IOException;
12 | import java.io.PrintWriter;
13 | import java.nio.charset.StandardCharsets;
14 | import java.nio.file.Files;
15 | import java.nio.file.Path;
16 | import java.util.Arrays;
17 | import java.util.List;
18 | import java.util.Map;
19 | import java.util.TreeMap;
20 | import java.util.function.Function;
21 | import java.util.stream.Collectors;
22 |
23 | public class FileView extends HBox {
24 |
25 | private static final String ACTION_SELECT = "select";
26 | private static final String ACTION_COPY = "copy";
27 | private static final String ACTION_MOVE = "move";
28 | private static final String ACTION_DELETE = "delete";
29 | private static final String ACTION_OPEN = "open";
30 |
31 | private ListView mLeftPane;
32 | private ListView mRightPane;
33 |
34 | private TextEditor mTextEditor;
35 |
36 | public FileView() {
37 | File[] roots = File.listRoots();
38 | String leftPanePath = roots[0].getPath();
39 | String rightPanePath = roots.length > 1 ? roots[1].getPath() : leftPanePath;
40 |
41 | mLeftPane = new ListView(leftPanePath);
42 | mRightPane = new ListView(rightPanePath);
43 | mTextEditor = new TextEditor();
44 |
45 | mLeftPane.getTextField().setOnAction(e -> onTextEntered(mLeftPane.getTextField()));
46 | mRightPane.getTextField().setOnAction(e -> onTextEntered(mRightPane.getTextField()));
47 |
48 | VBox leftView = new VBox(mLeftPane.getTextField(), mLeftPane);
49 | VBox rightView = new VBox(mRightPane.getTextField(), mRightPane);
50 | mLeftPane.setFocusTraversable(true);
51 |
52 | VBox.setVgrow(mLeftPane, Priority.ALWAYS);
53 | VBox.setVgrow(mRightPane, Priority.ALWAYS);
54 | HBox.setHgrow(leftView, Priority.ALWAYS);
55 | HBox.setHgrow(rightView, Priority.ALWAYS);
56 |
57 | getChildren().addAll(leftView, rightView);
58 | }
59 |
60 | public void copy() {
61 | if (mLeftPane.isFocused()) {
62 | List source = mLeftPane.getSelection();
63 | Path target = mRightPane.getDirectory();
64 | FileHelper.copy(source, target);
65 | } else if (mRightPane.isFocused()) {
66 | List source = mRightPane.getSelection();
67 | Path target = mLeftPane.getDirectory();
68 | FileHelper.copy(source, target);
69 | }
70 | }
71 |
72 | public void move() {
73 | if (mLeftPane.isFocused()) {
74 | List source = mLeftPane.getSelection();
75 | Path target = mRightPane.getDirectory();
76 | FileHelper.move(source, target);
77 | } else if (mRightPane.isFocused()) {
78 | List source = mRightPane.getSelection();
79 | Path target = mLeftPane.getDirectory();
80 | FileHelper.move(source, target);
81 | }
82 | }
83 |
84 | public void delete() {
85 | ListView focusedPane = getFocusedPane();
86 | if (focusedPane != null) FileHelper.delete(focusedPane.getSelection());
87 | }
88 |
89 | public void rename() {
90 | ListView focusedPane = getFocusedPane();
91 | if (focusedPane != null) {
92 | List selection = focusedPane.getSelection();
93 | if (selection.size() == 1) FileHelper.rename(selection.get(0));
94 | }
95 | }
96 |
97 | public void createDirectory() {
98 | ListView focusedPane = getFocusedPane();
99 | if (focusedPane != null) FileHelper.createDirectory(focusedPane.getDirectory());
100 | }
101 |
102 | public void createFile() {
103 | ListView focusedPane = getFocusedPane();
104 | if (focusedPane != null) FileHelper.createFile(focusedPane.getDirectory());
105 | }
106 |
107 | public void focusTextField() {
108 | ListView focusedPane = getFocusedPane();
109 | if (focusedPane != null) focusedPane.getTextField().requestFocus();
110 | }
111 |
112 | public void openHtml() {
113 | ListView focusedPane = getFocusedPane();
114 | if (focusedPane == null) return;
115 | List selection = focusedPane.getSelection();
116 | if (selection.size() != 1) return;
117 | File file = selection.get(0).toFile();
118 | mTextEditor.open(file);
119 | }
120 |
121 | public void countWords() {
122 | Path path = getSelectedPath();
123 | if (path != null && path.toString().endsWith(".txt")) {
124 | Path resultPath = path.getParent().resolve("[Word Count] " + path.getFileName());
125 | try (PrintWriter printWriter = new PrintWriter(resultPath.toFile())) {
126 | Arrays.stream(new String(Files.readAllBytes(path), StandardCharsets.UTF_8).toLowerCase().split("\\W+"))
127 | .collect(Collectors.groupingBy(Function.identity(), TreeMap::new, Collectors.counting()))
128 | .entrySet().stream().sorted(Map.Entry.comparingByValue().reversed())
129 | .forEach(printWriter::println);
130 | Desktop.getDesktop().open(resultPath.toFile());
131 | } catch (IOException e) {
132 | DialogHelper.showException(e);
133 | }
134 | }
135 | }
136 |
137 | private ListView getFocusedPane() {
138 | if (mLeftPane.isFocused() || mLeftPane.getTextField().isFocused()) {
139 | return mLeftPane;
140 | } else if (mRightPane.isFocused() || mRightPane.getTextField().isFocused()) {
141 | return mRightPane;
142 | } else {
143 | return null;
144 | }
145 | }
146 |
147 | private ListView getFocusedPane(TextField textField) {
148 | if (textField == mLeftPane.getTextField()) {
149 | return mLeftPane;
150 | } else {
151 | return mRightPane;
152 | }
153 | }
154 |
155 | @Nullable
156 | private Path getSelectedPath() {
157 | ListView focusedPane = getFocusedPane();
158 | if (focusedPane == null) return null;
159 | List selection = focusedPane.getSelection();
160 | if (selection.size() != 1) return null;
161 | return selection.get(0);
162 | }
163 |
164 | private void onTextEntered(TextField textField) {
165 | ListView focusedPane = getFocusedPane(textField);
166 | String command = textField.getText().trim();
167 | File file = new File(command);
168 | if (file.exists()) {
169 | focusedPane.openFile(file);
170 | focusedPane.requestFocus();
171 | } else if (command.startsWith(ACTION_SELECT)) {
172 | String regex = command.substring(ACTION_SELECT.length()).trim();
173 | focusedPane.select(regex);
174 | focusedPane.requestFocus();
175 | } else if (command.startsWith(ACTION_COPY)) {
176 | String regex = command.substring(ACTION_COPY.length()).trim();
177 | focusedPane.select(regex);
178 | focusedPane.requestFocus();
179 | copy();
180 | } else if (command.startsWith(ACTION_MOVE)) {
181 | String regex = command.substring(ACTION_MOVE.length()).trim();
182 | focusedPane.select(regex);
183 | focusedPane.requestFocus();
184 | move();
185 | } else if (command.startsWith(ACTION_DELETE)) {
186 | String regex = command.substring(ACTION_DELETE.length()).trim();
187 | focusedPane.select(regex);
188 | focusedPane.requestFocus();
189 | delete();
190 | } else if (command.startsWith(ACTION_OPEN)) {
191 | String regex = command.substring(ACTION_OPEN.length()).trim();
192 | focusedPane.select(regex);
193 | focusedPane.requestFocus();
194 | for (Path path : focusedPane.getSelection()) {
195 | try {
196 | Desktop.getDesktop().open(path.toFile());
197 | } catch (Exception e) {
198 | DialogHelper.showException(e);
199 | }
200 | }
201 | }
202 | textField.setText(focusedPane.getDirectory().toString());
203 | }
204 | }
205 |
--------------------------------------------------------------------------------
/src/com/konv/dolphinexplorer/ListView.java:
--------------------------------------------------------------------------------
1 | package com.konv.dolphinexplorer;
2 |
3 | import javafx.collections.FXCollections;
4 | import javafx.collections.ObservableList;
5 | import javafx.scene.control.ListCell;
6 | import javafx.scene.control.SelectionMode;
7 | import javafx.scene.control.TextField;
8 | import javafx.scene.input.MouseButton;
9 | import javafx.util.Callback;
10 |
11 | import java.awt.*;
12 | import java.io.File;
13 | import java.nio.file.Path;
14 | import java.util.ArrayList;
15 | import java.util.Arrays;
16 | import java.util.List;
17 |
18 | public class ListView extends javafx.scene.control.ListView {
19 |
20 | private File mDirectory;
21 | private TextField mTextField;
22 | private ObservableList mChildrenList;
23 |
24 | private WatchServiceHelper mWatchServiceHelper;
25 |
26 | public ListView(String path) {
27 | super();
28 | getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
29 | mDirectory = new File(path);
30 |
31 | mChildrenList = FXCollections.observableArrayList();
32 | setItems(mChildrenList);
33 |
34 | mTextField = new TextField();
35 | mTextField.setStyle("-fx-font-size: 10px;");
36 |
37 | setOnKeyPressed(key -> {
38 | switch (key.getCode()) {
39 | case ENTER:
40 | if (isFocused()) navigate(getSelectionModel().getSelectedItem());
41 | break;
42 | case BACK_SPACE:
43 | back();
44 | break;
45 | }
46 | });
47 |
48 | setOnMouseClicked(m -> {
49 | if (m.getButton().equals(MouseButton.PRIMARY) && m.getClickCount() == 2)
50 | navigate(getSelectionModel().getSelectedItem());
51 | });
52 | setCellFactory(new Callback, ListCell>() {
53 | @Override
54 | public ListCell call(javafx.scene.control.ListView list) {
55 | return new SystemIconsHelper.AttachmentListCell(ListView.this);
56 | }
57 | });
58 | mWatchServiceHelper = new WatchServiceHelper(this);
59 | refresh();
60 | }
61 |
62 | public void refresh() {
63 | showList(getCurrentFilesList());
64 | mTextField.setText(mDirectory.getAbsolutePath());
65 | mWatchServiceHelper.changeObservableDirectory(mDirectory.toPath());
66 | }
67 |
68 | public TextField getTextField() {
69 | return mTextField;
70 | }
71 |
72 | public List getSelection() {
73 | List selection = new ArrayList<>();
74 | for (String item : getSelectionModel().getSelectedItems()) {
75 | selection.add(mDirectory.toPath().resolve(item));
76 | }
77 | return selection;
78 | }
79 |
80 | public Path getDirectory() {
81 | return mDirectory.toPath();
82 | }
83 |
84 | public void select(String regex) {
85 | if (regex.startsWith("*")) regex = "." + regex;
86 | getSelectionModel().clearSelection();
87 | for (int i = 0; i < mChildrenList.size(); ++i) {
88 | String item = mChildrenList.get(i);
89 | if (item.matches(regex) || StringHelper.containsWord(item, regex)) {
90 | getSelectionModel().select(i);
91 | }
92 | }
93 | }
94 |
95 | private String[] getCurrentFilesList() {
96 | File[] listFiles = mDirectory.listFiles(file -> !file.isHidden());
97 |
98 | if (listFiles == null) {
99 | listFiles = new File[0];
100 | }
101 |
102 | Arrays.sort(listFiles, (f1, f2) -> {
103 | if ((f1.isDirectory() && f2.isDirectory()) || (f1.isFile() && f2.isFile())) {
104 | return f1.compareTo(f2);
105 | }
106 | return f1.isDirectory() ? -1 : 1;
107 | });
108 |
109 | String[] list = new String[listFiles.length];
110 | for (int i = 0; i < list.length; ++i) {
111 | list[i] = listFiles[i].getName();
112 | }
113 |
114 | return list;
115 | }
116 |
117 | private void showList(String[] list) {
118 | if (list != null) {
119 | mChildrenList.clear();
120 | mChildrenList.addAll(list);
121 | } else {
122 | mChildrenList.clear();
123 | }
124 | }
125 |
126 | public void openFile(File file) {
127 | if (!file.exists()) {
128 | refresh();
129 | return;
130 | }
131 | if (file.isDirectory()) {
132 | mDirectory = file;
133 | refresh();
134 | } else if (file.isFile()) {
135 | try {
136 | Desktop.getDesktop().open(file);
137 | } catch (Exception e) {
138 | DialogHelper.showException(e);
139 | }
140 | }
141 | }
142 |
143 | private void navigate(String name) {
144 | String selectedPath = mDirectory.getAbsolutePath() + File.separator + name;
145 | File selectedFile = new File(selectedPath);
146 | if (selectedFile.isDirectory()) {
147 | mDirectory = selectedFile;
148 | refresh();
149 | } else {
150 | try {
151 | Desktop.getDesktop().open(selectedFile);
152 | } catch (Exception e) {
153 | DialogHelper.showException(e);
154 | }
155 | }
156 | }
157 |
158 | private void back() {
159 | File parent = mDirectory.getParentFile();
160 | if (parent != null) {
161 | mDirectory = parent;
162 | if (mDirectory.exists()) {
163 | refresh();
164 | } else {
165 | back();
166 | }
167 | }
168 | }
169 | }
170 |
--------------------------------------------------------------------------------
/src/com/konv/dolphinexplorer/Main.java:
--------------------------------------------------------------------------------
1 | package com.konv.dolphinexplorer;
2 |
3 | import javafx.application.Application;
4 | import javafx.scene.Scene;
5 | import javafx.scene.control.*;
6 | import javafx.scene.image.Image;
7 | import javafx.scene.input.KeyCode;
8 | import javafx.scene.input.KeyCodeCombination;
9 | import javafx.scene.input.KeyCombination;
10 | import javafx.scene.input.KeyEvent;
11 | import javafx.scene.layout.Priority;
12 | import javafx.scene.layout.VBox;
13 | import javafx.stage.Stage;
14 |
15 | public class Main extends Application {
16 |
17 | private static final KeyCombination SHORTCUT_COPY = new KeyCodeCombination(KeyCode.F5);
18 | private static final KeyCombination SHORTCUT_MOVE = new KeyCodeCombination(KeyCode.F6);
19 | private static final KeyCombination SHORTCUT_DELETE = new KeyCodeCombination(KeyCode.DELETE);
20 | private static final KeyCombination SHORTCUT_NEW_FILE = new KeyCodeCombination(KeyCode.N,
21 | KeyCombination.SHORTCUT_DOWN);
22 | private static final KeyCombination SHORTCUT_NEW_DIRECTORY = new KeyCodeCombination(KeyCode.N,
23 | KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN);
24 | private static final KeyCombination SHORTCUT_RENAME = new KeyCodeCombination(KeyCode.F6, KeyCombination.SHIFT_DOWN);
25 | private static final KeyCombination SHORTCUT_FOCUS_TEXT_FIELD = new KeyCodeCombination(KeyCode.D, KeyCombination.SHIFT_DOWN);
26 | private static final KeyCombination SHORTCUT_HTML_EDITOR = new KeyCodeCombination(KeyCode.F3);
27 |
28 | private FileView mFileView;
29 |
30 | @Override
31 | public void start(Stage primaryStage) throws Exception {
32 | VBox root = new VBox();
33 |
34 | mFileView = new FileView();
35 |
36 | VBox.setVgrow(mFileView, Priority.ALWAYS);
37 |
38 | root.getChildren().addAll(getMenuBar(), mFileView, getToolBar());
39 |
40 | Scene scene = new Scene(root, 840, 600);
41 |
42 | scene.addEventFilter(KeyEvent.KEY_RELEASED, e -> {
43 | if (SHORTCUT_DELETE.match(e)) {
44 | mFileView.delete();
45 | } else if (SHORTCUT_NEW_FILE.match(e)) {
46 | mFileView.createFile();
47 | } else if (SHORTCUT_NEW_DIRECTORY.match(e)) {
48 | mFileView.createDirectory();
49 | } else if (SHORTCUT_RENAME.match(e)) {
50 | mFileView.rename();
51 | } else if (SHORTCUT_COPY.match(e)) {
52 | mFileView.copy();
53 | } else if (SHORTCUT_MOVE.match(e)) {
54 | mFileView.move();
55 | } else if (SHORTCUT_FOCUS_TEXT_FIELD.match(e)) {
56 | mFileView.focusTextField();
57 | } else if (SHORTCUT_HTML_EDITOR.match(e)) {
58 | mFileView.openHtml();
59 | }
60 | });
61 |
62 | primaryStage.setTitle("Dolphin Explorer");
63 | primaryStage.setScene(scene);
64 | primaryStage.getIcons().add(new Image(Main.class.getResourceAsStream("dolphin.png")));
65 | primaryStage.show();
66 | }
67 |
68 | public static void main(String[] args) {
69 | launch(args);
70 | }
71 |
72 | private MenuBar getMenuBar() {
73 | Menu fileMenu = new Menu("File");
74 |
75 | // Create file menu
76 | MenuItem newFile = new MenuItem("New File");
77 | newFile.setOnAction(e -> mFileView.createFile());
78 | newFile.setAccelerator(SHORTCUT_NEW_FILE);
79 |
80 | MenuItem newFolder = new MenuItem("New Folder ");
81 | newFolder.setOnAction(e -> mFileView.createDirectory());
82 | newFolder.setAccelerator(SHORTCUT_NEW_DIRECTORY);
83 |
84 | MenuItem renameItem = new MenuItem("Rename");
85 | renameItem.setOnAction(e -> mFileView.rename());
86 | renameItem.setAccelerator(SHORTCUT_RENAME);
87 |
88 | MenuItem deleteItem = new MenuItem("Delete");
89 | deleteItem.setOnAction(e -> mFileView.delete());
90 | deleteItem.setAccelerator(SHORTCUT_DELETE);
91 |
92 | fileMenu.getItems().addAll(newFile, newFolder, renameItem, deleteItem);
93 |
94 | //Create helpMenu
95 | Menu helpMenu = new Menu("Help");
96 | MenuItem aboutMenuItem = new MenuItem("About");
97 | aboutMenuItem.setOnAction(e -> DialogHelper.showAlert(Alert.AlertType.INFORMATION, "About", null,
98 | "Dolphin Explorer\n\n" + "Copyright © 2016 by Vitaliy Kononenko\nK-24")
99 | );
100 | helpMenu.getItems().addAll(aboutMenuItem);
101 |
102 | return new MenuBar(fileMenu, helpMenu);
103 | }
104 |
105 | private ToolBar getToolBar() {
106 | Label labelOpenAsText = new Label("F3 Edit HTML");
107 | labelOpenAsText.setOnMouseClicked(e -> mFileView.openHtml());
108 |
109 | Label labelCountWords = new Label("Count words");
110 | labelCountWords.setOnMouseClicked(e -> mFileView.countWords());
111 |
112 | Label labelCopy = new Label("F5 Copy");
113 | labelCopy.setOnMouseClicked(e -> mFileView.copy());
114 |
115 | Label labelMove = new Label("F6 Move");
116 | labelMove.setOnMouseClicked(e -> mFileView.move());
117 |
118 | return new ToolBar(labelCountWords, new Separator(), labelOpenAsText, new Separator(), labelCopy, new Separator(), labelMove);
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/src/com/konv/dolphinexplorer/StringHelper.java:
--------------------------------------------------------------------------------
1 | package com.konv.dolphinexplorer;
2 |
3 | public class StringHelper {
4 |
5 | public static boolean containsWord(String text, String word) {
6 | String[] words = getWords(text);
7 | word = word.toLowerCase();
8 | for (String item : words) {
9 | if (item.equals(word)) return true;
10 | }
11 | return false;
12 | }
13 |
14 | public static String[] getWords(String text) {
15 | return text.toLowerCase().split("\\W+");
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/com/konv/dolphinexplorer/SystemIconsHelper.java:
--------------------------------------------------------------------------------
1 | package com.konv.dolphinexplorer;
2 |
3 | import javafx.embed.swing.SwingFXUtils;
4 | import javafx.scene.control.ListCell;
5 | import javafx.scene.image.Image;
6 | import javafx.scene.image.ImageView;
7 |
8 | import javax.swing.filechooser.FileSystemView;
9 | import java.awt.image.BufferedImage;
10 | import java.io.File;
11 | import java.io.IOException;
12 | import java.util.HashMap;
13 |
14 | public class SystemIconsHelper {
15 |
16 | public static class AttachmentListCell extends ListCell {
17 | private ListView mListView;
18 | public AttachmentListCell(ListView listView) {
19 | mListView = listView;
20 | }
21 | @Override
22 | public void updateItem(String item, boolean empty) {
23 | super.updateItem(item, empty);
24 | if (empty) {
25 | setGraphic(null);
26 | setText(null);
27 | } else {
28 | Image fxImage = getFileIcon(mListView.getDirectory().resolve(item).toString());
29 | ImageView imageView = new ImageView(fxImage);
30 | setGraphic(imageView);
31 | setText(item);
32 | }
33 | }
34 | }
35 |
36 | static HashMap mapOfFileExtToSmallIcon = new HashMap();
37 |
38 | private static String getFileExt(String fname) {
39 | String ext = ".";
40 | int p = fname.lastIndexOf('.');
41 | if (p >= 0) {
42 | ext = fname.substring(p);
43 | }
44 | return ext.toLowerCase();
45 | }
46 |
47 | private static javax.swing.Icon getJSwingIconFromFileSystem(File file) {
48 |
49 | FileSystemView view = FileSystemView.getFileSystemView();
50 | javax.swing.Icon icon = view.getSystemIcon(file);
51 |
52 | return icon;
53 | }
54 |
55 | private static Image getFileIcon(String fname) {
56 | final String ext = getFileExt(fname);
57 |
58 | Image fileIcon = mapOfFileExtToSmallIcon.get(ext);
59 | if (fileIcon == null) {
60 |
61 | javax.swing.Icon jswingIcon = null;
62 |
63 | File file = new File(fname);
64 | if (file.exists()) {
65 | jswingIcon = getJSwingIconFromFileSystem(file);
66 | } else {
67 | File tempFile = null;
68 | try {
69 | tempFile = File.createTempFile("icon", ext);
70 | jswingIcon = getJSwingIconFromFileSystem(tempFile);
71 | } catch (IOException ignored) {
72 | // Cannot create temporary file.
73 | } finally {
74 | if (tempFile != null) tempFile.delete();
75 | }
76 | }
77 |
78 | if (jswingIcon != null) {
79 | fileIcon = jswingIconToImage(jswingIcon);
80 | mapOfFileExtToSmallIcon.put(ext, fileIcon);
81 | }
82 | }
83 |
84 | return fileIcon;
85 | }
86 |
87 | private static Image jswingIconToImage(javax.swing.Icon jswingIcon) {
88 | BufferedImage bufferedImage = new BufferedImage(jswingIcon.getIconWidth(), jswingIcon.getIconHeight(),
89 | BufferedImage.TYPE_INT_ARGB);
90 | jswingIcon.paintIcon(null, bufferedImage.getGraphics(), 0, 0);
91 | return SwingFXUtils.toFXImage(bufferedImage, null);
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/src/com/konv/dolphinexplorer/TextEditor.java:
--------------------------------------------------------------------------------
1 | package com.konv.dolphinexplorer;
2 |
3 | import javafx.scene.Scene;
4 | import javafx.scene.control.Menu;
5 | import javafx.scene.control.MenuBar;
6 | import javafx.scene.control.MenuItem;
7 | import javafx.scene.image.Image;
8 | import javafx.scene.layout.VBox;
9 | import javafx.scene.web.HTMLEditor;
10 | import javafx.stage.Stage;
11 | import org.apache.commons.io.FileUtils;
12 |
13 | import java.io.File;
14 | import java.io.IOException;
15 | import java.io.PrintWriter;
16 | import java.nio.charset.StandardCharsets;
17 |
18 | public class TextEditor extends HTMLEditor {
19 |
20 | private Stage mStage;
21 | private File mFile;
22 |
23 | public TextEditor() {
24 |
25 | VBox root = new VBox();
26 |
27 | Menu fileMenu = new Menu("File");
28 | MenuItem saveHtmlMenuItem = new MenuItem("Save as HTML");
29 | saveHtmlMenuItem.setOnAction(e -> saveHtml());
30 | MenuItem closeMenuItem = new MenuItem("Close");
31 | closeMenuItem.setOnAction(e -> close());
32 | fileMenu.getItems().addAll(saveHtmlMenuItem, closeMenuItem);
33 |
34 | root.getChildren().addAll(new MenuBar(fileMenu), this);
35 |
36 | mStage = new Stage();
37 | Scene scene = new Scene(root);
38 | mStage.setScene(scene);
39 | mStage.getIcons().add(new Image(Main.class.getResourceAsStream("dolphin.png")));
40 | }
41 |
42 | public void open(File file) {
43 | if (file.toString().endsWith(".html")) {
44 | try {
45 | String content = FileUtils.readFileToString(file, StandardCharsets.UTF_8);
46 | mFile = file;
47 | setHtmlText(content);
48 | mStage.setTitle(file.getPath());
49 | mStage.show();
50 | } catch (IOException e) {
51 | mFile = null;
52 | mStage.close();
53 | }
54 | }
55 | }
56 |
57 | public void saveHtml() {
58 | if (mFile != null) {
59 | try (PrintWriter printWriter = new PrintWriter(mFile)) {
60 | printWriter.write(getHtmlText());
61 | } catch (Exception e) {
62 | mFile = null;
63 | }
64 | }
65 | }
66 |
67 | public void close() {
68 | boolean save = DialogHelper.showConfirmationDialog(mFile.getName(), null, "Save changes?");
69 | if (save) saveHtml();
70 | mStage.hide();
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/src/com/konv/dolphinexplorer/WatchServiceHelper.java:
--------------------------------------------------------------------------------
1 | package com.konv.dolphinexplorer;
2 |
3 | import javafx.application.Platform;
4 |
5 | import java.io.IOException;
6 | import java.nio.file.*;
7 |
8 | public class WatchServiceHelper {
9 |
10 | private WatchService mWatchService;
11 | private WatchKey mWatchKey;
12 | private volatile Thread mWatchThread;
13 |
14 | private ListView mListView;
15 | private Path mCurrentDirectory;
16 |
17 | public WatchServiceHelper(ListView listView) {
18 | mListView = listView;
19 | try {
20 | mWatchService = FileSystems.getDefault().newWatchService();
21 | mWatchKey = mListView.getDirectory().register(mWatchService, StandardWatchEventKinds.ENTRY_CREATE,
22 | StandardWatchEventKinds.ENTRY_DELETE, StandardWatchEventKinds.ENTRY_MODIFY);
23 | mCurrentDirectory = mListView.getDirectory();
24 | } catch (IOException e) {
25 | DialogHelper.showException(e);
26 | }
27 | mWatchThread = new Thread(() -> {
28 | while (true) {
29 | try {
30 | WatchKey watchKey = mWatchService.take();
31 | watchKey.pollEvents();
32 | updateUI();
33 | watchKey.reset();
34 | } catch (InterruptedException e) {
35 | DialogHelper.showException(e);
36 | }
37 | }
38 | });
39 | mWatchThread.start();
40 | }
41 |
42 | public void changeObservableDirectory(Path newDirectory) {
43 | if (mCurrentDirectory.equals(newDirectory)) return;
44 | mWatchKey.cancel();
45 | try {
46 | mWatchKey = newDirectory.register(mWatchService, StandardWatchEventKinds.ENTRY_CREATE,
47 | StandardWatchEventKinds.ENTRY_DELETE, StandardWatchEventKinds.ENTRY_MODIFY);
48 | mCurrentDirectory = newDirectory;
49 | } catch (IOException e) {
50 | DialogHelper.showException(e);
51 | }
52 | }
53 |
54 | private void updateUI() {
55 | Platform.runLater(() -> mListView.refresh());
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/com/konv/dolphinexplorer/dolphin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/konvio/javafx-file-manager/9a246d2864a504401302322bc5d6b786dac817cc/src/com/konv/dolphinexplorer/dolphin.png
--------------------------------------------------------------------------------
/src/com/konv/dolphinexplorer/test/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.konv.dolphinexplorer.test;
2 |
3 | import com.konv.dolphinexplorer.FileHelper;
4 | import com.konv.dolphinexplorer.StringHelper;
5 | import org.junit.After;
6 | import org.junit.Before;
7 | import org.junit.Test;
8 |
9 | import java.io.File;
10 | import java.io.IOException;
11 | import java.nio.file.Path;
12 | import java.util.ArrayList;
13 | import java.util.List;
14 |
15 | import static junit.framework.TestCase.fail;
16 | import static org.apache.commons.io.FileUtils.deleteDirectory;
17 | import static org.hamcrest.MatcherAssert.assertThat;
18 | import static org.hamcrest.Matchers.arrayContaining;
19 | import static org.hamcrest.Matchers.equalTo;
20 |
21 | public class ApplicationTest {
22 | private File mDirectory;
23 | private File mSourceDirectory;
24 | private File mTargetDirectory;
25 |
26 | @Before
27 | public void setupTestDirectory() {
28 | mDirectory = new File("D:/DolphinExplorerUnitTest");
29 | mDirectory.mkdir();
30 | mSourceDirectory = new File("D:/DolphinExplorerUnitTest/Source");
31 | mSourceDirectory.mkdir();
32 | mTargetDirectory = new File("D:/DolphinExplorerUnitTest/Target");
33 | mTargetDirectory.mkdir();
34 | }
35 |
36 | @Test
37 | public void singleFileCopyToOtherDirectory() {
38 | try {
39 | File file = new File("D:/DolphinExplorerUnitTest/Source/testFile.txt");
40 | file.createNewFile();
41 | List selection = new ArrayList<>();
42 | selection.add(file.toPath());
43 | FileHelper.copy(selection, mTargetDirectory.toPath());
44 | String[] targetFiles = mTargetDirectory.list();
45 | assertThat(targetFiles, arrayContaining("testFile.txt"));
46 | assertThat(file.exists(), equalTo(true));
47 | } catch (Exception e) {
48 | fail();
49 | }
50 | }
51 |
52 | @Test
53 | public void nonEmptyDirectoryDeletion() {
54 | try {
55 | File file = new File("D:/DolphinExplorerUnitTest/Source/testFile.txt");
56 | file.createNewFile();
57 | deleteDirectory(mSourceDirectory);
58 | assertThat(mSourceDirectory.exists(), equalTo(false));
59 | } catch (IOException e) {
60 | fail();
61 | }
62 | }
63 |
64 | @Test
65 | public void splitWordsTest() {
66 | String text = "Split,, me properly.Please,";
67 | String[] words = StringHelper.getWords(text);
68 | assertThat(words, arrayContaining("split", "me", "properly", "please"));
69 | }
70 |
71 | @Test
72 | public void containsWordTest() {
73 | String text = "fjaljflj ,jl aflj !!find,,,djfald; ";
74 | String word = "find";
75 | assertThat(StringHelper.containsWord(text, word), equalTo(true));
76 | }
77 |
78 | @After
79 | public void deleteTestDirectory() {
80 | try {
81 | deleteDirectory(mDirectory);
82 | } catch (IOException e) {
83 | fail();
84 | }
85 | }
86 | }
87 |
--------------------------------------------------------------------------------