1 11 package org.eclipse.debug.internal.ui.launchConfigurations; 12 13 14 import org.eclipse.debug.ui.DebugUITools; 15 import org.eclipse.debug.ui.IDebugUIConstants; 16 import org.eclipse.jface.resource.CompositeImageDescriptor; 17 import org.eclipse.swt.graphics.Image; 18 import org.eclipse.swt.graphics.ImageData; 19 import org.eclipse.swt.graphics.Point; 20 21 25 public class LaunchConfigurationTabImageDescriptor extends CompositeImageDescriptor { 26 27 28 public final static int ERROR= 0x001; 29 30 private Image fBaseImage; 31 private int fFlags; 32 private Point fSize; 33 34 41 public LaunchConfigurationTabImageDescriptor(Image baseImage, int flags) { 42 setBaseImage(baseImage); 43 setFlags(flags); 44 } 45 46 49 protected Point getSize() { 50 if (fSize == null) { 51 ImageData data= getBaseImage().getImageData(); 52 setSize(new Point(data.width, data.height)); 53 } 54 return fSize; 55 } 56 57 60 public boolean equals(Object object) { 61 if (!(object instanceof LaunchConfigurationTabImageDescriptor)){ 62 return false; 63 } 64 65 LaunchConfigurationTabImageDescriptor other= (LaunchConfigurationTabImageDescriptor)object; 66 return (getBaseImage().equals(other.getBaseImage()) && getFlags() == other.getFlags()); 67 } 68 69 72 public int hashCode() { 73 return getBaseImage().hashCode() | getFlags(); 74 } 75 76 79 protected void drawCompositeImage(int width, int height) { 80 ImageData bg= getBaseImage().getImageData(); 81 if (bg == null) { 82 bg= DEFAULT_IMAGE_DATA; 83 } 84 drawImage(bg, 0, 0); 85 drawOverlays(); 86 } 87 88 91 protected void drawOverlays() { 92 int flags= getFlags(); 93 ImageData data= null; 94 if ((flags & ERROR) != 0) { 95 data= DebugUITools.getImage(IDebugUIConstants.IMG_OVR_ERROR).getImageData(); 96 drawImage(data, 0, 0); 97 } 98 } 99 100 protected Image getBaseImage() { 101 return fBaseImage; 102 } 103 104 protected void setBaseImage(Image baseImage) { 105 fBaseImage = baseImage; 106 } 107 108 protected int getFlags() { 109 return fFlags; 110 } 111 112 protected void setFlags(int flags) { 113 fFlags = flags; 114 } 115 116 protected void setSize(Point size) { 117 fSize = size; 118 } 119 } 120 | Popular Tags |