1 11 package org.eclipse.ui.internal.misc; 12 13 import org.eclipse.jface.resource.ImageDescriptor; 14 import org.eclipse.swt.graphics.Image; 15 import org.eclipse.swt.graphics.ImageData; 16 import org.eclipse.swt.program.Program; 17 import org.eclipse.ui.ISharedImages; 18 import org.eclipse.ui.internal.WorkbenchImages; 19 20 24 public class ExternalProgramImageDescriptor extends ImageDescriptor { 25 26 public Program program; 27 28 32 public ExternalProgramImageDescriptor(Program program) { 33 this.program = program; 34 } 35 36 39 public boolean equals(Object o) { 40 if (!(o instanceof ExternalProgramImageDescriptor)) { 41 return false; 42 } 43 ExternalProgramImageDescriptor other = (ExternalProgramImageDescriptor) o; 44 45 String otherName = other.program.getName(); 47 if (otherName == null) { 48 return other.program.equals(program); 49 } else { 50 return otherName.equals(program.getName()); 51 } 52 } 53 54 58 public Image getImage() { 59 return createImage(); 60 } 61 62 66 public ImageData getImageData() { 67 ImageData data = null; 68 ImageData defaultImage = WorkbenchImages.getImageDescriptor( 69 ISharedImages.IMG_OBJ_FILE).getImageData(); 70 if (defaultImage == null) { 71 return null; 72 } 73 74 if (program == null || ((data = program.getImageData()) == null)) { 75 return defaultImage; 76 } 77 78 if (data.height > defaultImage.height 80 || data.width > defaultImage.width) { 81 return defaultImage; 82 } 83 84 return data; 85 } 86 87 90 public int hashCode() { 91 String programName = program.getName(); 92 if (programName == null) { 93 return program.hashCode(); 94 } else { 95 return programName.hashCode(); 96 } 97 } 98 } 99 | Popular Tags |