1 11 package org.eclipse.ui.internal.about; 12 13 import java.io.IOException ; 14 import java.io.InputStream ; 15 import java.net.URL ; 16 import java.util.zip.CRC32 ; 17 import java.util.zip.CheckedInputStream ; 18 19 import org.eclipse.core.runtime.IBundleGroup; 20 import org.eclipse.jface.resource.ImageDescriptor; 21 import org.eclipse.ui.branding.IBundleGroupConstants; 22 23 27 public class AboutBundleGroupData extends AboutData { 28 private IBundleGroup bundleGroup; 29 30 private URL licenseUrl; 31 32 private URL featureImageUrl; 33 34 private Long featureImageCrc; 35 36 private ImageDescriptor featureImage; 37 38 public AboutBundleGroupData(IBundleGroup bundleGroup) { 39 super(bundleGroup.getProviderName(), bundleGroup.getName(), bundleGroup 40 .getVersion(), bundleGroup.getIdentifier()); 41 this.bundleGroup = bundleGroup; 42 } 43 44 public IBundleGroup getBundleGroup() { 45 return bundleGroup; 46 } 47 48 public URL getLicenseUrl() { 49 if (licenseUrl == null) { 50 licenseUrl = getURL(bundleGroup 51 .getProperty(IBundleGroupConstants.LICENSE_HREF)); 52 } 53 54 return licenseUrl; 55 } 56 57 public URL getFeatureImageUrl() { 58 if (featureImageUrl == null) { 59 featureImageUrl = getURL(bundleGroup 60 .getProperty(IBundleGroupConstants.FEATURE_IMAGE)); 61 } 62 return featureImageUrl; 63 } 64 65 public ImageDescriptor getFeatureImage() { 66 if (featureImage == null) { 67 featureImage = getImage(getFeatureImageUrl()); 68 } 69 return featureImage; 70 } 71 72 public Long getFeatureImageCrc() { 73 if (featureImageCrc != null) { 74 return featureImageCrc; 75 } 76 77 URL url = getFeatureImageUrl(); 78 if (url == null) { 79 return null; 80 } 81 82 InputStream in = null; 84 try { 85 CRC32 checksum = new CRC32 (); 86 in = new CheckedInputStream (url.openStream(), checksum); 87 88 byte[] sink = new byte[1024]; 90 while (true) { 91 if (in.read(sink) <= 0) { 92 break; 93 } 94 } 95 96 featureImageCrc = new Long (checksum.getValue()); 97 return featureImageCrc; 98 99 } catch (IOException e) { 100 return null; 101 } finally { 102 if (in != null) { 103 try { 104 in.close(); 105 } catch (IOException e) { 106 } 108 } 109 } 110 } 111 112 public String getAboutText() { 113 return bundleGroup.getProperty(IBundleGroupConstants.ABOUT_TEXT); 114 } 115 } 116 | Popular Tags |