Page 1 of 1
Use "Specific Element Icons" in own framework
Posted: Wed Jul 25, 2012 3:28 pm
by patrick
How can I define those "Specific Element Icons" which is listet as new feature in v14 of oXygen in my own framework?
Thanks
Patrick
Re: Use "Specific Element Icons" in own framework
Posted: Wed Jul 25, 2012 3:51 pm
by Radu
Hi Patrick,
You are talking about the possibility to customize icons in the Outline view using our Java API, right?
We have a new API interface called:
Code: Select all
ro.sync.exml.workspace.api.node.customizer.XMLNodeRendererCustomizer
If you edit a document type, in the
Extensions tab you can now set your own implementation of a customizer.
As an example, in our Author SDK you can look at how the:
Code: Select all
ro.sync.ecss.extensions.xhtml.XHTMLNodeRendererCustomizer
customizer works for providing custom icons in the Outline when editing XHTML files.
Using the API you can also change the display name and tooltip of the elements presented in the Outline.
Regards,
Radu
Re: Use "Specific Element Icons" in own framework
Posted: Wed Aug 15, 2012 2:08 pm
by patrick
Thanks, it works now. But which path should I use to get an icon from my framework directory instead of the oxygen.jar?
Re: Use "Specific Element Icons" in own framework
Posted: Thu Aug 16, 2012 11:27 am
by Radu
Hi Patrick,
You should look over the JavaDoc from the API method:
Code: Select all
ro.sync.exml.workspace.api.node.customizer.BasicRenderingInformation.setIconPath(String)
Set the path of the icon used to render a node. The path can be an icon file path, the string representation of an icon URL or can contain editor variables as defined in the EditorVariables class. The editor variables will be expanded at runtime. If the icon path is null the default icon will be used for the node.
If the custom used images are located in the same jar file as the XMLNodeRendererCustomizer then you can use as the return value for this function the following code sequence:
this.getClass().getResource("/images/Icon.gif").toExternalForm();
The previous sequence assumes that Icon.gif icon image is located in the images folder inside your jar file.
So if you have the image in an "images" folder in the same JAR as the XMLNodeRendererCustomizer you could get its URL like:
this.getClass().getResource("/images/Icon.gif").toExternalForm();
Or you could try to use editor variables to express the path to the image like:
${frameworks}/myFramework/images/myImage.png
Regards,
Radu
Re: Use "Specific Element Icons" in own framework
Posted: Thu Aug 16, 2012 6:51 pm
by patrick
Hi Radu,
the images is in
Code: Select all
frameworks/myframework/templates/icons/my_16.gif
but
Code: Select all
nameToIconPath.put("document", getImageURL("${framework}/templates/icons/my_16.gif"));
does not work.
Thanks,
Patrick
Re: Use "Specific Element Icons" in own framework
Posted: Fri Aug 17, 2012 8:36 am
by Radu
Hi Patrick,
Indeed using the ${framework} editor variable does not work (but we'll fix this), that's why I suggested you using the "${frameworks}/myframework/templates/icons/my_16.gif" approach.
Regards,
Radu
Re: Use "Specific Element Icons" in own framework
Posted: Fri Aug 17, 2012 11:20 am
by patrick
Both, the ${framework} and the ${frameworks} variable do not seem to work.
Re: Use "Specific Element Icons" in own framework
Posted: Fri Aug 17, 2012 12:11 pm
by Radu
Hi Patrick,
First of all, we fixed the problem with not expanding the
${framework} variable and a fix will be available in a couple of weeks in the next Oxygen 14.0 minor bug fix which is announced in this RSS feed:
http://www.oxygenxml.com/rssBuildID.xml
The "${frameworks}" approach does not work if you install the framework using an update site approach (instead of copying it to the frameworks directory). And from previous conversations on our support email address it seems that this would be the case.
Then you would have two more approaches:
1) Bundle the images in the extension JAR and create the URL to them like:
Code: Select all
this.getClass().getResource("/images/Icon.gif").toExternalForm()
2) Obtain the URL which points to the current node customizer class:
Code: Select all
String classResource = this.class.getName().replace(".", "/") + ".class";
URL currentClassLocation = this.class.getClassLoader().getResource(classResource);
This URL has a "jar:file:" protocol but you can obtain from it the URL which points to the JAR file, then use it to point to the image.
Regards,
Radu
Re: Use "Specific Element Icons" in own framework
Posted: Fri Aug 17, 2012 12:53 pm
by patrick
Hi Radu,
this framework is installed classic to the framework directory, not with the add-on-feature. If I use ${frameworks}/myFramework/images/myImage.png, e.g. for an author action in the framework configuration, the icon is displayed correctly. Only in the jar file it does not work.
But I try to use the version with the class location.
Re: Use "Specific Element Icons" in own framework
Posted: Fri Aug 17, 2012 2:09 pm
by Radu
Hi Patrick,
The "${frameworks}" approach worked for me.
My implementation was something very basic like:
Code: Select all
public class XMLNodeCustomizerImpl extends XMLNodeRendererCustomizer {
@Override
public BasicRenderingInformation getRenderingInformation(
NodeRendererCustomizerContext arg0) {
BasicRenderingInformation bri = new BasicRenderingInformation();
bri.setIconPath("${frameworks}/dita/images/myImage.png");
return bri;
}
@Override
public String getDescription() {
return "MY CUSTOMIZER";
}
}
I added the JAR with the compiled class to the document type's classpath, added by implementation as an extension and opened a DITA topic.
The icon "myImage.png" was used both in the Outline and in the content completion window.
Maybe you have a different expectation of where the icons should appear.
Regards,
Radu
Re: Use "Specific Element Icons" in own framework
Posted: Fri Aug 17, 2012 3:53 pm
by patrick
Sorry,
I think I have had an error somewhere in my code. By using your sample script it works fine now.
Re: Use "Specific Element Icons" in own framework
Posted: Thu Aug 30, 2012 3:38 pm
by adrian
Hello,
I just wanted to let you know that this problem with not expanding the ${framework} variable has been resolved in the latest maintenance build of Oxygen 14.0, 2012082911 (released on August 30th):
Author API: ro.sync.exml.workspace.api.node.customizer.BasicRenderingInformation.setIconPath(String) did not expand the ${framework} editor variable from the path provided as argument.
You can download it from our web site:
http://www.oxygenxml.com/download.html
The list of bug-fixes can be found here:
http://www.oxygenxml.com/build_history.html#2012082911
You can follow the release/build RSS feed here:
http://www.oxygenxml.com/rssBuildID.xml
Let us know if you encounter further problems with this new build.
Regards,
Adrian