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

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

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

ResourceManager.createImageWithDefault介绍

[英]Creates an image, given an image descriptor. Images allocated in this manner must be disposed by #destroyImage(ImageDescriptor), and never by calling Image#dispose().
[中]在给定图像描述符的情况下创建图像。以这种方式分配的图像必须由#destroyImage(ImageDescriptor)处理,而决不能通过调用Image#dispose()处理。

代码示例

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

public Image getDefaultPageImage() {
  if (defaultImage == null) {
    defaultImage = JFaceResources.getResources().createImageWithDefault(defaultImageDescriptor);
  }
  return defaultImage;
}

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

@Override
public Image getDefaultPageImage() {
  if (defaultImage == null) {
    defaultImage = JFaceResources.getResources().createImageWithDefault(defaultImageDescriptor);
  }
  return defaultImage;
}

代码示例来源: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.scout.sdk.deps/org.eclipse.ui.ide

/**
 * Get the IDE image at path.
 *
 * @param constantName
 * @return Image
 */
private static Image getIDEImage(String constantName) {
  return JFaceResources.getResources().createImageWithDefault(
      IDEInternalWorkbenchImages.getImageDescriptor(constantName));
}

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

public BookmarkLabelProvider(BookmarkNavigator view) {
  desc = IDEWorkbenchPlugin.getIDEImageDescriptor("obj16/bkmrk_tsk.png"); //$NON-NLS-1$
  image = JFaceResources.getResources().createImageWithDefault(desc);
}

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

/**
 * Get the IDE image at path.
 *
 * @param path
 * @return Image
 */
private static Image getIDEImage(String constantName) {
  return JFaceResources.getResources().createImageWithDefault(
      IDEInternalWorkbenchImages.getImageDescriptor(constantName));
}

代码示例来源:origin: de.dentrassi.eclipse.neoscada.hmi/org.eclipse.scada.vi.ui.user

private Image createImage ( final String key )
{
  try
  {
    final String uri = Activator.getDefault ().getPreferenceStore ().getString ( key );
    return this.manager.createImageWithDefault ( ImageDescriptor.createFromURL ( new URL ( uri ) ) );
  }
  catch ( final MalformedURLException e )
  {
    return this.manager.createImageWithDefault ( ImageDescriptor.getMissingImageDescriptor () );
  }
}

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

entry.image = manager.createImageWithDefault(entry.descriptor);

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

/**
 * Create the image at the supplied path.
 *
 * @param completeImagePath
 * @param manager the resource manager to allocate the image in
 * @return Image or <code>null</code>.
 */
static final Image createImage(String completeImagePath, ResourceManager manager) {
  URL url = BundleUtility.find(IDEWorkbenchPlugin.getDefault()
      .getBundle().getSymbolicName(), completeImagePath);
  if (url == null)
    return null;
  return manager.createImageWithDefault(ImageDescriptor.createFromURL(url));
}

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

entry.image = manager.createImageWithDefault(entry.descriptor);

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

entry.image = manager.createImageWithDefault(entry.descriptor);

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

/**
 * The <code>IntroPart</code> implementation of this
 * <code>IExecutableExtension</code> records the configuration element in
 * and internal state variable (accessible via <code>getConfigElement</code>).
 * It also loads the title image, if one is specified in the configuration
 * element. Subclasses may extend.
 *
 * Should not be called by clients. It is called by the core plugin when
 * creating this executable extension.
 */
@Override
public void setInitializationData(IConfigurationElement cfig,
    String propertyName, Object data) {
  // Save config element.
  configElement = cfig;
  titleLabel = cfig.getAttribute(IWorkbenchRegistryConstants.ATT_LABEL);
  // Icon.
  String strIcon = cfig.getAttribute(IWorkbenchRegistryConstants.ATT_ICON);
  if (strIcon == null) {
    return;
  }
  imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin(
      configElement.getContributor().getName(), strIcon);
  if (imageDescriptor == null) {
    return;
  }
  Image image = JFaceResources.getResources().createImageWithDefault(imageDescriptor);
  titleImage = image;
}

代码示例来源: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.scout.sdk.deps/org.eclipse.ui.ide

/**
 * @return The image to be displayed in the column header for this field or
 *         <code>null<code>.
 */
public Image getColumnHeaderImage() {
  String path = configurationElement
      .getAttribute(MarkerSupportInternalUtilities.ATTRIBUTE_ICON);
  if (path == null)
    return null;
  URL url = BundleUtility.find(configurationElement.getContributor()
      .getName(), path);
  if (url == null)
    return null;
  return getImageManager().createImageWithDefault(
      ImageDescriptor.createFromURL(url));
}

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

titleImage = JFaceResources.getResources().createImageWithDefault(imageDescriptor);

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

/**
 * Return the image for the receiver.
 *
 * @param item
 * @return Image or <code>null</code>
 */
private Image getImage(MarkerItem item) {
  MarkerSupportItem supportItem = (MarkerSupportItem) item;
  int severity = -1;
  if (supportItem.isConcrete())
    severity = MarkerSupportInternalUtilities.getSeverity(item);
  else
    severity = ((MarkerCategory) supportItem).getHighestSeverity();
  if (severity >= 0)
    return MarkerSupportInternalUtilities.getSeverityImage(severity);
  try {
    if (supportItem.isConcrete())
      return null;
    return JFaceResources
        .getResources()
        .createImageWithDefault(
            IDEInternalWorkbenchImages
                .getImageDescriptor(IDEInternalWorkbenchImages.IMG_ETOOL_PROBLEM_CATEGORY));
  } catch (DeviceResourceException e) {
    return null;
  }
}

代码示例来源:origin: de.dentrassi.eclipse.neoscada.hmi/org.eclipse.scada.vi.ui.user

public DebugHandler ( final Composite parent, final ViewManager viewManager )
{
  this.viewManager = viewManager;
  this.label = new Label ( parent, SWT.NONE );
  final ResourceManager manager = new LocalResourceManager ( JFaceResources.getResources ( this.label.getDisplay () ), this.label );
  this.label.setImage ( manager.createImageWithDefault ( ImageDescriptor.createFromURL ( FileLocator.find ( Activator.getDefault ().getBundle (), new Path ( "/resources/debugIcon.png" ), Collections.EMPTY_MAP ) ) ) ); //$NON-NLS-1$
  final MenuManager menuManager = new MenuManager ( "#PopupMenu", "org.eclipse.scada.vi.ui.user.debugMenu" ); //$NON-NLS-1$ //$NON-NLS-2$
  menuManager.setRemoveAllWhenShown ( true );
  this.label.setMenu ( menuManager.createContextMenu ( this.label ) );
  createActions ();
  menuManager.addMenuListener ( new IMenuListener () {
    @Override
    public void menuAboutToShow ( final IMenuManager menuManager )
    {
      contextMenuAboutToShow ( menuManager );
    }
  } );
  viewManager.registerMenuManager ( menuManager );
}

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

/**
 * Get the image for the info.
 *
 * @return Image
 */
private Image getInfoImage() {
  if (!info.isJobInfo()) {
    return JFaceResources.getImage(DEFAULT_JOB_KEY);
  }
  JobInfo jobInfo = (JobInfo) info;
  ImageDescriptor descriptor = null;
  Object property = jobInfo.getJob().getProperty(
      IProgressConstants.ICON_PROPERTY);
  if (property instanceof ImageDescriptor) {
    descriptor = (ImageDescriptor) property;
  } else if (property instanceof URL) {
    descriptor = ImageDescriptor.createFromURL((URL) property);
  }
  Image image = null;
  if (descriptor == null) {
    image = ProgressManager.getInstance().getIconFor(jobInfo.getJob());
  } else {
    image = getResourceManager().createImageWithDefault(descriptor);
  }
  if (image == null)
    image = jobInfo.getDisplayImage();
  return image;
}

相关文章