本文整理了Java中org.eclipse.jface.resource.ResourceManager
类的一些代码示例,展示了ResourceManager
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ResourceManager
类的具体详情如下:
包路径:org.eclipse.jface.resource.ResourceManager
类名称:ResourceManager
[英]This class manages SWT resources. It manages reference-counted instances of resources such as Fonts, Images, and Colors, and allows them to be accessed using descriptors. Everything allocated through the registry should also be disposed through the registry. Since the resources are shared and reference counted, they should never be disposed directly.
ResourceManager handles correct allocation and disposal of resources. It differs from the various JFace Registry classes, which also map symbolic IDs onto resources. In general, you should use a Registry class to map IDs onto descriptors, and use a ResourceManager to convert the descriptors into real Images/Fonts/etc.
[中]这个类管理SWT资源。它管理字体、图像和颜色等资源的引用计数实例,并允许使用描述符访问它们。通过注册表分配的所有内容也应通过注册表进行处理。由于这些资源是共享的,并且引用是经过计算的,所以永远不应该直接处理它们。
ResourceManager处理资源的正确分配和处置。它不同于各种JFace注册表类,后者也将符号ID映射到资源上。通常,应该使用注册表类将ID映射到描述符,并使用ResourceManager将描述符转换为真实的图像/字体等。
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide
@Override
public void stop(BundleContext context) throws Exception {
super.stop(context);
if (resourceManager != null)
resourceManager.dispose();
}
代码示例来源:origin: org.eclipse.egit/ui
/**
* @param dimmedForegroundRgb the color used for as foreground color for "unhighlighted" entries
*/
public FileDiffLabelProvider(RGB dimmedForegroundRgb) {
dimmedForegroundColor = resourceManager.createColor(dimmedForegroundRgb);
}
代码示例来源:origin: org.eclipse.egit/ui
@Override
public Image getImage(Object element) {
return fImageCache.createImage(UIIcons.REPOSITORY);
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface
/**
* Creates an empty image registry using the given resource manager to allocate images.
*
* @param manager the resource manager used to allocate images
*
* @since 3.1
*/
public ImageRegistry(ResourceManager manager) {
Assert.isNotNull(manager);
Device dev = manager.getDevice();
if (dev instanceof Display) {
this.display = (Display)dev;
}
this.manager = manager;
manager.disposeExec(disposeRunnable);
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.jface
/**
* Disposes this image registry, disposing any images
* that were allocated for it, and clearing its entries.
*
* @since 3.1
*/
public void dispose() {
manager.cancelDisposeExec(disposeRunnable);
if (table != null) {
for (Entry entry : table.values()) {
if (entry.image != null) {
manager.destroyImage(entry.descriptor);
}
}
table = null;
}
display = null;
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench
private Image findOrCreateImage(ImageDescriptor imageDescriptor,
ResourceManager resourceManager) {
if (imageDescriptor == null) {
return null;
}
Image image = (Image) resourceManager.find(imageDescriptor);
if (image == null) {
try {
image = resourceManager.createImage(imageDescriptor);
} catch (DeviceResourceException e) {
WorkbenchPlugin.log(e);
}
}
return image;
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.jface
@Override
public Image getDefaultPageImage() {
if (defaultImage == null) {
defaultImage = JFaceResources.getResources().createImageWithDefault(defaultImageDescriptor);
}
return defaultImage;
}
代码示例来源:origin: de.dentrassi.eclipse.neoscada.hmi/org.eclipse.scada.core.ui.styles
private void refresh ()
{
if ( this.color != null )
{
// we may not dispose, the manager has to do that
this.color = null;
}
if ( this.activeColor != null )
{
this.manager.destroyColor ( this.activeColor );
this.activeColor = null;
}
this.activeColor = JFaceResources.getColorRegistry ().getColorDescriptor ( this.name, this.defaultColor );
if ( this.activeColor != null )
{
this.color = this.manager.createColor ( this.activeColor );
}
}
代码示例来源:origin: org.eclipse.neoscada.hmi/org.eclipse.scada.vi.ui.draw2d
public void setImage ( final String uri )
{
if ( this.currentImage != null )
{
this.manager.destroyImage ( this.currentImage );
this.currentImage = null;
}
if ( uri == null || uri.isEmpty () )
{
this.figure.setIcon ( null );
}
else
{
try
{
final URL url = new URL ( this.symbolLoader.resolveUri ( uri ) );
this.figure.setIcon ( this.manager.createImageWithDefault ( this.currentImage = ImageDescriptor.createFromURL ( url ) ) );
this.factoryContext.loadedResource ( URI.createURI ( url.toString () ) );
}
catch ( final MalformedURLException e )
{
this.figure.setIcon ( this.manager.createImageWithDefault ( ImageDescriptor.getMissingImageDescriptor () ) );
}
}
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide
@Override
public void dispose() {
if (image != null) {
JFaceResources.getResources().destroyImage(desc);
image = null;
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.jface
@Override
protected Object allocate(DeviceResourceDescriptor descriptor)
throws DeviceResourceException {
return parentRegistry.create(descriptor);
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface
entry.descriptor = new OriginalImageDescriptor(image, manager.getDevice());
manager.create(entry.descriptor);
} catch (DeviceResourceException e) {
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.jface
public Device getDevice() {
return parentRegistry.getDevice();
}
代码示例来源:origin: de.dentrassi.eclipse.neoscada.chart/org.eclipse.scada.chart.swt
private Font createFont ( final ResourceManager resourceManager )
{
final Font defaultFont = resourceManager.getDevice ().getSystemFont ();
if ( defaultFont == null )
{
return null;
}
final FontData fd[] = FontDescriptor.copy ( defaultFont.getFontData () );
if ( fd == null )
{
return null;
}
for ( final FontData f : fd )
{
if ( this.fontSize > 0 )
{
f.setHeight ( this.fontSize );
}
}
return resourceManager.createFont ( FontDescriptor.createFrom ( fd ) );
}
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.jface
/**
* Undoes everything that was done by a call to {@link #createColor(RGB)}.
*
* @since 1.0
*
* @param descriptor RGB value of the color to dispose
*/
public final void destroyColor(RGB descriptor) {
destroyColor(new RGBColorDescriptor(descriptor));
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface
@Override
public Image getDefaultPageImage() {
if (defaultImage == null) {
defaultImage = JFaceResources.getResources().createImageWithDefault(defaultImageDescriptor);
}
return defaultImage;
}
代码示例来源:origin: org.eclipse.neoscada.hmi/org.eclipse.scada.core.ui.styles
private void refresh ()
{
if ( this.color != null )
{
// we may not dispose, the manager has to do that
this.color = null;
}
if ( this.activeColor != null )
{
this.manager.destroyColor ( this.activeColor );
this.activeColor = null;
}
this.activeColor = JFaceResources.getColorRegistry ().getColorDescriptor ( this.name, this.defaultColor );
if ( this.activeColor != null )
{
this.color = this.manager.createColor ( this.activeColor );
}
}
代码示例来源:origin: de.dentrassi.eclipse.neoscada.hmi/org.eclipse.scada.vi.ui.draw2d
public void setImage ( final String uri )
{
if ( this.currentImage != null )
{
this.manager.destroyImage ( this.currentImage );
this.currentImage = null;
}
if ( uri == null || uri.isEmpty () )
{
this.figure.setIcon ( null );
}
else
{
try
{
final URL url = new URL ( this.symbolLoader.resolveUri ( uri ) );
this.figure.setIcon ( this.manager.createImageWithDefault ( this.currentImage = ImageDescriptor.createFromURL ( url ) ) );
this.factoryContext.loadedResource ( URI.createURI ( url.toString () ) );
}
catch ( final MalformedURLException e )
{
this.figure.setIcon ( this.manager.createImageWithDefault ( ImageDescriptor.getMissingImageDescriptor () ) );
}
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench
/**
* The <code>IntroPart</code> implementation of this
* <code>IIntroPart</code> method disposes the title image loaded by
* <code>setInitializationData</code>. Subclasses may extend.
*/
@Override
public void dispose() {
if (titleImage != null) {
JFaceResources.getResources().destroyImage(imageDescriptor);
titleImage = null;
}
// Clear out the property change listeners as we
// should not be notifying anyone after the part
// has been disposed.
clearListeners();
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface
@Override
protected Object allocate(DeviceResourceDescriptor descriptor)
throws DeviceResourceException {
return parentRegistry.create(descriptor);
}
内容来源于网络,如有侵权,请联系作者删除!