私のrcpプラグインでは、プラグインをエクスポートしてフォルダーを作成するときに必要です。たとえば、エクスポートされたフォルダー内の画像を作成します。たとえば、エクスポートしたフォルダーには、構成、p2、プラグイン、およびワークスペースフォルダーがあります。画像を保存し、プラグイン内から審判できるデフォルトのフォルダが必要です。
1 に答える
1
あなたはおそらくこれについて少し間違って行っているでしょう。プラグイン内に画像をパッケージ化して、コードから簡単にアクセスできます。プラグインプロジェクト内にイメージフォルダーを作成し、plugin.xmlエディターの[ビルド構成]ページの[バイナリビルド]ペインでそのフォルダーを選択するだけです。
次に、次のようなキャッシュを介して画像を管理できます。
public class ImageCache
{
private static ImageCache s_instance = new ImageCache();
private ImageRegistry m_imageRegistry = Activator.getDefault().getImageRegistry();
public static enum AppImage
{
EXAMPLE("images/example.gif")
;
public String location;
private AppImage(String location)
{
this.location = location;
}
}
private ImageCache()
{
for(AppImage image : AppImage.values())
{
imageRegistry.put(image.name(),Activator.getImageDescriptor(image.location));
}
}
public static ImageCache instance()
{
return s_instance;
}
public final static Image get(AppImage key)
{
return instance().m_imageRegistry.get(key.name());
}
public final static ImageDescriptor getDescriptor(AppImage key)
{
return instance().m_imageRegistry.getDescriptor(key.name());
}
}
example.gifは、プラグインプロジェクトのルートの下にあるimagesフォルダーにあります。
参照:http ://www.vogella.com/articles/EclipseRCP/article.html#tips_loadimages および:http://obscuredclarity.blogspot.co.uk/2009/10/add-image-to-eclipse-rcp- application.html
于 2012-05-01T12:24:12.527 に答える