即使plugin.xml使用相同的图标路径,Activator.getImageDescriptor(path)也会返回null
在 StyledCellLabelProvider
的子类中,我有这样一行:
ImageDescriptor d = Activator.getImageDescriptor("/icons/sample.gif");
然而,变量 d
始终为 null
。奇怪的是,当我在 plugin.xml
中指定完全相同的路径时,图像正确显示在视图的左上角:
<view
name="Message"
allowMultiple="true"
icon="/icons/sample.gif"
class="com.myapp.views.EmailView"
id="com.myapp.gui.emailView">
</view>
该图像在我的项目中的路径是 的标准位置
,插件源代码位于
。
令人沮丧的是,示例插件项目“RCP Mail Template”(成功)使用相同的函数来获取对 ImageDescriptor
的引用:
ImageDescriptor d = Activator.getImageDescriptor("/icons/sample.gif");
我的插件配置是否有问题,会导致找不到图像什么时候以编程方式引用?
In a subclass of StyledCellLabelProvider
, I have a line like this:
ImageDescriptor d = Activator.getImageDescriptor("/icons/sample.gif");
However, the variable d
is always null
. Strangely, the image shows up correctly in the upper left corner of a View when I specify the exact same path in plugin.xml
:
<view
name="Message"
allowMultiple="true"
icon="/icons/sample.gif"
class="com.myapp.views.EmailView"
id="com.myapp.gui.emailView">
</view>
The path of this image in my project is the standard location of <project>/icons/sample.gif
, and the plugin source code is in <project>/src
.
Frustratingly, the sample Plugin project "RCP Mail Template" uses (successfully) an identical function to obtain a reference to an ImageDescriptor
:
ImageDescriptor d = Activator.getImageDescriptor("/icons/sample.gif");
Could there be something wrong with my plugin configuration that would cause images to not be found when referenced programmatically?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
但是您的
Activator
类和“RCP Mail Template”的Activator
类的静态getImageDescriptor
方法是不同的。也许您在那里使用了不正确的插件 ID?But the static
getImageDescriptor
methods of yourActivator
class and "RCP Mail Template"'sActivator
class are different. Perhaps you are using incorrect plugin ID there?