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
|
Rev | Line | |
---|
[127] | 1 | package genius.gui.panels;
|
---|
| 2 |
|
---|
| 3 | import java.io.File;
|
---|
| 4 | import java.io.IOException;
|
---|
| 5 |
|
---|
| 6 | import javax.swing.filechooser.FileSystemView;
|
---|
| 7 |
|
---|
| 8 | public 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.