org.eclipse.jface.resource.ResourceManager.create()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(9.8k)|赞(0)|评价(0)|浏览(77)

本文整理了Java中org.eclipse.jface.resource.ResourceManager.create方法的一些代码示例,展示了ResourceManager.create的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ResourceManager.create方法的具体详情如下:
包路径:org.eclipse.jface.resource.ResourceManager
类名称:ResourceManager
方法名:create

ResourceManager.create介绍

[英]Returns the resource described by the given descriptor. If the resource already exists, the reference count is incremented and the exiting resource is returned. Otherwise, a new resource is allocated. Every call to this method should have a corresponding call to #destroy(DeviceResourceDescriptor).

If the resource is intended to live for entire lifetime of the resource manager, a subsequent call to #destroy(DeviceResourceDescriptor) may be omitted and the resource will be cleaned up when the resource manager is disposed. This pattern is useful for short-lived LocalResourceManagers, but should never be used with the global resource manager since doing so effectively leaks the resource.

The resources returned from this method are reference counted and may be shared internally with other resource managers. They should never be disposed outside of the ResourceManager framework, or it will cause exceptions in other code that shares them. For example, never call org.eclipse.swt.graphics.Resource#dispose()on anything returned from this method.

Callers may safely downcast the result to the resource type associated with the descriptor. For example, when given an ImageDescriptor, the return value of this method will always be an Image.
[中]返回给定描述符描述的资源。如果资源已经存在,则会增加引用计数并返回现有资源。否则,将分配一个新资源。对该方法的每次调用都应该有对#destroy(DeviceResourceDescriptor)的相应调用。
如果资源打算在资源管理器的整个生命周期内使用,则可能会忽略对#destroy(DeviceResourceDescriptor)的后续调用,并且在释放资源管理器时将清理资源。此模式对于短期的LocalResourceManager很有用,但不应与全局资源管理器一起使用,因为这样做会有效地泄漏资源。
此方法返回的资源是引用计数的,可以在内部与其他资源管理器共享。决不能在ResourceManager框架之外处理它们,否则会导致共享它们的其他代码出现异常。例如,永远不要给组织打电话。日食swt。图样资源#dispose()处理从此方法返回的任何内容。
调用者可以安全地将结果向下转换为与描述符关联的资源类型。例如,当给定ImageDescriptor时,此方法的返回值将始终为图像。

代码示例

代码示例来源: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

@Override
protected Object allocate(DeviceResourceDescriptor descriptor)
    throws DeviceResourceException {
  return parentRegistry.create(descriptor);
}

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.jface

protected Object allocate(DeviceResourceDescriptor descriptor)
    throws DeviceResourceException {
  return parentRegistry.create(descriptor);
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface

/**
 * Returns the Font described by the given FontDescriptor. Any Font
 * allocated in this manner must be deallocated by calling disposeFont(...),
 * or by an eventual call to {@link #dispose()}.  The method {@link Font#dispose()}
 * must never be called directly on the returned font.
 *
 * @since 3.1
 *
 * @param descriptor description of the font to create
 * @return the Font described by the given descriptor
 * @throws DeviceResourceException if unable to create the font
 */
public final Font createFont(FontDescriptor descriptor) {
  return (Font)create(descriptor);
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface

/**
 * Returns the Font described by the given FontDescriptor. Any Font
 * allocated in this manner must be deallocated by calling disposeFont(...),
 * or by an eventual call to {@link #dispose()}.  The method {@link Font#dispose()}
 * must never be called directly on the returned font.
 *
 * @since 3.1
 *
 * @param descriptor description of the font to create
 * @return the Font described by the given descriptor
 * @throws DeviceResourceException if unable to create the font
 */
public final Font createFont(FontDescriptor descriptor) {
  return (Font)create(descriptor);
}

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.jface

/**
 * Returns the Font described by the given FontDescriptor. Any Font
 * allocated in this manner must be deallocated by calling disposeFont(...),
 * or by an eventual call to {@link #dispose()}.  The method {@link Font#dispose()}
 * must never be called directly on the returned font.
 * 
 * @since 1.0 
 *
 * @param descriptor description of the font to create
 * @return the Font described by the given descriptor
 * @throws DeviceResourceException if unable to create the font
 */
public final Font createFont(FontDescriptor descriptor) {
  return (Font)create(descriptor);
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface

/**
 * Allocates a color, given a color descriptor. Any color allocated in this
 * manner must be disposed by calling {@link #destroyColor(ColorDescriptor)},
 * or by an eventual call to {@link #dispose()}. {@link Color#dispose()} must
 * never been called directly on the returned color.
 *
 * @since 3.1
 *
 * @param descriptor descriptor for the color to create
 * @return the Color described by the given ColorDescriptor (not null)
 * @throws DeviceResourceException if unable to create the color
 */
public final Color createColor(ColorDescriptor descriptor) {
  return (Color)create(descriptor);
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface

/**
 * Allocates a color, given a color descriptor. Any color allocated in this
 * manner must be disposed by calling {@link #destroyColor(ColorDescriptor)},
 * or by an eventual call to {@link #dispose()}. {@link Color#dispose()} must
 * never been called directly on the returned color.
 *
 * @since 3.1
 *
 * @param descriptor descriptor for the color to create
 * @return the Color described by the given ColorDescriptor (not null)
 * @throws DeviceResourceException if unable to create the color
 */
public final Color createColor(ColorDescriptor descriptor) {
  return (Color)create(descriptor);
}

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.jface

/**
 * Allocates a color, given a color descriptor. Any color allocated in this
 * manner must be disposed by calling {@link #destroyColor(ColorDescriptor)}, 
 * or by an eventual call to {@link #dispose()}. {@link Color#dispose()} must
 * never been called directly on the returned color.
 * 
 * @since 1.0 
 *
 * @param descriptor descriptor for the color to create
 * @return the Color described by the given ColorDescriptor (not null)
 * @throws DeviceResourceException if unable to create the color
 */
public final Color createColor(ColorDescriptor descriptor) {
  return (Color)create(descriptor);
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface

/**
 * <p>Creates an image, given an image descriptor. Images allocated in this manner must
 * be disposed by {@link #destroyImage(ImageDescriptor)}, and never by calling
 * {@link Image#dispose()}.</p>
 *
 * <p>
 * If the image is intended to remain allocated for the lifetime of the ResourceManager,
 * the call to destroyImage may be omitted and the image will be cleaned up automatically
 * when the ResourceManager is disposed. This should only be done with short-lived ResourceManagers,
 * as doing so with the global manager effectively leaks the resource.
 * </p>
 *
 * @since 3.1
 *
 * @param descriptor descriptor for the image to create
 * @return the Image described by this descriptor (possibly shared by other equivalent
 * ImageDescriptors)
 * @throws DeviceResourceException if unable to allocate the Image
 */
public final Image createImage(ImageDescriptor descriptor) {
  // Assertion added to help diagnose client bugs.  See bug #83711 and bug #90454.
  Assert.isNotNull(descriptor);
  return (Image)create(descriptor);
}

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.jface

/**
 * <p>Creates an image, given an image descriptor. Images allocated in this manner must
 * be disposed by {@link #destroyImage(ImageDescriptor)}, and never by calling 
 * {@link Image#dispose()}.</p>
 * 
 * <p>
 * If the image is intended to remain allocated for the lifetime of the ResourceManager,
 * the call to destroyImage may be omitted and the image will be cleaned up automatically
 * when the ResourceManager is disposed. This should only be done with short-lived ResourceManagers,
 * as doing so with the global manager effectively leaks the resource.
 * </p>
 * 
 * @since 1.0 
 *
 * @param descriptor descriptor for the image to create
 * @return the Image described by this descriptor (possibly shared by other equivalent
 * ImageDescriptors)
 * @throws DeviceResourceException if unable to allocate the Image
 */
public final Image createImage(ImageDescriptor descriptor) {
  // Assertion added to help diagnose client bugs.  See bug #83711 and bug #90454.
  Assert.isNotNull(descriptor);
  
  return (Image)create(descriptor);
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface

/**
 * <p>Creates an image, given an image descriptor. Images allocated in this manner must
 * be disposed by {@link #destroyImage(ImageDescriptor)}, and never by calling
 * {@link Image#dispose()}.</p>
 *
 * <p>
 * If the image is intended to remain allocated for the lifetime of the ResourceManager,
 * the call to destroyImage may be omitted and the image will be cleaned up automatically
 * when the ResourceManager is disposed. This should only be done with short-lived ResourceManagers,
 * as doing so with the global manager effectively leaks the resource.
 * </p>
 *
 * @since 3.1
 *
 * @param descriptor descriptor for the image to create
 * @return the Image described by this descriptor (possibly shared by other equivalent
 * ImageDescriptors)
 * @throws DeviceResourceException if unable to allocate the Image
 */
public final Image createImage(ImageDescriptor descriptor) {
  // Assertion added to help diagnose client bugs.  See bug #83711 and bug #90454.
  Assert.isNotNull(descriptor);
  return (Image)create(descriptor);
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface

result = create(descriptor);

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.m2e.core.ui

@SuppressWarnings("deprecation")
public Image getImage(Object element) {
 if(element instanceof IWorkingSet) {
  ImageDescriptor imageDescriptor = ((IWorkingSet) element).getImage();
  if(imageDescriptor != null) {
   try {
    return (Image) images.create(imageDescriptor);
   } catch(DeviceResourceException ex) {
    return null;
   }
  }
 }
 return super.getImage(element);
}

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.jface

manager.create(entry.descriptor);
} catch (DeviceResourceException e) {

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface

manager.create(entry.descriptor);
} catch (DeviceResourceException e) {

代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench

newResource = newDescriptor == null ? null : mgr.create(newDescriptor);
} catch (DeviceResourceException e1) {
  WorkbenchPlugin.log(e1);

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface

return (Image) create(descriptor);
} catch (DeviceResourceException e) {
  Policy.getLog().log(

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.jface

return (Image) create(descriptor);
} catch (DeviceResourceException e) {
  Policy.getLog().log(

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface

return (Image) create(descriptor);
} catch (DeviceResourceException e) {
  Policy.getLog().log(

相关文章