< prev index next >

src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java

Print this page

        

@@ -954,11 +954,11 @@
     // Return the icon of a file system shell folder in the form of an HICON
     private static native long getIcon(String absolutePath, boolean getLargeIcon);
 
     // NOTE: this method uses COM and must be called on the 'COM thread'. See ComInvoker for the details
     private static native long extractIcon(long parentIShellFolder, long relativePIDL,
-                                           boolean getLargeIcon);
+                                           boolean getLargeIcon, boolean getDefaultIcon);
 
     // Returns an icon from the Windows system icon list in the form of an HICON
     private static native long getSystemIcon(int iconID);
     private static native long getIconResource(String libName, int iconID,
                                                int cxDesired, int cyDesired,

@@ -1005,11 +1005,18 @@
         if (icon == null) {
             icon =
                 invoke(new Callable<Image>() {
                     public Image call() {
                         Image newIcon = null;
-                        if (isFileSystem()) {
+                        if (isLink()) {
+                            ShellFolder folder = getLinkLocation();
+                            if (folder != null && "Library".equals(
+                                    folder.getFolderType())) {
+                                return folder.getIcon(getLargeIcon);
+                            }
+                        }
+                        if (isFileSystem() || "Library".equals(getFolderType())) {
                             long parentIShellIcon = (parent != null)
                                 ? ((Win32ShellFolder2) parent).getIShellIcon()
                                 : 0L;
                             long relativePIDL = getRelativePIDL();
 

@@ -1035,11 +1042,23 @@
                         }
 
                         if (newIcon == null) {
                             // These are only cached per object
                             long hIcon = extractIcon(getParentIShellFolder(),
-                                getRelativePIDL(), getLargeIcon);
+                                    getRelativePIDL(), getLargeIcon, false);
+                            // E_PENDING: loading can take time so get the default
+                            if(hIcon <= 0) {
+                                hIcon = extractIcon(getParentIShellFolder(),
+                                         getRelativePIDL(), getLargeIcon, true);
+                                if(hIcon <= 0) {
+                                    if (isDirectory()) {
+                                        return getShell32Icon(4, getLargeIcon);
+                                    } else {
+                                        return getShell32Icon(1, getLargeIcon);
+                                    }
+                                }
+                            }
                             newIcon = makeIcon(hIcon, getLargeIcon);
                             disposeIcon(hIcon);
                         }
 
                         if (newIcon == null) {
< prev index next >