source: src/main/java/genius/gui/panels/DirectoryRestrictedFileSystemView.java@ 84

Last change on this file since 84 was 1, checked in by Wouter Pasman, 6 years ago

Initial import : Genius 9.0.0

File size: 1.1 KB
Line 
1package genius.gui.panels;
2
3import java.io.File;
4import java.io.IOException;
5
6import javax.swing.filechooser.FileSystemView;
7
8public class DirectoryRestrictedFileSystemView extends FileSystemView
9{
10 private final File[] rootDirectories;
11
12 public DirectoryRestrictedFileSystemView(File rootDirectory)
13 {
14 this.rootDirectories = new File[] {rootDirectory};
15 }
16
17 public DirectoryRestrictedFileSystemView(File[] rootDirectories)
18 {
19 this.rootDirectories = rootDirectories;
20 }
21
22 @Override
23 public File getHomeDirectory() { return rootDirectories[0]; }
24
25 @Override
26 public File[] getRoots()
27 {
28 return rootDirectories;
29 }
30
31 @Override
32 public boolean isRoot(File file)
33 {
34 for (File root : rootDirectories) {
35 if (root.equals(file)) {
36 return true;
37 }
38 }
39 return false;
40 }
41
42 @Override
43 public File createNewFolder(File folder) throws IOException {
44 return super.getFileSystemView().createNewFolder(folder);
45 }
46}
Note: See TracBrowser for help on using the repository browser.