1 Clazz.declarePackage ("jssun.awt.shell");
2 Clazz.load (["java.io.File"], "jssun.awt.shell.ShellFolder", ["java.io.FileNotFoundException", "java.lang.Error", "java.util.Vector", "java.awt.Toolkit", "jssun.awt.shell.ShellFolderManager"], function () {
3 c$ = Clazz.decorateAsClass (function () {
5 Clazz.instantialize (this, arguments);
6 }, jssun.awt.shell, "ShellFolder", java.io.File);
7 Clazz.makeConstructor (c$,
8 function (parent, pathname) {
9 Clazz.superConstructor (this, jssun.awt.shell.ShellFolder, [(pathname != null) ? pathname : "ShellFolder"]);
11 }, "jssun.awt.shell.ShellFolder,~S");
12 Clazz.defineMethod (c$, "isFileSystem",
14 return (!this.getPath ().startsWith ("ShellFolder"));
16 Clazz.defineMethod (c$, "getParent",
18 if (this.parent == null && this.isFileSystem ()) {
19 return Clazz.superCall (this, jssun.awt.shell.ShellFolder, "getParent", []);
20 }if (this.parent != null) {
21 return (this.parent.getPath ());
25 Clazz.defineMethod (c$, "getParentFile",
27 if (this.parent != null) {
29 } else if (this.isFileSystem ()) {
30 return Clazz.superCall (this, jssun.awt.shell.ShellFolder, "getParentFile", []);
34 Clazz.defineMethod (c$, "listFiles",
36 return this.listFiles (true);
38 Clazz.defineMethod (c$, "listFiles",
39 function (includeHiddenFiles) {
40 var files = Clazz.superCall (this, jssun.awt.shell.ShellFolder, "listFiles", []);
41 if (!includeHiddenFiles) {
42 var v = new java.util.Vector ();
43 var nameCount = (files == null) ? 0 : files.length;
44 for (var i = 0; i < nameCount; i++) {
45 if (!files[i].isHidden ()) {
46 v.addElement (files[i]);
48 files = v.toArray ( new Array (v.size ()));
51 Clazz.defineMethod (c$, "compareTo",
53 if (file2 == null || !(Clazz.instanceOf (file2, jssun.awt.shell.ShellFolder)) || ((Clazz.instanceOf (file2, jssun.awt.shell.ShellFolder)) && (file2).isFileSystem ())) {
54 if (this.isFileSystem ()) {
55 return Clazz.superCall (this, jssun.awt.shell.ShellFolder, "compareTo", [file2]);
59 if (this.isFileSystem ()) {
62 return this.getName ().compareTo (file2.getName ());
64 Clazz.defineMethod (c$, "getIcon",
65 function (getLargeIcon) {
68 c$.getShellFolder = Clazz.defineMethod (c$, "getShellFolder",
70 if (Clazz.instanceOf (file, jssun.awt.shell.ShellFolder)) {
72 }if (!file.exists ()) {
73 throw new java.io.FileNotFoundException ();
74 }return jssun.awt.shell.ShellFolder.shellFolderManager.createShellFolder (file);
76 c$.get = Clazz.defineMethod (c$, "get",
78 return jssun.awt.shell.ShellFolder.shellFolderManager.get (key);
80 c$.isComputerNode = Clazz.defineMethod (c$, "isComputerNode",
82 return jssun.awt.shell.ShellFolder.shellFolderManager.isComputerNode (dir);
84 c$.isFileSystemRoot = Clazz.defineMethod (c$, "isFileSystemRoot",
86 return jssun.awt.shell.ShellFolder.shellFolderManager.isFileSystemRoot (dir);
88 c$.getNormalizedFile = Clazz.defineMethod (c$, "getNormalizedFile",
90 var canonical = f.getCanonicalFile ();
91 if (f.equals (canonical)) {
93 }return new java.io.File (f.toURI ().normalize ());
95 c$.sortFiles = Clazz.defineMethod (c$, "sortFiles",
97 jssun.awt.shell.ShellFolder.shellFolderManager.sortFiles (files);
99 Clazz.defineMethod (c$, "isAbsolute",
101 return (!this.isFileSystem () || Clazz.superCall (this, jssun.awt.shell.ShellFolder, "isAbsolute", []));
103 Clazz.defineMethod (c$, "getAbsoluteFile",
105 return (this.isFileSystem () ? Clazz.superCall (this, jssun.awt.shell.ShellFolder, "getAbsoluteFile", []) : this);
107 Clazz.defineMethod (c$, "canRead",
109 return (this.isFileSystem () ? Clazz.superCall (this, jssun.awt.shell.ShellFolder, "canRead", []) : true);
111 Clazz.defineMethod (c$, "canWrite",
113 return (this.isFileSystem () ? Clazz.superCall (this, jssun.awt.shell.ShellFolder, "canWrite", []) : false);
115 Clazz.defineMethod (c$, "exists",
117 return (!this.isFileSystem () || jssun.awt.shell.ShellFolder.isFileSystemRoot (this) || Clazz.superCall (this, jssun.awt.shell.ShellFolder, "exists", []));
119 Clazz.defineMethod (c$, "isDirectory",
121 return (this.isFileSystem () ? Clazz.superCall (this, jssun.awt.shell.ShellFolder, "isDirectory", []) : true);
123 Clazz.defineMethod (c$, "isFile",
125 return (this.isFileSystem () ? Clazz.superCall (this, jssun.awt.shell.ShellFolder, "isFile", []) : !this.isDirectory ());
127 Clazz.defineMethod (c$, "lastModified",
129 return (this.isFileSystem () ? Clazz.superCall (this, jssun.awt.shell.ShellFolder, "lastModified", []) : 0);
131 Clazz.defineMethod (c$, "length",
133 return (this.isFileSystem () ? Clazz.superCall (this, jssun.awt.shell.ShellFolder, "length", []) : 0);
135 Clazz.defineMethod (c$, "createNewFile",
137 return (this.isFileSystem () ? Clazz.superCall (this, jssun.awt.shell.ShellFolder, "createNewFile", []) : false);
139 Clazz.defineMethod (c$, "$delete",
141 return (this.isFileSystem () ? Clazz.superCall (this, jssun.awt.shell.ShellFolder, "delete", []) : false);
143 Clazz.defineMethod (c$, "deleteOnExit",
145 if (this.isFileSystem ()) {
146 Clazz.superCall (this, jssun.awt.shell.ShellFolder, "deleteOnExit", []);
149 Clazz.defineMethod (c$, "mkdir",
151 return (this.isFileSystem () ? Clazz.superCall (this, jssun.awt.shell.ShellFolder, "mkdir", []) : false);
153 Clazz.defineMethod (c$, "mkdirs",
155 return (this.isFileSystem () ? Clazz.superCall (this, jssun.awt.shell.ShellFolder, "mkdirs", []) : false);
157 Clazz.defineMethod (c$, "renameTo",
159 return (this.isFileSystem () ? Clazz.superCall (this, jssun.awt.shell.ShellFolder, "renameTo", [dest]) : false);
161 Clazz.defineMethod (c$, "setLastModified",
163 return (this.isFileSystem () ? Clazz.superCall (this, jssun.awt.shell.ShellFolder, "setLastModified", [time]) : false);
165 Clazz.defineMethod (c$, "setReadOnly",
167 return (this.isFileSystem () ? Clazz.superCall (this, jssun.awt.shell.ShellFolder, "setReadOnly", []) : false);
169 Clazz.defineMethod (c$, "toString",
171 return (this.isFileSystem () ? Clazz.superCall (this, jssun.awt.shell.ShellFolder, "toString", []) : this.getDisplayName ());
173 c$.getFolderColumns = Clazz.defineMethod (c$, "getFolderColumns",
175 return jssun.awt.shell.ShellFolder.shellFolderManager.getFolderColumns (dir);
177 c$.getFolderColumnValue = Clazz.defineMethod (c$, "getFolderColumnValue",
178 function (file, column) {
179 return jssun.awt.shell.ShellFolder.shellFolderManager.getFolderColumnValue (file, column);
180 }, "java.io.File,~N");
181 Clazz.defineMethod (c$, "getFolderColumns",
185 Clazz.defineMethod (c$, "getFolderColumnValue",
189 Clazz.defineStatics (c$,
190 "shellFolderManager", null);
192 var managerClass = java.awt.Toolkit.getDefaultToolkit ().getDesktopProperty ("Shell.shellFolderManager");
193 if (managerClass == null) {
194 managerClass = jssun.awt.shell.ShellFolderManager;
196 jssun.awt.shell.ShellFolder.shellFolderManager = managerClass.newInstance ();
198 if (Clazz.exceptionOf (e$$, InstantiationException)) {
201 throw new Error ("Could not instantiate Shell Folder Manager: " + managerClass.getName ());
203 } else if (Clazz.exceptionOf (e$$, IllegalAccessException)) {
206 throw new Error ("Could not access Shell Folder Manager: " + managerClass.getName ());