< prev index next >

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

Print this page

        

@@ -849,18 +849,18 @@
      */
     public ShellFolder getLinkLocation()  {
         return getLinkLocation(true);
     }
 
-    private ShellFolder getLinkLocation(final boolean resolve) {
-        return invoke(new Callable<ShellFolder>() {
-            public ShellFolder call() {
+    private Win32ShellFolder2 getLinkLocation(final boolean resolve) {
+        return invoke(new Callable<Win32ShellFolder2>() {
+            public Win32ShellFolder2 call() {
                 if (!isLink()) {
                     return null;
                 }
 
-                ShellFolder location = null;
+                Win32ShellFolder2 location = null;
                 long linkLocationPIDL = getLinkLocation(getParentIShellFolder(),
                         getRelativePIDL(), resolve);
                 if (linkLocationPIDL != 0) {
                     try {
                         location =

@@ -966,11 +966,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,

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

@@ -1047,11 +1053,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 >