23bf6e30107826186f753fda8c4bd86e15e7595b
[jalviewjs.git] / site / swingjs / j2s / jssun / awt / shell / ShellFolder.js
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 () {
4 this.parent = null;
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"]);
10 this.parent = parent;
11 }, "jssun.awt.shell.ShellFolder,~S");
12 Clazz.defineMethod (c$, "isFileSystem", 
13 function () {
14 return (!this.getPath ().startsWith ("ShellFolder"));
15 });
16 Clazz.defineMethod (c$, "getParent", 
17 function () {
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 ());
22 } else {
23 return null;
24 }});
25 Clazz.defineMethod (c$, "getParentFile", 
26 function () {
27 if (this.parent != null) {
28 return this.parent;
29 } else if (this.isFileSystem ()) {
30 return Clazz.superCall (this, jssun.awt.shell.ShellFolder, "getParentFile", []);
31 } else {
32 return null;
33 }});
34 Clazz.defineMethod (c$, "listFiles", 
35 function () {
36 return this.listFiles (true);
37 });
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]);
47 }}
48 files = v.toArray ( new Array (v.size ()));
49 }return files;
50 }, "~B");
51 Clazz.defineMethod (c$, "compareTo", 
52 function (file2) {
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]);
56 } else {
57 return -1;
58 }} else {
59 if (this.isFileSystem ()) {
60 return 1;
61 } else {
62 return this.getName ().compareTo (file2.getName ());
63 }}}, "java.io.File");
64 Clazz.defineMethod (c$, "getIcon", 
65 function (getLargeIcon) {
66 return null;
67 }, "~B");
68 c$.getShellFolder = Clazz.defineMethod (c$, "getShellFolder", 
69 function (file) {
70 if (Clazz.instanceOf (file, jssun.awt.shell.ShellFolder)) {
71 return file;
72 }if (!file.exists ()) {
73 throw  new java.io.FileNotFoundException ();
74 }return jssun.awt.shell.ShellFolder.shellFolderManager.createShellFolder (file);
75 }, "java.io.File");
76 c$.get = Clazz.defineMethod (c$, "get", 
77 function (key) {
78 return jssun.awt.shell.ShellFolder.shellFolderManager.get (key);
79 }, "~S");
80 c$.isComputerNode = Clazz.defineMethod (c$, "isComputerNode", 
81 function (dir) {
82 return jssun.awt.shell.ShellFolder.shellFolderManager.isComputerNode (dir);
83 }, "java.io.File");
84 c$.isFileSystemRoot = Clazz.defineMethod (c$, "isFileSystemRoot", 
85 function (dir) {
86 return jssun.awt.shell.ShellFolder.shellFolderManager.isFileSystemRoot (dir);
87 }, "java.io.File");
88 c$.getNormalizedFile = Clazz.defineMethod (c$, "getNormalizedFile", 
89 function (f) {
90 var canonical = f.getCanonicalFile ();
91 if (f.equals (canonical)) {
92 return canonical;
93 }return  new java.io.File (f.toURI ().normalize ());
94 }, "java.io.File");
95 c$.sortFiles = Clazz.defineMethod (c$, "sortFiles", 
96 function (files) {
97 jssun.awt.shell.ShellFolder.shellFolderManager.sortFiles (files);
98 }, "java.util.List");
99 Clazz.defineMethod (c$, "isAbsolute", 
100 function () {
101 return (!this.isFileSystem () || Clazz.superCall (this, jssun.awt.shell.ShellFolder, "isAbsolute", []));
102 });
103 Clazz.defineMethod (c$, "getAbsoluteFile", 
104 function () {
105 return (this.isFileSystem () ? Clazz.superCall (this, jssun.awt.shell.ShellFolder, "getAbsoluteFile", []) : this);
106 });
107 Clazz.defineMethod (c$, "canRead", 
108 function () {
109 return (this.isFileSystem () ? Clazz.superCall (this, jssun.awt.shell.ShellFolder, "canRead", []) : true);
110 });
111 Clazz.defineMethod (c$, "canWrite", 
112 function () {
113 return (this.isFileSystem () ? Clazz.superCall (this, jssun.awt.shell.ShellFolder, "canWrite", []) : false);
114 });
115 Clazz.defineMethod (c$, "exists", 
116 function () {
117 return (!this.isFileSystem () || jssun.awt.shell.ShellFolder.isFileSystemRoot (this) || Clazz.superCall (this, jssun.awt.shell.ShellFolder, "exists", []));
118 });
119 Clazz.defineMethod (c$, "isDirectory", 
120 function () {
121 return (this.isFileSystem () ? Clazz.superCall (this, jssun.awt.shell.ShellFolder, "isDirectory", []) : true);
122 });
123 Clazz.defineMethod (c$, "isFile", 
124 function () {
125 return (this.isFileSystem () ? Clazz.superCall (this, jssun.awt.shell.ShellFolder, "isFile", []) : !this.isDirectory ());
126 });
127 Clazz.defineMethod (c$, "lastModified", 
128 function () {
129 return (this.isFileSystem () ? Clazz.superCall (this, jssun.awt.shell.ShellFolder, "lastModified", []) : 0);
130 });
131 Clazz.defineMethod (c$, "length", 
132 function () {
133 return (this.isFileSystem () ? Clazz.superCall (this, jssun.awt.shell.ShellFolder, "length", []) : 0);
134 });
135 Clazz.defineMethod (c$, "createNewFile", 
136 function () {
137 return (this.isFileSystem () ? Clazz.superCall (this, jssun.awt.shell.ShellFolder, "createNewFile", []) : false);
138 });
139 Clazz.defineMethod (c$, "$delete", 
140 function () {
141 return (this.isFileSystem () ? Clazz.superCall (this, jssun.awt.shell.ShellFolder, "delete", []) : false);
142 });
143 Clazz.defineMethod (c$, "deleteOnExit", 
144 function () {
145 if (this.isFileSystem ()) {
146 Clazz.superCall (this, jssun.awt.shell.ShellFolder, "deleteOnExit", []);
147 } else {
148 }});
149 Clazz.defineMethod (c$, "mkdir", 
150 function () {
151 return (this.isFileSystem () ? Clazz.superCall (this, jssun.awt.shell.ShellFolder, "mkdir", []) : false);
152 });
153 Clazz.defineMethod (c$, "mkdirs", 
154 function () {
155 return (this.isFileSystem () ? Clazz.superCall (this, jssun.awt.shell.ShellFolder, "mkdirs", []) : false);
156 });
157 Clazz.defineMethod (c$, "renameTo", 
158 function (dest) {
159 return (this.isFileSystem () ? Clazz.superCall (this, jssun.awt.shell.ShellFolder, "renameTo", [dest]) : false);
160 }, "java.io.File");
161 Clazz.defineMethod (c$, "setLastModified", 
162 function (time) {
163 return (this.isFileSystem () ? Clazz.superCall (this, jssun.awt.shell.ShellFolder, "setLastModified", [time]) : false);
164 }, "~N");
165 Clazz.defineMethod (c$, "setReadOnly", 
166 function () {
167 return (this.isFileSystem () ? Clazz.superCall (this, jssun.awt.shell.ShellFolder, "setReadOnly", []) : false);
168 });
169 Clazz.defineMethod (c$, "toString", 
170 function () {
171 return (this.isFileSystem () ? Clazz.superCall (this, jssun.awt.shell.ShellFolder, "toString", []) : this.getDisplayName ());
172 });
173 c$.getFolderColumns = Clazz.defineMethod (c$, "getFolderColumns", 
174 function (dir) {
175 return jssun.awt.shell.ShellFolder.shellFolderManager.getFolderColumns (dir);
176 }, "java.io.File");
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", 
182 function () {
183 return null;
184 });
185 Clazz.defineMethod (c$, "getFolderColumnValue", 
186 function (column) {
187 return null;
188 }, "~N");
189 Clazz.defineStatics (c$,
190 "shellFolderManager", null);
191 {
192 var managerClass = java.awt.Toolkit.getDefaultToolkit ().getDesktopProperty ("Shell.shellFolderManager");
193 if (managerClass == null) {
194 managerClass = jssun.awt.shell.ShellFolderManager;
195 }try {
196 jssun.awt.shell.ShellFolder.shellFolderManager = managerClass.newInstance ();
197 } catch (e$$) {
198 if (Clazz.exceptionOf (e$$, InstantiationException)) {
199 var e = e$$;
200 {
201 throw  new Error ("Could not instantiate Shell Folder Manager: " + managerClass.getName ());
202 }
203 } else if (Clazz.exceptionOf (e$$, IllegalAccessException)) {
204 var e = e$$;
205 {
206 throw  new Error ("Could not access Shell Folder Manager: " + managerClass.getName ());
207 }
208 } else {
209 throw e$$;
210 }
211 }
212 }});