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

Last change on this file was 127, checked in by Wouter Pasman, 6 years ago

#41 ROLL BACK of rev.126 . So this version is equal to rev. 125

File size: 1.1 KB
RevLine 
[127]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 }
[1]46}
Note: See TracBrowser for help on using the repository browser.