< prev index next >

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

Print this page




 109     private static final int VIEW_NEWFOLDER = 11;
 110 
 111     private static final Image[] STANDARD_VIEW_BUTTONS = new Image[12];
 112 
 113     private static Image getStandardViewButton(int iconIndex) {
 114         Image result = STANDARD_VIEW_BUTTONS[iconIndex];
 115 
 116         if (result != null) {
 117             return result;
 118         }
 119 
 120         final int[] iconBits = Win32ShellFolder2
 121                 .getStandardViewButton0(iconIndex, true);
 122         if (iconBits != null) {
 123             // icons are always square
 124             final int size = (int) Math.sqrt(iconBits.length);
 125             final BufferedImage img =
 126                     new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB);
 127             img.setRGB(0, 0, size, size, iconBits, 0, size);
 128 
 129             STANDARD_VIEW_BUTTONS[iconIndex] = (size == 16)
 130                     ? img
 131                     : new MultiResolutionIconImage(16, img);
 132         }
 133 
 134         return STANDARD_VIEW_BUTTONS[iconIndex];
 135     }
 136 
 137     // Special folders
 138     private static Win32ShellFolder2 desktop;
 139     private static Win32ShellFolder2 drives;
 140     private static Win32ShellFolder2 recent;
 141     private static Win32ShellFolder2 network;
 142     private static Win32ShellFolder2 personal;
 143 
 144     static Win32ShellFolder2 getDesktop() {
 145         if (desktop == null) {
 146             try {
 147                 desktop = new Win32ShellFolder2(DESKTOP);
 148             } catch (SecurityException e) {
 149                 // Ignore error
 150             } catch (IOException e) {
 151                 // Ignore error


 362             return getStandardViewButton(iconIndex);
 363         } else if (key.startsWith("optionPaneIcon ")) {
 364             Win32ShellFolder2.SystemIcon iconType;
 365             if (key == "optionPaneIcon Error") {
 366                 iconType = Win32ShellFolder2.SystemIcon.IDI_ERROR;
 367             } else if (key == "optionPaneIcon Information") {
 368                 iconType = Win32ShellFolder2.SystemIcon.IDI_INFORMATION;
 369             } else if (key == "optionPaneIcon Question") {
 370                 iconType = Win32ShellFolder2.SystemIcon.IDI_QUESTION;
 371             } else if (key == "optionPaneIcon Warning") {
 372                 iconType = Win32ShellFolder2.SystemIcon.IDI_EXCLAMATION;
 373             } else {
 374                 return null;
 375             }
 376             return Win32ShellFolder2.getSystemIcon(iconType);
 377         } else if (key.startsWith("shell32Icon ") || key.startsWith("shell32LargeIcon ")) {
 378             String name = key.substring(key.indexOf(" ") + 1);
 379             try {
 380                 int i = Integer.parseInt(name);
 381                 if (i >= 0) {
 382                     return Win32ShellFolder2.getShell32Icon(i, key.startsWith("shell32LargeIcon "));


 383                 }
 384             } catch (NumberFormatException ex) {
 385             }
 386         }
 387         return null;
 388     }
 389 
 390     private File checkFile(File file) {
 391         SecurityManager sm = System.getSecurityManager();
 392         return (sm == null || file == null) ? file : checkFile(file, sm);
 393     }
 394 
 395     private File checkFile(File file, SecurityManager sm) {
 396         try {
 397             sm.checkRead(file.getPath());
 398             return file;
 399         } catch (SecurityException se) {
 400             return null;
 401         }
 402     }




 109     private static final int VIEW_NEWFOLDER = 11;
 110 
 111     private static final Image[] STANDARD_VIEW_BUTTONS = new Image[12];
 112 
 113     private static Image getStandardViewButton(int iconIndex) {
 114         Image result = STANDARD_VIEW_BUTTONS[iconIndex];
 115 
 116         if (result != null) {
 117             return result;
 118         }
 119 
 120         final int[] iconBits = Win32ShellFolder2
 121                 .getStandardViewButton0(iconIndex, true);
 122         if (iconBits != null) {
 123             // icons are always square
 124             final int size = (int) Math.sqrt(iconBits.length);
 125             final BufferedImage img =
 126                     new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB);
 127             img.setRGB(0, 0, size, size, iconBits, 0, size);
 128 
 129             STANDARD_VIEW_BUTTONS[iconIndex] = (size == SMALL_ICON_SIZE)
 130                     ? img
 131                     : new MultiResolutionIconImage(SMALL_ICON_SIZE, img);
 132         }
 133 
 134         return STANDARD_VIEW_BUTTONS[iconIndex];
 135     }
 136 
 137     // Special folders
 138     private static Win32ShellFolder2 desktop;
 139     private static Win32ShellFolder2 drives;
 140     private static Win32ShellFolder2 recent;
 141     private static Win32ShellFolder2 network;
 142     private static Win32ShellFolder2 personal;
 143 
 144     static Win32ShellFolder2 getDesktop() {
 145         if (desktop == null) {
 146             try {
 147                 desktop = new Win32ShellFolder2(DESKTOP);
 148             } catch (SecurityException e) {
 149                 // Ignore error
 150             } catch (IOException e) {
 151                 // Ignore error


 362             return getStandardViewButton(iconIndex);
 363         } else if (key.startsWith("optionPaneIcon ")) {
 364             Win32ShellFolder2.SystemIcon iconType;
 365             if (key == "optionPaneIcon Error") {
 366                 iconType = Win32ShellFolder2.SystemIcon.IDI_ERROR;
 367             } else if (key == "optionPaneIcon Information") {
 368                 iconType = Win32ShellFolder2.SystemIcon.IDI_INFORMATION;
 369             } else if (key == "optionPaneIcon Question") {
 370                 iconType = Win32ShellFolder2.SystemIcon.IDI_QUESTION;
 371             } else if (key == "optionPaneIcon Warning") {
 372                 iconType = Win32ShellFolder2.SystemIcon.IDI_EXCLAMATION;
 373             } else {
 374                 return null;
 375             }
 376             return Win32ShellFolder2.getSystemIcon(iconType);
 377         } else if (key.startsWith("shell32Icon ") || key.startsWith("shell32LargeIcon ")) {
 378             String name = key.substring(key.indexOf(" ") + 1);
 379             try {
 380                 int i = Integer.parseInt(name);
 381                 if (i >= 0) {
 382                     return Win32ShellFolder2.getShell32Icon(i,
 383                                  key.startsWith("shell32LargeIcon ") ?
 384                                              LARGE_ICON_SIZE : SMALL_ICON_SIZE);
 385                 }
 386             } catch (NumberFormatException ex) {
 387             }
 388         }
 389         return null;
 390     }
 391 
 392     private File checkFile(File file) {
 393         SecurityManager sm = System.getSecurityManager();
 394         return (sm == null || file == null) ? file : checkFile(file, sm);
 395     }
 396 
 397     private File checkFile(File file, SecurityManager sm) {
 398         try {
 399             sm.checkRead(file.getPath());
 400             return file;
 401         } catch (SecurityException se) {
 402             return null;
 403         }
 404     }


< prev index next >