1 11 package org.eclipse.jdt.internal.debug.ui; 12 13 14 import org.eclipse.jface.resource.CompositeImageDescriptor; 15 import org.eclipse.jface.resource.ImageDescriptor; 16 import org.eclipse.swt.graphics.ImageData; 17 import org.eclipse.swt.graphics.Point; 18 19 23 public class JDIImageDescriptor extends CompositeImageDescriptor { 24 25 26 public final static int IS_OUT_OF_SYNCH= 0x0001; 27 28 public final static int MAY_BE_OUT_OF_SYNCH= 0x0002; 29 30 public final static int INSTALLED= 0x0004; 31 32 public final static int ENTRY= 0x0008; 33 34 public final static int EXIT= 0x0010; 35 36 public final static int ENABLED= 0x0020; 37 38 public final static int CONDITIONAL= 0x0040; 39 40 public final static int CAUGHT= 0x0080; 41 42 public final static int UNCAUGHT= 0x0100; 43 44 public final static int SCOPED= 0x0200; 45 46 47 public final static int OWNS_MONITOR= 0x0400; 48 49 public final static int OWNED_MONITOR= 0x0800; 50 51 public final static int CONTENTED_MONITOR= 0x1000; 52 53 public final static int IN_CONTENTION_FOR_MONITOR= 0x2000; 54 55 public final static int IN_DEADLOCK= 0x8000; 56 57 58 public final static int SYNCHRONIZED= 0x4000; 59 60 private ImageDescriptor fBaseImage; 61 private int fFlags; 62 private Point fSize; 63 64 71 public JDIImageDescriptor(ImageDescriptor baseImage, int flags) { 72 setBaseImage(baseImage); 73 setFlags(flags); 74 } 75 76 79 protected Point getSize() { 80 if (fSize == null) { 81 ImageData data= getBaseImage().getImageData(); 82 setSize(new Point(data.width, data.height)); 83 } 84 return fSize; 85 } 86 87 90 public boolean equals(Object object) { 91 if (!(object instanceof JDIImageDescriptor)){ 92 return false; 93 } 94 95 JDIImageDescriptor other= (JDIImageDescriptor)object; 96 return (getBaseImage().equals(other.getBaseImage()) && getFlags() == other.getFlags()); 97 } 98 99 102 public int hashCode() { 103 return getBaseImage().hashCode() | getFlags(); 104 } 105 106 109 protected void drawCompositeImage(int width, int height) { 110 ImageData bg= getBaseImage().getImageData(); 111 if (bg == null) { 112 bg= DEFAULT_IMAGE_DATA; 113 } 114 drawImage(bg, 0, 0); 115 drawOverlays(); 116 } 117 118 private ImageData getImageData(String imageDescriptorKey) { 119 return JavaDebugImages.getImageDescriptor(imageDescriptorKey).getImageData(); 120 } 121 124 protected void drawOverlays() { 125 int flags= getFlags(); 126 int x= 0; 127 int y= 0; 128 ImageData data= null; 129 if ((flags & IS_OUT_OF_SYNCH) != 0) { 130 x= getSize().x; 131 y= 0; 132 data= getImageData(JavaDebugImages.IMG_OVR_OUT_OF_SYNCH); 133 x -= data.width; 134 drawImage(data, x, y); 135 } else if ((flags & MAY_BE_OUT_OF_SYNCH) != 0) { 136 x= getSize().x; 137 y= 0; 138 data= getImageData(JavaDebugImages.IMG_OVR_MAY_BE_OUT_OF_SYNCH); 139 x -= data.width; 140 drawImage(data, x, y); 141 } else if ((flags & SYNCHRONIZED) != 0) { 142 x= getSize().x; 143 y= 0; 144 data= getImageData(JavaDebugImages.IMG_OVR_SYNCHRONIZED); 145 x -= data.width; 146 drawImage(data, x, y); 147 } else { 148 if ((flags & IN_DEADLOCK) != 0) { 149 x= 0; 150 y= 0; 151 data= getImageData(JavaDebugImages.IMG_OVR_IN_DEADLOCK); 152 drawImage(data, x, y); 153 } 154 if ((flags & OWNED_MONITOR) != 0) { 155 x= getSize().x; 156 y= getSize().y; 157 data= getImageData(JavaDebugImages.IMG_OVR_OWNED); 158 x -= data.width; 159 y -= data.height; 160 drawImage(data, x, y); 161 } else if ((flags & CONTENTED_MONITOR) != 0) { 162 x= getSize().x; 163 y= getSize().y; 164 data= getImageData(JavaDebugImages.IMG_OVR_IN_CONTENTION); 165 x -= data.width; 166 y -= data.height; 167 drawImage(data, x, y); 168 } else if ((flags & OWNS_MONITOR) != 0) { 169 x= getSize().x; 170 y= 0; 171 data= getImageData(JavaDebugImages.IMG_OVR_OWNS_MONITOR); 172 x -= data.width; 173 drawImage(data, x, y); 174 } else if ((flags & IN_CONTENTION_FOR_MONITOR) != 0) { 175 x= getSize().x; 176 y= 0; 177 data= getImageData(JavaDebugImages.IMG_OVR_IN_CONTENTION_FOR_MONITOR); 178 x -= data.width; 179 drawImage(data, x, y); 180 } else { 181 drawBreakpointOverlays(); 182 } 183 } 184 } 185 186 protected void drawBreakpointOverlays() { 187 int flags= getFlags(); 188 int x= 0; 189 int y= 0; 190 ImageData data= null; 191 if ((flags & INSTALLED) != 0) { 192 x= 0; 193 y= getSize().y; 194 if ((flags & ENABLED) !=0) { 195 data= getImageData(JavaDebugImages.IMG_OVR_BREAKPOINT_INSTALLED); 196 } else { 197 data= getImageData(JavaDebugImages.IMG_OVR_BREAKPOINT_INSTALLED_DISABLED); 198 } 199 200 y -= data.height; 201 drawImage(data, x, y); 202 } 203 if ((flags & CAUGHT) != 0) { 204 if ((flags & ENABLED) !=0) { 205 data= getImageData(JavaDebugImages.IMG_OVR_CAUGHT_BREAKPOINT); 206 } else { 207 data= getImageData(JavaDebugImages.IMG_OVR_CAUGHT_BREAKPOINT_DISABLED); 208 } 209 x= 0; 210 y= 0; 211 drawImage(data, x, y); 212 } 213 if ((flags & UNCAUGHT) != 0) { 214 if ((flags & ENABLED) !=0) { 215 data= getImageData(JavaDebugImages.IMG_OVR_UNCAUGHT_BREAKPOINT); 216 } else { 217 data= getImageData(JavaDebugImages.IMG_OVR_UNCAUGHT_BREAKPOINT_DISABLED); 218 } 219 x= data.width; 220 y= data.height; 221 drawImage(data, x, y); 222 } 223 if ((flags & SCOPED) != 0) { 224 if ((flags & ENABLED) !=0) { 225 data= getImageData(JavaDebugImages.IMG_OVR_SCOPED_BREAKPOINT); 226 } else { 227 data= getImageData(JavaDebugImages.IMG_OVR_SCOPED_BREAKPOINT_DISABLED); 228 } 229 x= 0; 230 y= getSize().y; 231 y-= data.height; 232 drawImage(data, x, y); 233 } 234 if ((flags & CONDITIONAL) != 0) { 235 if ((flags & ENABLED) !=0) { 236 data= getImageData(JavaDebugImages.IMG_OVR_CONDITIONAL_BREAKPOINT); 237 } else { 238 data= getImageData(JavaDebugImages.IMG_OVR_CONDITIONAL_BREAKPOINT_DISABLED); 239 } 240 x= 0; 241 y= 0; 242 drawImage(data, x, y); 243 } 244 if ((flags & ENTRY) != 0) { 245 x= getSize().x; 246 y= 0; 247 if ((flags & ENABLED) !=0) { 248 data= getImageData(JavaDebugImages.IMG_OVR_METHOD_BREAKPOINT_ENTRY); 249 } else { 250 data= getImageData(JavaDebugImages.IMG_OVR_METHOD_BREAKPOINT_ENTRY_DISABLED); 251 } 252 x -= data.width; 253 x = x - 2; 254 drawImage(data, x, y); 255 } 256 if ((flags & EXIT) != 0){ 257 x= getSize().x; 258 y= getSize().y; 259 if ((flags & ENABLED) != 0) { 260 data= getImageData(JavaDebugImages.IMG_OVR_METHOD_BREAKPOINT_EXIT); 261 } else { 262 data= getImageData(JavaDebugImages.IMG_OVR_METHOD_BREAKPOINT_EXIT_DISABLED); 263 } 264 x -= data.width; 265 x = x - 2; 266 y -= data.height; 267 drawImage(data, x, y); 268 } 269 } 270 protected ImageDescriptor getBaseImage() { 271 return fBaseImage; 272 } 273 274 protected void setBaseImage(ImageDescriptor baseImage) { 275 fBaseImage = baseImage; 276 } 277 278 protected int getFlags() { 279 return fFlags; 280 } 281 282 protected void setFlags(int flags) { 283 fFlags = flags; 284 } 285 286 protected void setSize(Point size) { 287 fSize = size; 288 } 289 } 290 | Popular Tags |