1 /*
2 * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
175 */
176 public int compareTo(File file2) {
177 if (file2 == null || !(file2 instanceof ShellFolder)
178 || ((file2 instanceof ShellFolder) && ((ShellFolder)file2).isFileSystem())) {
179
180 if (isFileSystem()) {
181 return super.compareTo(file2);
182 } else {
183 return -1;
184 }
185 } else {
186 if (isFileSystem()) {
187 return 1;
188 } else {
189 return getName().compareTo(file2.getName());
190 }
191 }
192 }
193
194 /**
195 * @param getLargeIcon whether to return large icon (ignored in base implementation)
196 * @return The icon used to display this shell folder
197 */
198 public Image getIcon(boolean getLargeIcon) {
199 return null;
200 }
201
202
203 // Static
204
205 private static final ShellFolderManager shellFolderManager;
206
207 private static final Invoker invoker;
208
209 static {
210 String managerClassName = (String)Toolkit.getDefaultToolkit().
211 getDesktopProperty("Shell.shellFolderManager");
212 Class<?> managerClass = null;
213 try {
214 managerClass = Class.forName(managerClassName, false, null);
215 if (!ShellFolderManager.class.isAssignableFrom(managerClass)) {
216 managerClass = null;
217 }
218 // swallow the exceptions below and use default shell folder
219 } catch(ClassNotFoundException e) {
220 } catch(NullPointerException e) {
221 } catch(SecurityException e) {
|
1 /*
2 * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
175 */
176 public int compareTo(File file2) {
177 if (file2 == null || !(file2 instanceof ShellFolder)
178 || ((file2 instanceof ShellFolder) && ((ShellFolder)file2).isFileSystem())) {
179
180 if (isFileSystem()) {
181 return super.compareTo(file2);
182 } else {
183 return -1;
184 }
185 } else {
186 if (isFileSystem()) {
187 return 1;
188 } else {
189 return getName().compareTo(file2.getName());
190 }
191 }
192 }
193
194 /**
195 * Returns the icon to display this shell folder.
196 *
197 * @param getLargeIcon whether to return large icon (ignored in base implementation)
198 * @return The icon used to display this shell folder
199 */
200 public Image getIcon(boolean getLargeIcon) {
201 return null;
202 }
203
204 /**
205 * Returns the icon of the specified size used to display this shell folder.
206 *
207 * @param size size of the icon > 0(Valid range: 1 to 256)
208 * @return The icon of the specified size used to display this shell folder
209 */
210 public Image getIcon(int size) {
211 return null;
212 }
213
214 // Static
215
216 private static final ShellFolderManager shellFolderManager;
217
218 private static final Invoker invoker;
219
220 static {
221 String managerClassName = (String)Toolkit.getDefaultToolkit().
222 getDesktopProperty("Shell.shellFolderManager");
223 Class<?> managerClass = null;
224 try {
225 managerClass = Class.forName(managerClassName, false, null);
226 if (!ShellFolderManager.class.isAssignableFrom(managerClass)) {
227 managerClass = null;
228 }
229 // swallow the exceptions below and use default shell folder
230 } catch(ClassNotFoundException e) {
231 } catch(NullPointerException e) {
232 } catch(SecurityException e) {
|