< prev index next >

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

Print this page




  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
  23  * questions.
  24  */
  25 
  26 package sun.awt.shell;
  27 
  28 import java.awt.*;
  29 import java.awt.image.BufferedImage;
  30 
  31 import java.io.File;
  32 import java.io.FileNotFoundException;
  33 import java.io.IOException;

  34 import java.security.AccessController;
  35 import java.security.PrivilegedAction;
  36 import java.util.*;
  37 import java.util.List;
  38 import java.util.concurrent.*;
  39 import java.util.stream.Stream;
  40 
  41 import static sun.awt.shell.Win32ShellFolder2.*;
  42 import sun.awt.OSInfo;
  43 import sun.awt.util.ThreadGroupUtils;
  44 // NOTE: This class supersedes Win32ShellFolderManager, which was removed
  45 //       from distribution after version 1.4.2.
  46 
  47 /**
  48  * @author Michael Martak
  49  * @author Leif Samuelsson
  50  * @author Kenneth Russell
  51  * @since 1.4
  52  */
  53 


 356             if (key == "optionPaneIcon Error") {
 357                 iconType = Win32ShellFolder2.SystemIcon.IDI_ERROR;
 358             } else if (key == "optionPaneIcon Information") {
 359                 iconType = Win32ShellFolder2.SystemIcon.IDI_INFORMATION;
 360             } else if (key == "optionPaneIcon Question") {
 361                 iconType = Win32ShellFolder2.SystemIcon.IDI_QUESTION;
 362             } else if (key == "optionPaneIcon Warning") {
 363                 iconType = Win32ShellFolder2.SystemIcon.IDI_EXCLAMATION;
 364             } else {
 365                 return null;
 366             }
 367             return Win32ShellFolder2.getSystemIcon(iconType);
 368         } else if (key.startsWith("shell32Icon ") || key.startsWith("shell32LargeIcon ")) {
 369             String name = key.substring(key.indexOf(" ") + 1);
 370             try {
 371                 int i = Integer.parseInt(name);
 372                 if (i >= 0) {
 373                     return Win32ShellFolder2.getShell32Icon(i, key.startsWith("shell32LargeIcon "));
 374                 }
 375             } catch (NumberFormatException ex) {

















 376             }
 377         }
 378         return null;
 379     }
 380 
 381     private File checkFile(File file) {
 382         SecurityManager sm = System.getSecurityManager();
 383         return (sm == null || file == null) ? file : checkFile(file, sm);
 384     }
 385 
 386     private File checkFile(File file, SecurityManager sm) {
 387         try {
 388             sm.checkRead(file.getPath());
 389             return file;
 390         } catch (SecurityException se) {
 391             return null;
 392         }
 393     }
 394 
 395     private File[] checkFiles(File[] files) {




  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
  23  * questions.
  24  */
  25 
  26 package sun.awt.shell;
  27 
  28 import java.awt.*;
  29 import java.awt.image.BufferedImage;
  30 
  31 import java.io.File;
  32 import java.io.FileNotFoundException;
  33 import java.io.IOException;
  34 import java.io.UncheckedIOException;
  35 import java.security.AccessController;
  36 import java.security.PrivilegedAction;
  37 import java.util.*;
  38 import java.util.List;
  39 import java.util.concurrent.*;
  40 import java.util.stream.Stream;
  41 
  42 import static sun.awt.shell.Win32ShellFolder2.*;
  43 import sun.awt.OSInfo;
  44 import sun.awt.util.ThreadGroupUtils;
  45 // NOTE: This class supersedes Win32ShellFolderManager, which was removed
  46 //       from distribution after version 1.4.2.
  47 
  48 /**
  49  * @author Michael Martak
  50  * @author Leif Samuelsson
  51  * @author Kenneth Russell
  52  * @since 1.4
  53  */
  54 


 357             if (key == "optionPaneIcon Error") {
 358                 iconType = Win32ShellFolder2.SystemIcon.IDI_ERROR;
 359             } else if (key == "optionPaneIcon Information") {
 360                 iconType = Win32ShellFolder2.SystemIcon.IDI_INFORMATION;
 361             } else if (key == "optionPaneIcon Question") {
 362                 iconType = Win32ShellFolder2.SystemIcon.IDI_QUESTION;
 363             } else if (key == "optionPaneIcon Warning") {
 364                 iconType = Win32ShellFolder2.SystemIcon.IDI_EXCLAMATION;
 365             } else {
 366                 return null;
 367             }
 368             return Win32ShellFolder2.getSystemIcon(iconType);
 369         } else if (key.startsWith("shell32Icon ") || key.startsWith("shell32LargeIcon ")) {
 370             String name = key.substring(key.indexOf(" ") + 1);
 371             try {
 372                 int i = Integer.parseInt(name);
 373                 if (i >= 0) {
 374                     return Win32ShellFolder2.getShell32Icon(i, key.startsWith("shell32LargeIcon "));
 375                 }
 376             } catch (NumberFormatException ex) {
 377             }
 378         } else if (key.startsWith("{") && key.endsWith("}")) {
 379             try {
 380                 long pidl = getDesktop().parseDisplayName("shell:::" + key);
 381                 return Win32ShellFolder2.createShellFolder(getDesktop(), pidl);
 382             } catch (IOException ex) {
 383                 throw new InternalError(ex);
 384             }catch(InterruptedException ex) {
 385             }
 386         } else if(key.startsWith("parseDisplayName ")) {
 387             String name = key.substring("parseDisplayName ".length());
 388             try {
 389                 long pidl = getDesktop().parseDisplayName(name);
 390                 return Win32ShellFolder2.createShellFolder(getDesktop(), pidl);
 391             } catch (IOException ex) {
 392                 throw new UncheckedIOException(ex);
 393             } catch(InterruptedException ex) {
 394             }
 395         }
 396         return null;
 397     }
 398 
 399     private File checkFile(File file) {
 400         SecurityManager sm = System.getSecurityManager();
 401         return (sm == null || file == null) ? file : checkFile(file, sm);
 402     }
 403 
 404     private File checkFile(File file, SecurityManager sm) {
 405         try {
 406             sm.checkRead(file.getPath());
 407             return file;
 408         } catch (SecurityException se) {
 409             return null;
 410         }
 411     }
 412 
 413     private File[] checkFiles(File[] files) {


< prev index next >