Custom image icons in a workspace access plugin
Post here questions and problems related to oXygen frameworks/document types.
-
- Posts: 11
- Joined: Fri Oct 04, 2019 11:26 pm
Custom image icons in a workspace access plugin
Post by jakubsimek »
Dear list,
May I ask for help with the way how to include custom image icons for a toolbar in a standalone workspace access plugin extension?
Unfortunately I cannot find any documentation to the "ro.sync.ui.Icons.getIcon(String iconKey)" mentioned in another post here ([topic12826.html]).
I am (naively?) trying something like to following line to put an image into a button:
The image file resides in "src/main/resources" of my Maven project.
It doesn't work however. Do I need to tell Maven somehow about copying the image into the final "jar" file?
And how would I proceed with an alternative high resolution image for Retina monitors (or with dark mode images)?
Sorry for perhaps asking the obvious; I am still a newbie. Any hints are very welcome.
Best,
Jakub
---
Jakub Šimek
Heidelberg University Library
May I ask for help with the way how to include custom image icons for a toolbar in a standalone workspace access plugin extension?
Unfortunately I cannot find any documentation to the "ro.sync.ui.Icons.getIcon(String iconKey)" mentioned in another post here ([topic12826.html]).
I am (naively?) trying something like to following line to put an image into a button:
Code: Select all
Button btn = new Button("text",new ImageIcon("/main/resources/my_image.png"));
It doesn't work however. Do I need to tell Maven somehow about copying the image into the final "jar" file?
And how would I proceed with an alternative high resolution image for Retina monitors (or with dark mode images)?
Sorry for perhaps asking the obvious; I am still a newbie. Any hints are very welcome.
Best,
Jakub
---
Jakub Šimek
Heidelberg University Library
-
- Posts: 9530
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Custom image icons in a workspace access plugin
Hi Jakub,
Maybe you can take inspiration from some of the plugins we've built like our Git client plugin, it has the images here:
https://github.com/oxygenxml/oxygen-git ... ces/images
as you see the retina images have the "@2x.png" suffix.
And it has this Icons class which defines all icon constants and has a special method which uses our API to load the icons:
https://github.com/oxygenxml/oxygen-git ... Icons.java
The method "PluginWorkspaceProvider.getPluginWorkspace().getImageUtilities().loadIcon" will automatically load the @2 icon if running on retina displays.
Also you need to load the icon directly with the path "/resources/images/icon.png" because that's how the image is placed in the JAR library.
Regards,
Radu
Maybe you can take inspiration from some of the plugins we've built like our Git client plugin, it has the images here:
https://github.com/oxygenxml/oxygen-git ... ces/images
as you see the retina images have the "@2x.png" suffix.
And it has this Icons class which defines all icon constants and has a special method which uses our API to load the icons:
https://github.com/oxygenxml/oxygen-git ... Icons.java
The method "PluginWorkspaceProvider.getPluginWorkspace().getImageUtilities().loadIcon" will automatically load the @2 icon if running on retina displays.
Also you need to load the icon directly with the path "/resources/images/icon.png" because that's how the image is placed in the JAR library.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 11
- Joined: Fri Oct 04, 2019 11:26 pm
Re: Custom image icons in a workspace access plugin
Post by jakubsimek »
Hi Radu,
A part of my beginner problems seems to be that the "resources" directory ("src/main/resources") does not land in the "JAR" at all. I thought that this is handled by Maven correctly by default. Or do I have to tell this Maven explicitly somehow in the pom.xml file?
Neither are the "resources" being copied into the "target" directory.
Do you perhaps have an idea what I am doing wrong?
Best wishes,
Jakub
A part of my beginner problems seems to be that the "resources" directory ("src/main/resources") does not land in the "JAR" at all. I thought that this is handled by Maven correctly by default. Or do I have to tell this Maven explicitly somehow in the pom.xml file?
Neither are the "resources" being copied into the "target" directory.
Do you perhaps have an idea what I am doing wrong?
Best wishes,
Jakub
-
- Posts: 1018
- Joined: Wed Nov 16, 2005 11:11 am
Re: Custom image icons in a workspace access plugin
Post by alex_jitianu »
Hi Jakub,
The src/main/resources directory is handled by default and its content end up in the jar artifact. Its content is copied inside target/classes during the build process.
If I have a resource, src/main/resources/myfile.xml, after an mvn install :
- myfile.xml will appear in the jar file on the top level.
- target/classes/myfile.xml will exist
Is this true for your project as well?
Best regards,
Alex
The src/main/resources directory is handled by default and its content end up in the jar artifact. Its content is copied inside target/classes during the build process.
If I have a resource, src/main/resources/myfile.xml, after an mvn install :
- myfile.xml will appear in the jar file on the top level.
- target/classes/myfile.xml will exist
Is this true for your project as well?
Best regards,
Alex
-
- Posts: 3
- Joined: Mon Sep 29, 2025 9:54 pm
Re: Custom image icons in a workspace access plugin
Hi Radu,Radu wrote: ↑Wed May 12, 2021 1:25 pm Maybe you can take inspiration from some of the plugins we've built like our Git client plugin, it has the images here:
https://github.com/oxygenxml/oxygen-git ... ces/images
I'm also having trouble in loading custom image icon in a custom JavaScript based workspace access plugin, however the link above is no longer available on GitHub. Could you kindly provide available git repo for our reference, thanks in advance.
Best Regards,
Jeff
Last edited by nh89ur168 on Tue Sep 30, 2025 11:03 am, edited 2 times in total.
-
- Posts: 9530
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Custom image icons in a workspace access plugin
Hi Jeff,
We made the Git plugin a private GitHub repo and thus the broken link.
Most of our plugins are Java based though, and in this case we place the icons directly in a folder path like:
https://github.com/oxygenxml/oxygen-bat ... ces/images
And the images become part of the JAR library of the plugin and are accessed in this manner.
In general once a plugin's code becomes more advanced/complex, working directly in Java on it makes sense.
For Javascript plugins, maybe this sample plugin's way of loading a custom icon will help:
https://github.com/oxygenxml/wsaccess-j ... esAndIcons
Regards,
Radu
We made the Git plugin a private GitHub repo and thus the broken link.
Most of our plugins are Java based though, and in this case we place the icons directly in a folder path like:
https://github.com/oxygenxml/oxygen-bat ... ces/images
And the images become part of the JAR library of the plugin and are accessed in this manner.
In general once a plugin's code becomes more advanced/complex, working directly in Java on it makes sense.
For Javascript plugins, maybe this sample plugin's way of loading a custom icon will help:
https://github.com/oxygenxml/wsaccess-j ... esAndIcons
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 3
- Joined: Mon Sep 29, 2025 9:54 pm
Re: Custom image icons in a workspace access plugin
Hi Radu,
Thanks for the links. It reminds me the magic "jsDirUrl", a globally defined field that points to the folder where the JavaScript file is located.
Thank you again
Thanks for the links. It reminds me the magic "jsDirUrl", a globally defined field that points to the folder where the JavaScript file is located.
Thank you again

Return to “SDK-API, Frameworks - Document Types”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service