2017-04-05 115 views
0

我已经按照我的日食build.properties插件与路径的问题,以资源文件夹

source.. = src/main/java,\ 
      src/main/resources 
output.. = bin/ 
bin.includes = plugin.xml,\ 
       META-INF/,\ 

我的plugin.xml是

<?xml version="1.0" encoding="UTF-8"?> 
<?eclipse version="3.4"?> 
<plugin> 

<extension 
     point="org.eclipse.ui.decorators"> 
    <decorator 
      adaptable="true" 
      class="com.idc.xtext.shared.XtextFileDecorator" 
      id="com.idc.xtext.shared.xtextFileDecorator" 
      label="label" 
      lightweight="false" 
      location="REPLACE" 
      objectClass="org.eclipse.core.resources.IFile" 
      state="true"> 
    </decorator> 
</extension> 
</plugin> 
       . 

和项目的结构如下

enter image description here

当我尝试使用下面的代码加载图像时,指针异常。

private static void putInIconMap(
      HashMap<String, Image> pIconsMap, String pEnv, String pIconPath) { 
     ImageDescriptor fromPlugin = AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, 
         pIconPath); 
     try { 

      Image createImage = fromPlugin.createImage(); 
      pIconsMap.put(pEnv, createImage); 
     } catch (Exception e) { 
      e.printStackTrace(); 
     } 
    } 

....

putInIconMap(dirsIconsMap, DEV, "icons/dev/Dirs_Dev_icon.png"); 

看起来像一些问题,以文件的路径。 我有检查,所有PNG文件都有实际名称 但为什么以及如何修复它? 问候, 弗拉基米尔

回答

1

您必须在您的build.propertiesbin.includes部分resources文件夹。

resources文件夹置于项目顶层,而不是在src文件夹内,这是正常的。在这种情况下,build.properties是:

source.. = src/main/java 
output.. = bin/ 
bin.includes = plugin.xml,\ 
       META-INF/,\ 
       resources/, 
       . 

而且你会在你的代码中使用像resources/myimage.gif的路径。

+0

所以我需要使用资源/图标/ dev/Config_Dev_icon.png而不是图标/ dev/Config_Dev_icon.png,不是吗? –

+0

你还没有告诉我们任何关于你的图像是什么,所以我不能回答这个问题。如果你愿意,你可以使用'图标'作为顶级文件夹。关键是他们必须列在bin.includes中。 –

+0

不幸的是它不工作。哪里可以解决问题? –