Where to put image files (resources) and how to access them

Hi,

I have an image cell and I want to use the image provider to show a default image if no real image is chosen yet. I put my image under "MyProject/languages/myLanguage/res/missing.png".

Is this the right location for an image? How can I get the location of myLanguage programmatically? 

Thanks,

Julian

3 comments
Comment actions Permalink

If you have the model

new File(this.model/.getSource().getLocation())

If you have a node

new File(<<your node>>/.getModel().getSource().getLocation())
1
Comment actions Permalink

Thanks, that helps.

For the next person running into this, the result of 

this.model/.getSource().getLocation()

Looks like this:

"IdeaFile{file:///path/to/MPSHome/ProjectName/languages/LanguageName/sandbox/models/LanguageName/sandbox.mps}"

And to get the "real" path out of it one can use:

VirtualFileManager.extractPath(location)

 

 

 

 

3
Comment actions Permalink

Hi, 

What about when the png is in another model ?

0

Please sign in to leave a comment.