01: /*
02: * @(#)MyComputerTreeNode.java 8/19/2006
03: *
04: * Copyright 2002 - 2006 JIDE Software Inc. All rights reserved.
05: */
06:
07: package com.jidesoft.plaf.basic;
08:
09: import com.jidesoft.swing.FolderChooser;
10:
11: import javax.swing.filechooser.FileSystemView;
12: import java.io.File;
13: import java.util.Arrays;
14:
15: class MyComputerTreeNode extends LazyMutableTreeNode {
16: private FolderChooser _folderChooser;
17:
18: public MyComputerTreeNode(FolderChooser folderChooser) {
19: super (folderChooser.getFileSystemView());
20: _folderChooser = folderChooser;
21: }
22:
23: @Override
24: protected void initChildren() {
25: FileSystemView fsv = (FileSystemView) getUserObject();
26: File[] roots = fsv.getRoots();
27: if (roots != null) {
28: Arrays.sort(roots);
29: for (int i = 0, c = roots.length; i < c; i++) {
30: BasicFileSystemTreeNode newChild = BasicFileSystemTreeNode
31: .createFileSystemTreeNode(roots[i],
32: _folderChooser);
33: add(newChild);
34: }
35: }
36: }
37:
38: @Override
39: public String toString() {
40: return "/";
41: }
42: }
|