1 11 package org.eclipse.jface.resource; 12 13 import org.eclipse.swt.graphics.Device; 14 import org.eclipse.swt.graphics.Image; 15 16 31 public final class DeviceResourceManager extends AbstractResourceManager { 32 33 private Device device; 34 private Image missingImage; 35 36 39 public Device getDevice() { 40 return device; 41 } 42 43 48 public DeviceResourceManager(Device device) { 49 this.device = device; 50 } 51 52 55 protected Object allocate(DeviceResourceDescriptor descriptor) throws DeviceResourceException { 56 return descriptor.createResource(device); 57 } 58 59 62 protected void deallocate(Object resource, DeviceResourceDescriptor descriptor) { 63 descriptor.destroyResource(resource); 64 } 65 66 69 protected Image getDefaultImage() { 70 if (missingImage == null) { 71 missingImage = ImageDescriptor.getMissingImageDescriptor().createImage(); 72 } 73 return missingImage; 74 } 75 76 79 public void dispose() { 80 super.dispose(); 81 if (missingImage != null) { 82 missingImage.dispose(); 83 missingImage = null; 84 } 85 } 86 } 87 | Popular Tags |