本文整理了Java中org.eclipse.jface.resource.ResourceManager.get
方法的一些代码示例,展示了ResourceManager.get
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ResourceManager.get
方法的具体详情如下:
包路径:org.eclipse.jface.resource.ResourceManager
类名称:ResourceManager
方法名:get
[英]Returns a previously-allocated resource or allocates a new one if none exists yet. The resource will remain allocated for at least the lifetime of this resource manager. If necessary, the resource will be deallocated automatically when the resource manager is disposed.
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 may be downcast to Image.
This method should only be used for resources that should remain allocated for the lifetime of the resource manager. To allocate shorter-lived resources, manage them with create
, and destroy
rather than this method.
This method should never be called on the global resource manager, since all resources will remain allocated for the lifetime of the app and will be effectively leaked.
[中]返回以前分配的资源,如果还不存在,则分配新资源。资源将至少在此资源管理器的生命周期内保持分配状态。如有必要,在释放资源管理器时,将自动释放资源。
此方法返回的资源是引用计数的,可以在内部与其他资源管理器共享。决不能在ResourceManager框架之外处理它们,否则会导致共享它们的其他代码出现异常。例如,永远不要给组织打电话。日食swt。图样资源#dispose()处理从此方法返回的任何内容。
调用者可以安全地将结果向下转换为与描述符关联的资源类型。例如,当给定ImageDescriptor时,此方法的返回值可能向下转换为Image。
此方法应仅用于在资源管理器的生命周期内保持分配的资源。要分配寿命较短的资源,请使用create
和destroy
来管理它们,而不是使用此方法。
永远不要在全局资源管理器上调用此方法,因为在应用程序的生命周期内,所有资源都将保持分配状态,并且会被有效泄漏。
代码示例来源:origin: org.eclipse.egit/ui
public Image getImage(Object element) {
String comment = ((ReflogEntry) element).getComment();
if (comment.startsWith("commit:") || comment.startsWith("commit (initial):")) //$NON-NLS-1$ //$NON-NLS-2$
return (Image) resourceManager.get(UIIcons.COMMIT);
if (comment.startsWith("commit (amend):")) //$NON-NLS-1$
return (Image) resourceManager.get(UIIcons.AMEND_COMMIT);
if (comment.startsWith("pull")) //$NON-NLS-1$
return (Image) resourceManager.get(UIIcons.PULL);
if (comment.startsWith("clone")) //$NON-NLS-1$
return (Image) resourceManager.get(UIIcons.CLONEGIT);
if (comment.startsWith("rebase")) //$NON-NLS-1$
return (Image) resourceManager.get(UIIcons.REBASE);
if (comment.startsWith("merge")) //$NON-NLS-1$
return (Image) resourceManager.get(UIIcons.MERGE);
if (comment.startsWith("fetch")) //$NON-NLS-1$
return (Image) resourceManager.get(UIIcons.FETCH);
if (comment.startsWith("branch")) //$NON-NLS-1$
return (Image) resourceManager.get(UIIcons.CREATE_BRANCH);
if (comment.startsWith("checkout")) //$NON-NLS-1$
return (Image) resourceManager.get(UIIcons.CHECKOUT);
return null;
}
代码示例来源:origin: org.eclipse.egit/ui
private Image getDecoratedImage(Image base, ImageDescriptor decorator) {
DecorationOverlayIcon decorated = new DecorationOverlayIcon(base,
decorator, IDecoration.BOTTOM_RIGHT);
return (Image) this.resourceManager.get(decorated);
}
代码示例来源:origin: org.eclipse.egit/ui
public Image getImage(final Object element) {
final FileDiff c = (FileDiff) element;
return (Image) resourceManager.get(c.getImageDescriptor(c));
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench
@Override
public Image getImage(Object element) {
IEditorDescriptor d = (IEditorDescriptor) element;
return (Image) resourceManager.get(d.getImageDescriptor());
}
});
代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench
@Override
public Image getImage(Object element) {
ImageDescriptor imageDescriptor = ((WorkingSetDescriptor) element)
.getIcon();
return imageDescriptor == null ? null : (Image) images
.get(imageDescriptor);
}
});
代码示例来源:origin: org.eclipse.egit/ui
private Image getDecoratedImage(Image base, ImageDescriptor decorator) {
DecorationOverlayIcon decorated = new DecorationOverlayIcon(base,
decorator, IDecoration.BOTTOM_RIGHT);
return (Image) this.resourceManager.get(decorated);
}
代码示例来源:origin: org.eclipse.egit/ui
private Image getDecoratedImage(Image base, String teamImageId) {
ImageDescriptor overlay = TeamImages.getImageDescriptor(teamImageId);
DecorationOverlayIcon decorated = new DecorationOverlayIcon(base,
overlay, IDecoration.BOTTOM_LEFT);
return (Image) this.resourceManager.get(decorated);
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench
@Override
public Image getImage(Object object) {
Assert.isTrue(object instanceof IWorkingSet);
IWorkingSet workingSet = (IWorkingSet) object;
ImageDescriptor imageDescriptor = workingSet.getImageDescriptor();
if (imageDescriptor == null) {
return null;
}
Image icon = (Image) images.get(imageDescriptor);
return icon;
}
代码示例来源:origin: org.eclipse.egit/ui
private Image getEditorImage(CommitItem item) {
if (!item.submodule) {
Image image = DEFAULT;
String name = new Path(item.path).lastSegment();
if (name != null) {
ImageDescriptor descriptor = PlatformUI.getWorkbench()
.getEditorRegistry().getImageDescriptor(name);
image = (Image) this.resourceManager.get(descriptor);
}
return image;
} else
return SUBMODULE;
}
代码示例来源:origin: org.eclipse.egit/ui
private Image getEditorImage(StagingEntry diff) {
if (diff.isSubmodule())
return SUBMODULE;
Image image = DEFAULT;
String name = new Path(diff.getPath()).lastSegment();
if (name != null) {
ImageDescriptor descriptor = PlatformUI.getWorkbench()
.getEditorRegistry().getImageDescriptor(name);
image = (Image) this.resourceManager.get(descriptor);
}
return image;
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench
@Override
public Font getFont(Object element) {
IWorkbenchAdapter2 adapter = getAdapter2(element);
if (adapter == null) {
return null;
}
FontData descriptor = adapter.getFont(element);
if (descriptor == null) {
return null;
}
return (Font) getResourceManager().get(
FontDescriptor.createFrom(descriptor));
}
代码示例来源:origin: org.eclipse.neoscada.chart/org.eclipse.scada.chart.swt
@Override
public void setForeground ( final RGB color )
{
if ( color != null )
{
this.gc.setForeground ( (Color)this.resourceManager.get ( ColorDescriptor.createFrom ( color ) ) );
}
else
{
this.gc.setForeground ( this.gc.getDevice ().getSystemColor ( SWT.COLOR_WIDGET_FOREGROUND ) );
}
}
代码示例来源:origin: org.eclipse.neoscada.chart/org.eclipse.scada.chart.swt
@Override
public void setBackground ( final RGB color )
{
if ( color != null )
{
this.gc.setBackground ( (Color)this.resourceManager.get ( ColorDescriptor.createFrom ( color ) ) );
}
else
{
this.gc.setBackground ( this.gc.getDevice ().getSystemColor ( SWT.COLOR_WIDGET_BACKGROUND ) );
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench
@Override
public final Image getImage(Object element) {
//obtain the base image by querying the element
IWorkbenchAdapter adapter = getAdapter(element);
if (adapter == null) {
return null;
}
ImageDescriptor descriptor = adapter.getImageDescriptor(element);
if (descriptor == null) {
return null;
}
//add any annotations to the image descriptor
descriptor = decorateImage(descriptor, element);
return (Image) getResourceManager().get(descriptor);
}
代码示例来源:origin: de.dentrassi.eclipse.neoscada.chart/org.eclipse.scada.chart.swt
@Override
public void setBackground ( final RGB color )
{
if ( color != null )
{
this.gc.setBackground ( (Color)this.resourceManager.get ( ColorDescriptor.createFrom ( color ) ) );
}
else
{
this.gc.setBackground ( this.gc.getDevice ().getSystemColor ( SWT.COLOR_WIDGET_BACKGROUND ) );
}
}
代码示例来源:origin: de.dentrassi.eclipse.neoscada.chart/org.eclipse.scada.chart.swt
@Override
public void setForeground ( final RGB color )
{
if ( color != null )
{
this.gc.setForeground ( (Color)this.resourceManager.get ( ColorDescriptor.createFrom ( color ) ) );
}
else
{
this.gc.setForeground ( this.gc.getDevice ().getSystemColor ( SWT.COLOR_WIDGET_FOREGROUND ) );
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench
private Color getColor(Object element, boolean forground) {
IWorkbenchAdapter2 adapter = getAdapter2(element);
if (adapter == null) {
return null;
}
RGB descriptor = forground ? adapter.getForeground(element) : adapter
.getBackground(element);
if (descriptor == null) {
return null;
}
return (Color) getResourceManager().get(
ColorDescriptor.createFrom(descriptor));
}
}
代码示例来源:origin: org.eclipse.egit/ui
.getEditorRegistry()
.getImageDescriptor(((File) object).getName());
return decorateImage((Image) resourceManager.get(descriptor),
element);
内容来源于网络,如有侵权,请联系作者删除!