All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.jface.resource.DeviceResourceManager Maven / Gradle / Ivy

Go to download

JFace is a UI toolkit with classes for handling many common UI programming tasks. JFace is window-system-independent in both its API and implementation, and is designed to work with SWT without hiding it. JFace includes the usual UI toolkit components of image and font registries, text, dialog, preference and wizard frameworks, and progress reporting for long running operations. Two of its more interesting features are actions and viewers. The action mechanism allows user commands to be defined independently from their exact whereabouts in the UI. Viewers are model based adapters for certain SWT widgets, simplifying the presentation of application data structured as lists, tables or trees.

The newest version!
/*******************************************************************************
 * Copyright (c) 2004, 2006 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.jface.resource;

import org.eclipse.swt.graphics.Device;
import org.eclipse.swt.graphics.Image;

/**
 * Manages SWT resources for a particular device.
 *  
 * 

* IMPORTANT: in most cases clients should use a LocalResourceManager instead of a * DeviceResourceManager. To create a resource manager on a particular display, * use new LocalResourceManager(JFaceResources.getResources(myDisplay)). * DeviceResourceManager should only be used directly when managing * resources for a device other than a Display (such as a printer). *

* * @see LocalResourceManager * * @since 3.1 */ public final class DeviceResourceManager extends AbstractResourceManager { private Device device; private Image missingImage; /* (non-Javadoc) * @see org.eclipse.jface.resource.ResourceManager#getDevice() */ public Device getDevice() { return device; } /** * Creates a new registry for the given device. * * @param device device to manage */ public DeviceResourceManager(Device device) { this.device = device; } /* (non-Javadoc) * @see org.eclipse.jface.resource.AbstractResourceManager#allocate(org.eclipse.jface.resource.DeviceResourceDescriptor) */ protected Object allocate(DeviceResourceDescriptor descriptor) throws DeviceResourceException { return descriptor.createResource(device); } /* (non-Javadoc) * @see org.eclipse.jface.resource.AbstractResourceManager#deallocate(java.lang.Object, org.eclipse.jface.resource.DeviceResourceDescriptor) */ protected void deallocate(Object resource, DeviceResourceDescriptor descriptor) { descriptor.destroyResource(resource); } /* (non-Javadoc) * @see org.eclipse.jface.resource.ResourceManager#getDefaultImage() */ protected Image getDefaultImage() { if (missingImage == null) { missingImage = ImageDescriptor.getMissingImageDescriptor().createImage(); } return missingImage; } /* (non-Javadoc) * @see org.eclipse.jface.resource.AbstractResourceManager#dispose() */ public void dispose() { super.dispose(); if (missingImage != null) { missingImage.dispose(); missingImage = null; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy