Dynamic Icons

I’m trying to port a swing application into Vaadin and I’m doing pretty good so far. Nice job guys!

I’m trying to port a piece of my code that generates dynamic icons for a Tree. Basically the leaf nodes are usually files so I did this in the current code:

            //Create a temporary file with the specified extension
            file = File.createTempFile("icon", "." + extension);

            FileSystemView view = FileSystemView.getFileSystemView();
            icon = view.getSystemIcon(file);
            return icon

I’m aware of the ThemeResource but that seems to need them already rendered. Is there a way of doing this dinamically?

Also it seems like this is doen in the server. In my client this was done on the client side so the icon depends on what the client has installed locally. I would like to keep that.

Thanks in advance!

Issue solved
. It has full code for reference.