2012-05-01 2 views
0

私のrcpプラグインで、私はフォルダを作成するためにプラグインをエクスポートするときに、エクスポートされたフォルダに画像を言うことができます。たとえば、エクスポートされたフォルダに設定、p2、プラグイン、およびワークスペースフォルダがあります。私はそこに画像を保存するためのデフォルトのフォルダが欲しいし、プラグインの中から審判を受けることができます。rcpプラグインをエクスポートするときの出力フォルダ

答えて

1

これは多少誤っているかもしれません。あなたのプラグインの中にイメージをパッケージ化して、コードから簡単にアクセスすることができます。プラグインプロジェクト内にイメージフォルダを作成し、plugin.xmlエディタの[Build Configuration]ページの[Binary Build]ペインでそのフォルダを選択するだけです。

あなたは、このようなキャッシュを経由して、あなたのイメージを管理することができますexample.gifはプラグインプロジェクトのルートの下の画像フォルダにある

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()); 
    }  
} 

も参照してください:http://www.vogella.com/articles/EclipseRCP/article.html#tips_loadimages と:http://obscuredclarity.blogspot.co.uk/2009/10/add-image-to-eclipse-rcp-application.html

+0

iは、エクスポート後の写真を追加することができますか? – ddarellis

+0

Ok - ポストビルドを変更するイメージのコレクションを管理したいですか?写真管理アプリなどで?この場合、eclipseワークスペースを使用したい場合は、次のようにその場所を取得することができます。 'File rootDir = new File(Platform.getInstanceLocation()。getURL().getFile());'製品の起動設定から設定することができます。 –

関連する問題