gpt4 book ai didi

org.eclipse.ui.internal.WorkbenchImages类的使用及代码示例

转载 作者:知者 更新时间:2024-03-26 14:03:05 27 4
gpt4 key购买 nike

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

WorkbenchImages介绍

[英]This class provides convenience access to many of the resources required by the workbench. The class stores some images as descriptors, and some are stored as real Images in the registry. This is a pure speed-space tradeoff. The trick for users of this class is that images obtained from the registry (using getImage()), don't require disposal since they are shared, while images obtained using getImageDescriptor() will require disposal. Consult the declareImages method to see if a given image is declared as a registry image or just as a descriptor. If you change an image from being stored as a descriptor to a registry image, or vice-versa, make sure to check all users of the image to ensure they are calling the correct getImage... method and handling disposal correctly. Images: - use getImage(key) to access cached images from the registry. - Less common images are found by calling getImageDescriptor(key) where key can be found in IWorkbenchGraphicConstants This class initializes the image registry by declaring all of the required graphics. This involves creating image descriptors describing how to create/find the image should it be needed. The image is not actually allocated until requested. Some Images are also made available to other plugins by being placed in the descriptor table of the SharedImages class. Where are the images? The images (typically png file) are found the plugins install directory How to add a new image Place the png file into the appropriate directories. Add a constant to IWorkbenchGraphicConstants following the conventions Add the declaration to this file
[中]此类提供了对工作台所需的许多资源的方便访问。该类将一些图像存储为描述符,而一些图像则作为真实图像存储在注册表中。这是一种纯粹的速度空间权衡。此类用户的诀窍是,从注册表(使用getImage())获取的图像不需要处理,因为它们是共享的,而使用getImageDescriptor()获取的图像则需要处理。请参阅declareImages方法,查看给定图像是声明为注册表图像还是仅声明为描述符。如果将图像从作为描述符存储更改为注册表图像,或者反之亦然,请确保检查图像的所有用户,以确保他们调用的getImage是正确的。。。方法和正确处理。图像:-使用getImage(键)从注册表访问缓存的图像。-通过调用getImageDescriptor(key)可以找到不太常见的图像,其中key可以在iWorkbenchGraphic常量中找到。此类通过声明所有必需的图形来初始化图像注册表。这涉及到创建图像描述符,描述如何创建/查找需要的图像。在请求之前,不会实际分配映像。通过将一些图像放在SharedImages类的描述符表中,其他插件也可以使用这些图像。图像在哪里?图像(通常是png文件)可以在插件安装目录中找到。如何添加新图像将png文件放入适当的目录中。向iWorkbenchGraphic常量中添加一个常量按照约定将声明添加到此文件

代码示例

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

@Override
public ImageDescriptor getImageDescriptor() {
  return WorkbenchImages
      .getImageDescriptor(ISharedImages.IMG_ETOOL_DEF_PERSPECTIVE);
}

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

/**
 * Retrieves the specified image from the workbench plugin's image registry.
 *
 * @see ISharedImages
 */
@Override
public Image getImage(String symbolicName) {
  Image image = WorkbenchImages.getImage(symbolicName);
  if (image != null) {
    return image;
  }
  //if there is a descriptor for it, add the image to the registry.
  ImageDescriptor desc = WorkbenchImages.getImageDescriptor(symbolicName);
  if (desc != null) {
    WorkbenchImages.getImageRegistry().put(symbolicName, desc);
    return WorkbenchImages.getImageRegistry().get(symbolicName);
  }
  return null;
}

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

@Override
public void declareImage(String symbolicName, ImageDescriptor descriptor,
    boolean shared) {
  if (symbolicName == null || descriptor == null) {
    throw new IllegalArgumentException();
  }
  WorkbenchImages.declareImage(symbolicName, descriptor, shared);
}

代码示例来源:origin: org.eclipse.mylyn.commons.repositories/ui

@Override
public Image getImage(Object object) {
  if (object instanceof RepositoryCategory) {
    return WorkbenchImages.getImage(ISharedImages.IMG_OBJ_FOLDER);
  }
  return null;
}

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

/**
 * Convenience Method.
 * Returns an ImageDescriptor obtained from an external program.
 * If there isn't any image then <code>null</code> is returned.
 *
 * This method is convenience and only intended for use by the workbench because it
 * explicitly uses the workbench's registry for caching/retrieving images from other
 * extensions -- other plugins must user their own registry.
 * This convenience method is subject to removal.
 *
 * Note:
 * This consults the plugin for extension and obtains its installation location.
 * all requested images are assumed to be in a directory below and relative to that
 * plugins installation directory.
 *
 * @param filename the file name
 * @param offset the offset
 * @return the image descriptor
 */
public static ImageDescriptor getImageDescriptorFromProgram(
    String filename, int offset) {
  Assert.isNotNull(filename);
  String key = filename + "*" + offset; //use * as it is not a valid filename character//$NON-NLS-1$
  ImageDescriptor desc = getImageDescriptor(key);
  if (desc == null) {
    desc = new ProgramImageDescriptor(filename, offset);
    getDescriptors().put(key, desc);
  }
  return desc;
}

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

tempDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin(configurationElement.getNamespaceIdentifier(), imageFileName);
    else if (command != null)
      tempDescriptor = WorkbenchImages.getImageDescriptorFromProgram(command, 0);
  } else
    tempDescriptor = imageDesc;
    imageDesc = WorkbenchImages.getImageDescriptor(ISharedImages.IMG_OBJ_FILE);
    testImage = false;
    return imageDesc;
  tempDescriptor = WorkbenchImages.getImageDescriptor(ISharedImages.IMG_OBJ_FILE);
else
  img.dispose();

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

declareImage(ISharedImages.IMG_DEC_FIELD_ERROR, PATH_OVERLAY + "error_ovr.png", true); //$NON-NLS-1$
declareImage(ISharedImages.IMG_DEC_FIELD_WARNING, PATH_OVERLAY + "warning_ovr.png", true); //$NON-NLS-1$
declareImage(IWorkbenchGraphicConstants.IMG_ETOOL_PIN_EDITOR, PATH_ETOOL + "pin_editor.png", false); //$NON-NLS-1$
declareImage(IWorkbenchGraphicConstants.IMG_ETOOL_PIN_EDITOR_DISABLED, PATH_DTOOL + "pin_editor.png", false); //$NON-NLS-1$
declareImage(ISharedImages.IMG_ETOOL_SAVE_EDIT, PATH_ETOOL + "save_edit.png", true); //$NON-NLS-1$
declareImage(ISharedImages.IMG_ETOOL_SAVE_EDIT_DISABLED, PATH_DTOOL + "save_edit.png", true); //$NON-NLS-1$
declareImage(ISharedImages.IMG_ETOOL_SAVEAS_EDIT, PATH_ETOOL + "saveas_edit.png", true); //$NON-NLS-1$
declareImage(ISharedImages.IMG_ETOOL_SAVEAS_EDIT_DISABLED, PATH_DTOOL + "saveas_edit.png", true); //$NON-NLS-1$
declareImage(ISharedImages.IMG_ETOOL_SAVEALL_EDIT, PATH_ETOOL + "saveall_edit.png", true); //$NON-NLS-1$
declareImage(ISharedImages.IMG_ETOOL_SAVEALL_EDIT_DISABLED, PATH_DTOOL + "saveall_edit.png", true); //$NON-NLS-1$
declareImage(ISharedImages.IMG_TOOL_UNDO, PATH_ETOOL + "undo_edit.png", true); //$NON-NLS-1$
declareImage(ISharedImages.IMG_TOOL_UNDO_DISABLED, PATH_DTOOL + "undo_edit.png", true); //$NON-NLS-1$
declareImage(ISharedImages.IMG_TOOL_REDO, PATH_ETOOL + "redo_edit.png", true); //$NON-NLS-1$
declareImage(ISharedImages.IMG_TOOL_REDO_DISABLED, PATH_DTOOL + "redo_edit.png", true); //$NON-NLS-1$
declareImage(ISharedImages.IMG_TOOL_CUT, PATH_ETOOL + "cut_edit.png", true); //$NON-NLS-1$
declareImage(ISharedImages.IMG_TOOL_CUT_DISABLED, PATH_DTOOL + "cut_edit.png", true); //$NON-NLS-1$
declareImage(ISharedImages.IMG_TOOL_COPY, PATH_ETOOL + "copy_edit.png", true); //$NON-NLS-1$
declareImage(ISharedImages.IMG_TOOL_COPY_DISABLED, PATH_DTOOL + "copy_edit.png", true); //$NON-NLS-1$
declareImage(ISharedImages.IMG_TOOL_PASTE, PATH_ETOOL + "paste_edit.png", true); //$NON-NLS-1$
declareImage(ISharedImages.IMG_TOOL_PASTE_DISABLED, PATH_DTOOL + "paste_edit.png", true); //$NON-NLS-1$

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

/**
 * Initialize the image registry by declaring all of the required graphics.
 * This involves creating JFace image descriptors describing how to
 * create/find the image should it be needed. The image is not actually
 * allocated until requested.
 *
 * Prefix conventions Wizard Banners WIZBAN_ Preference Banners PREF_BAN_
 * Property Page Banners PROPBAN_ Enable toolbar ETOOL_ Disable toolbar
 * DTOOL_ Local enabled toolbar ELCL_ Local Disable toolbar DLCL_ Object
 * large OBJL_ Object small OBJS_ View VIEW_ Product images PROD_ Misc
 * images MISC_
 *
 * Where are the images? The images (typically png files) are found in the
 * same location as this plugin class. This may mean the same package
 * directory as the package holding this class. The images are declared
 * using this.getClass() to ensure they are looked up via this plugin class.
 *
 * @see ImageRegistry
 */
private static void initializeImageRegistry() {
  imageRegistry = new ImageRegistry();
  descriptors = new HashMap<>();
  declareImages();
}

代码示例来源:origin: org.eclipse.mylyn.commons/workbench

public Image getFolderImage() {
  return WorkbenchImages.getImage(ISharedImages.IMG_OBJ_FOLDER);
}

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

@Override
public ImageDescriptor getImageDescriptor() {
  return WorkbenchImages
      .getImageDescriptor(IWorkbenchGraphicConstants.IMG_VIEW_DEFAULTVIEW_MISC);
}

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

private Image getImage(Object element) {
  if (element instanceof ItemsListSeparator) {
    return WorkbenchImages
        .getImage(IWorkbenchGraphicConstants.IMG_OBJ_SEPARATOR);
  }
  return provider.getImage(element);
}

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

/**
 * Declares all the workbench's deprecated hover images, including both "shared" ones and
 * internal ones.
 *
 * @deprecated As of 3.0, since the workbench itself no longer uses the hover image variants
 */
@Deprecated
private static final void declareHoverImages() {
  declareImage(ISharedImages.IMG_TOOL_UNDO_HOVER, PATH_ETOOL
      + "undo_edit.png", true); //$NON-NLS-1$
  declareImage(ISharedImages.IMG_TOOL_REDO_HOVER, PATH_ETOOL
      + "redo_edit.png", true); //$NON-NLS-1$
  declareImage(ISharedImages.IMG_TOOL_CUT_HOVER, PATH_ETOOL
      + "cut_edit.png", true); //$NON-NLS-1$
  declareImage(ISharedImages.IMG_TOOL_COPY_HOVER, PATH_ETOOL
      + "copy_edit.png", true); //$NON-NLS-1$
  declareImage(ISharedImages.IMG_TOOL_PASTE_HOVER, PATH_ETOOL
      + "paste_edit.png", true); //$NON-NLS-1$
  declareImage(ISharedImages.IMG_TOOL_FORWARD_HOVER, PATH_ELOCALTOOL
      + "forward_nav.png", true); //$NON-NLS-1$
  declareImage(ISharedImages.IMG_TOOL_DELETE_HOVER, PATH_ETOOL
      + "delete_edit.png", true); //$NON-NLS-1$
  declareImage(ISharedImages.IMG_TOOL_NEW_WIZARD_HOVER, PATH_ETOOL
          + "new_wiz.png", true); //$NON-NLS-1$
  declareImage(ISharedImages.IMG_TOOL_BACK_HOVER, PATH_ELOCALTOOL
      + "backward_nav.png", true); //$NON-NLS-1$
  declareImage(ISharedImages.IMG_TOOL_UP_HOVER, PATH_ELOCALTOOL
      + "up_nav.png", true); //$NON-NLS-1$
}

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

@Override
public ImageDescriptor getImageDescriptor() {
  return WorkbenchImages
      .getImageDescriptor(IWorkbenchGraphicConstants.IMG_LCL_VIEW_MENU);
}

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

@Override
public Image getColumnImage(Object element, int columnIndex) {
  if (columnIndex == 0) {
    if (element instanceof AboutBundleData) {
      final AboutBundleData data = (AboutBundleData) element;
      if (data.isSignedDetermined()) {
        return WorkbenchImages
            .getImage(data.isSigned() ? IWorkbenchGraphicConstants.IMG_OBJ_SIGNED_YES
                : IWorkbenchGraphicConstants.IMG_OBJ_SIGNED_NO);
      }
      synchronized (resolveQueue) {
        resolveQueue.add(data);
      }
      resolveJob.schedule();
      return WorkbenchImages
          .getImage(IWorkbenchGraphicConstants.IMG_OBJ_SIGNED_UNKNOWN);
    }
  }
  return null;
}

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

/**
 * Declares a workbench image given the path of the image file (relative to
 * the workbench plug-in). This is a helper method that creates the image
 * descriptor and passes it to the main <code>declareImage</code> method.
 *
 * @param key the symbolic name of the image
 * @param path the path of the image file relative to the base of the workbench
 * plug-ins install directory
 * @param shared <code>true</code> if this is a shared image, and
 * <code>false</code> if this is not a shared image
 */
private static final void declareImage(String key, String path,
    boolean shared) {
  URL url = BundleUtility.find(PlatformUI.PLUGIN_ID, path);
  ImageDescriptor desc = ImageDescriptor.createFromURL(url);
  declareImage(key, desc, shared);
}

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

/**
   * Retrieves the specified image descriptor from the workbench plugin's image registry.
   *
   * @see ISharedImages
   */
  @Override
  public ImageDescriptor getImageDescriptor(String symbolicName) {
    return WorkbenchImages.getImageDescriptor(symbolicName);
  }
}

代码示例来源:origin: org.eclipse.mylyn.builds/ui

@Override
public Image getImage(Object element) {
  if (element instanceof ArtifactFolder) {
    return WorkbenchImages.getImage(ISharedImages.IMG_OBJ_FOLDER);
  } else if (element instanceof IArtifact) {
    return imageManager.getFileImage(((IArtifact) element).getName());
  }
  return null;
}

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

@Override
public ImageDescriptor getImageDescriptor() {
  return WorkbenchImages
      .getImageDescriptor(IWorkbenchGraphicConstants.IMG_OBJ_NODE);
}

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

Image getImage(QuickAccessElement element, ResourceManager resourceManager) {
  Image image = findOrCreateImage(element.getImageDescriptor(),
      resourceManager);
  if (image == null) {
    image = WorkbenchImages
        .getImage(IWorkbenchGraphicConstants.IMG_OBJ_ELEMENT);
  }
  return image;
}

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

@Override
public ImageDescriptor getImageDescriptor() {
  return WorkbenchImages
      .getImageDescriptor(IWorkbenchGraphicConstants.IMG_OBJ_NODE);
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com