1 11 package org.eclipse.jface.resource; 12 13 import org.eclipse.swt.events.DisposeEvent; 14 import org.eclipse.swt.events.DisposeListener; 15 import org.eclipse.swt.graphics.Device; 16 import org.eclipse.swt.graphics.Image; 17 import org.eclipse.swt.widgets.Control; 18 19 20 33 public final class LocalResourceManager extends AbstractResourceManager { 34 35 private ResourceManager parentRegistry; 36 37 43 public LocalResourceManager(ResourceManager parentRegistry) { 44 this.parentRegistry = parentRegistry; 45 } 46 47 57 public LocalResourceManager(ResourceManager parentRegistry, Control owner) { 58 this(parentRegistry); 59 60 owner.addDisposeListener(new DisposeListener() { 61 64 public void widgetDisposed(DisposeEvent e) { 65 LocalResourceManager.this.dispose(); 66 } 67 }); 68 } 69 70 73 public Device getDevice() { 74 return parentRegistry.getDevice(); 75 } 76 77 80 protected Object allocate(DeviceResourceDescriptor descriptor) 81 throws DeviceResourceException { 82 return parentRegistry.create(descriptor); 83 } 84 85 88 protected void deallocate(Object resource, 89 DeviceResourceDescriptor descriptor) { 90 91 parentRegistry.destroy(descriptor); 92 } 93 94 97 protected Image getDefaultImage() { 98 return parentRegistry.getDefaultImage(); 99 } 100 } 101 | Popular Tags |