FontAwesome icons in CUBA 6.9

Similar question (Cuba Platform 6.9)

I tried to use IconSets as in:
https://doc.cuba-platform.com/manual-6.8/icon_set.html

I downloaded tree set of flags icons, generated via awk tree ENUMS as in documentation for different image dimensions:

– Code Snippet –

package pro.sysonline.contacts.gui.icons;

import com.haulmont.cuba.gui.icons.Icons;

public enum flagsWorldMini implements Icons.Icon {

    /* Flag Images */
    AD_MINI("icons/flags-mini/ad.png"),
    AE_MINI("icons/flags-mini/ae.png"),
    AF_MINI("icons/flags-mini/af.png"),
    AG_MINI("icons/flags-mini/ag.png"),

– Code Snippet –

put images in module gui/$project/icons where enumerations resides
and configured three enumeration with application and web application properties

app.properties
web-app.properties

in main Cuba Studio project window.

cuba.iconsConfig = +pro.sysonline.contacts.gui.icons.smallIcon +pro.sysonline.contacts.gui.icons.bigIcon

but web application does not start.

I put only one of three enumerations, application starts but icons are not found. (used in a linked button or in a metod to show image near enumeration in a drop-down list)

Any help will’be appreciated.

Thank you in advance,
Fabrizio

Hi,

Please use </> button on editor panel or ``` for code blocks. Do not paste - Code snippet -.

Hello @f.demassis

To use icons that are located in source code of the project you should specify source of icons as classpath resources in the following way: classpath:/path/to/your/icon/from/root/icon.png.

Or you can create a folder named icons under the sources root and put icons there. It allows you to use the following icon sources:

AD_MINI("classpath:/icons/ad.png"),
AE_MINI("classpath:/icons/ae.png"),
AF_MINI("classpath:/icons/af.png"),
AG_MINI("classpath:/icons/ag.png"),

To use icons/*.png like paths you should extend a theme that you use and put icons into modules/web/themes/theme_name/icons/.

I’ve prepared small demo projects where you can find all described approaches.

fa-icons.zip (10.6 MB)

Result:

image

Hello @tsarev I tried first solution and works great!!!

Thank you very much.

Fabrizio

Hello,
I do not know what appened but Assembling project I get this error:

import com.haulmont.cuba.gui.icons.Icons;
 ^
/home/demassis/studio-projects/Contacts/modules/web/themes/halo/icons/flagsWorldMini.java:5: error: package Icons does not exist
public enum flagsWorldMini implements Icons.Icon {
 ^
/home/demassis/studio-projects/Contacts/modules/web/themes/halo/icons/flagsWorldMini.java:214: error: method does not override or implement a method from a supertype
 @Override
 ^

Icons are in path as in your example and correctly configured in web-app.properties

cuba.iconsConfig = +pro.sysonline.contacts.web.icons.icons

Application regurarly starts and works including icon display.

I tried gradle from command line, same problem.
It seems like it can’t find interface class. I did not extracted it from downloaded jars

Cuba Studio release: 6.10.2

CUBA Studio
Version 6.10.2
Built on 2019-01-09 11:43:17

Platform: platform-6.10.7

Not critical just to see if its not a bug.

Thank in advance,
Fabrizio

Hello @f.demassis

It is very strange that your icon set (flagsWorldMini.java) is located in themes directory.

Moreover the cuba.iconsConfig property should be equal to fully qualified name of your icon set, not only its package.

Ok I’ll try to modify it.
So could it be a classpath problem?

It does not seem to find framework package. Is there some configuration that influence classpath?

Thank you,
Fabrizio

It’s hard to say what exactly wrong in your case without sources. There is no any configuration that can influence classpath, and I think that the reason is not a wrong classpath.

OK, I’’ try to solve and let you know.

Thanks,
Fabrizio

Hi, I moved out icons folder from theme directory and changed package name from:

pro.sysonline.contacts.gui.icons
to:
pro.sysonline.contacts.web.icons

now it compile perfectly.
Probably it was my misunderstanding of project includes in this post.

Thank you,
Fabrizio

1 Like