示例#1
0
 public NSImage iconForPath(final Path item, final Integer size, final boolean overlay) {
   if (item.attributes().isSymbolicLink()) {
     final NSImage badge = this.iconForName("aliasbadge.tiff", size);
     badge.setName("aliasbadge");
     if (item.attributes().isDirectory()) {
       return this.iconForFolder(badge, size);
     }
     return this.iconForExtension(badge, item.getExtension(), size);
   }
   if (item.attributes().isFile()) {
     if (StringUtils.isEmpty(item.getExtension())) {
       if (item.attributes().getPermission().isExecutable()) {
         return this.iconForName("executable.tiff", size);
       }
     }
     return this.iconForExtension(item.getExtension(), size);
   }
   if (item.attributes().isVolume()) {
     return this.iconForName(item.getHost().getProtocol().disk(), size);
   }
   if (item.attributes().isDirectory()) {
     if (overlay) {
       if (!item.attributes().getPermission().isExecutable()) {
         final NSImage badge = this.iconForName("privatefolderbadge.tiff", size);
         badge.setName("privatefolderbadge");
         return this.iconForFolder(badge, size);
       }
       if (!item.attributes().getPermission().isReadable()) {
         if (item.attributes().getPermission().isWritable()) {
           final NSImage badge = this.iconForName("dropfolderbadge.tiff", size);
           badge.setName("dropfolderbadge");
           return this.iconForFolder(badge, size);
         }
       }
       if (!item.attributes().getPermission().isWritable()) {
         final NSImage badge = this.iconForName("readonlyfolderbadge.tiff", size);
         badge.setName("readonlyfolderbadge");
         return this.iconForFolder(badge, size);
       }
     }
     return this.iconForFolder(size);
   }
   return this.iconForName("notfound.tiff", size);
 }
示例#2
0
 /**
  * @param name When looking for files in the application bundle, it is better (but not required)
  *     to include the filename extension in the name parameter
  * @param width Requested size
  * @param height Requested size
  * @return Cached icon
  * @see NSImage#imageNamed(String)
  * @see #convert(ch.cyberduck.ui.cocoa.application.NSImage, Integer, Integer)
  */
 protected NSImage iconForName(final String name, final Integer width, final Integer height) {
   NSImage image = this.load(name, width);
   if (null == image) {
     if (name.startsWith("/")) {
       image = NSImage.imageWithContentsOfFile(name);
     } else {
       image = NSImage.imageNamed(name);
     }
     if (null == image) {
       log.warn(String.format("No icon named %s", name));
       this.put(name, null, width);
     } else {
       // You can clear an image object from the cache explicitly by passing nil for the image
       // name.
       image.setName(null);
       this.put(name, this.convert(image, width, height), width);
     }
   }
   return image;
 }