Page 1 of 1

Override the name of CSS title for localisation in framework

Posted: Wed Jan 10, 2018 2:27 pm
by Isabelle
Hello,

We use oxygen-18.1.0.0.jar, and we need to override the name of CSS title for localisation.

I success to manage localisation for other actions and toolbars in the framework thanks to "translation.xml" file.
But I don't find how to do for cssFile title.

Can you explain me how to do that, please ?
Thanks.

Regards,
Isabelle

Re: Override the name of CSS title for localisation in framework

Posted: Wed Jan 10, 2018 3:31 pm
by Radu
Hi Isabelle,

Right now (even in Oxygen 19.1 which is the current version) we do not have support to translate the titles of the CSS layers using the i18n editor variable which works for actions.
As a workaround you could probably try to navigate the Author toolbar Swing component, try to find the menu items for the CSS styles drop down and change their name.
Or you could try to create your own CSS layers drop down button. It would invoke custom actions which would change certain pseudo class properties on the root element, triggering various CSS selectors to be applied.

Regards,
Radu

Re: Override the name of CSS title for localisation in framework

Posted: Wed Jan 10, 2018 3:58 pm
by Isabelle
Hi Radu,

Thanks for your answer.

I tried to build the css toolbar using the "createCSSAlternativesToolbar()" method like this :

Code: Select all


        JToolBar cssAlternativesToolBar = currentPage.createCSSAlternativesToolbar();
for (int i = 0; i < cssAlternativesToolBar.getComponentCount(); i++) {
final JComponent jc = (JComponent) cssAlternativesToolBar.getComponent(i);
jc.setPreferredSize(new Dimension(55, 20));
jc.setMinimumSize(new Dimension(70, 20));
if(/* CSS title is not null */) {
jc.setName(CommonResourceBundle.getInstance().getString(/* CSS title */));
}
this.add(jc);
}
I want to take the "title" field from the framework and use it to build the name of the JComponent, but I don't find how te get this field.
In the "jc" variable, this info is in the field "db".
Is it possible for me to access to this field, in order to get the field "title" ?

Regards,
Isabelle

Re: Override the name of CSS title for localisation in framework

Posted: Wed Jan 10, 2018 4:44 pm
by Radu
Hi Isabelle,

I found an automated test in which I accessed those CSS layers, it looks something like this:

Code: Select all

    JToolBar tbs = authPage.createCSSAlternativesToolbar();
assertEquals(1, tbs.getComponentCount());
JMenu cssMBP = (JMenu) tbs.getComponent(0);
JPopupMenu popupMenu = cssMBP.getPopupMenu();
assertEquals(7, popupMenu.getComponentCount());
assertEquals("Default", ((JCheckBoxMenuItem)popupMenu.getComponent(0)).getText());
assertEquals("+ Show colspec", ((JCheckBoxMenuItem)popupMenu.getComponent(2)).getText());
so those components in the drop down menu are actually Swing JCheckBoxMenuItem and you can set and get the text set on them.

Regards,
Radu

Re: Override the name of CSS title for localisation in framework

Posted: Wed Jan 10, 2018 5:17 pm
by Isabelle
Hi Radu,

It doesn't change my situation.
Even if I use JComponent, or JMenu or JPopupMenu , the name is null.
The string I put as title in the framework :

Code: Select all


	<cssFile>
<field name="href">
<String>${framework}/redacteur.less</String>
</field>
<field name="title">
<String>css.file.redactor</String>
</field>
<field name="alternate">
<Boolean>false</Boolean>
</field>
</cssFile>
doesn't appear as the name of the component.

In fact I found this information in

Code: Select all

popupMenu.invoker.db.0.title = "css.file.redactor"
How can I access to this "db" ArryaList ?

Regards,
Isabelle

Re: Override the name of CSS title for localisation in framework

Posted: Wed Jan 10, 2018 5:26 pm
by Radu
Hi Isabelle,

You should not use "getName", you should use "getText" like in: ((JCheckBoxMenuItem)popupMenu.getComponent(i)).getText().

If this does not work for you please paste the current code you are working with.
About your remark:
How can I access to this "db" ArryaList ?
I do not understand in what context. What is that "popupMenu.invoker.db.0.title" key? How did you find it?

Regards,
Radu

Re: Override the name of CSS title for localisation in framework

Posted: Wed Jan 10, 2018 5:38 pm
by Isabelle
Hi Radu,

Thanks for your help, this is the solution I looked for.

Regarding your last question, I find "popupMenu.invoker.db.0.title" this way.
In debug mode I inspect the popupMenu element with debugger tool.
I find "invoker" field.
And when I inspect this field I find an arrayList with the name "db".
And in the first element of this arrayList, I found an object with the element "title" I looked for.

Regards,
Isabelle

Re: Override the name of CSS title for localisation in framework

Posted: Wed Jan 10, 2018 5:45 pm
by Radu
Hi Isabelle,

Oh, OK, I understand now, you were looking in the Java debugger.
By the way, we also added this API in Oxygen 17.0:

Code: Select all

PluginWorkspaceProvider.getPluginWorkspace().addAuthorCSSAlternativesCustomizer(cssAlternativesCustomizer);
and that CSS customizer API can be even used to add extra CSS layers or to override the call "customizeAvailableCSSGroups" and try to change the titles in the default CSS Groups.

Regards,
Radu

Re: Override the name of CSS title for localisation in framework

Posted: Wed Jan 10, 2018 6:09 pm
by Isabelle
Hi Radu,

Thanks for the information and for your help.

Regards,
Isabelle