ShellFolderManager.java revision 0
/*
* Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/**
* @author Michael Martak
* @since 1.4
*/
class ShellFolderManager {
/**
* Create a shell folder from a file.
* Override to return machine-dependent behavior.
*/
}
/**
* @param key a <code>String</code>
* "fileChooserDefaultFolder":
* Returns a <code>File</code> - the default shellfolder for a new filechooser
* "roots":
* Returns a <code>File[]</code> - containing the root(s) of the displayable hieararchy
* "fileChooserComboBoxFolders":
* Returns a <code>File[]</code> - an array of shellfolders representing the list to
* show by default in the file chooser's combobox
* "fileChooserShortcutPanelFolders":
* Returns a <code>File[]</code> - an array of shellfolders representing well-known
* folders, such as Desktop, Documents, History, Network, Home, etc.
* This is used in the shortcut panel of the filechooser on Windows 2000
* and Windows Me.
* "fileChooserIcon nn":
* Returns an <code>Image</code> - icon nn from resource 124 in comctl32.dll (Windows only).
*
* @return An Object matching the key string.
*/
// Return the default shellfolder for a new filechooser
try {
return createShellFolder(homeDir);
} catch (FileNotFoundException e) {
return homeDir;
}
// The root(s) of the displayable hieararchy
// Return an array of ShellFolders representing the list to
// show by default in the file chooser's combobox
return get("roots");
// Return an array of ShellFolders representing well-known
// folders, such as Desktop, Documents, History, Network, Home, etc.
// This is used in the shortcut panel of the filechooser on Windows 2000
// and Windows Me
}
return null;
}
/**
* Does <code>dir</code> represent a "computer" such as a node on the network, or
* "My Computer" on the desktop.
*/
return false;
}
return false;
}
}
}
}
if (f1 instanceof ShellFolder) {
if (sf1.isFileSystem()) {
}
}
if (f2 instanceof ShellFolder) {
if (sf2.isFileSystem()) {
}
}
return -1; // Non-file shellfolders sort before files
return 1;
} else {
// First ignore case when comparing
if (diff != 0) {
return diff;
} else {
// May differ in case (e.g. "mail" vs. "Mail")
// We need this test for consistent sorting
}
}
}
};
if (dir instanceof ShellFolder) {
}
columns = new ShellFolderColumnInfo[]{
ComparableComparator.getInstance(), true),
ComparableComparator.getInstance(), true)
};
}
return columns;
}
if (file instanceof ShellFolder) {
return value;
}
}
return null;
}
switch (column) {
case 0:
// By default, file name will be rendered using getSystemDisplayName()
return file;
case 1: // size
case 2: // date
if (isFileSystemRoot(file)) {
return null;
}
default:
return null;
}
}
/**
* This class provides a default comparator for the default column set
*/
private static class ComparableComparator implements Comparator {
private static Comparator instance;
public static Comparator getInstance() {
instance = new ComparableComparator();
}
return instance;
}
int gt;
gt = 0;
gt = 1;
gt = -1;
} else if (o1 instanceof Comparable) {
} else {
gt = 0;
}
return gt;
}
}
}