Plugin action icon

Hey!

I developed a language plugin for MPS. If I want to set a icon on my action, it always takes the absolute path to the selected image. Is there a way to set a relative path? Cause I want to distribute this MPS plugin, without having the next user to select the respective image again.

Regards msch95

0
3 comments

You can achieve this by adding your images to a jar file and then adding that jar to the class path (In mps you can try putting it inside lib folder as that gets loaded by default):

Java code Something like this:

public BufferedImage loadImage(String fileName){

    BufferedImage buff = null;
    try {
        buff = ImageIO.read(getClass().getResourceAsStream(fileName));
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return null;
    }
    return buff;

}

Note: In idea platform we have IconUtil class which makes out job much easier while reading image.
1

When you specify an icon that is inside the module's directory or inside a directory defined by a path variable (Settings -> Path Variables), its path should be automatically changed ("shrunk") to include a macro for the module directory, so the path should effectively become relative.

1

Thanks to both of you!

0

Please sign in to leave a comment.