|How to make custom widgets themeable? [message #1231274]
||Tue, 14 January 2014 03:38
| Christian Mohr
Registered: June 2012
i am trying the create my first custom widget. I used Tim Buschtöns Dropdown-Widget as base and made the needed changes for my widget. Worked pretty good so far. Now I also want to make the widget themeable. I copied the *.appearances.js/*.default.css/*.theme.xml and only renamed the files, the packagename and the properties. But it doesn't work yet.
On Clientside a get the error "Error: Missing appearance entry: timepickr". I searched the whole DropDown-Project for any information on how to register the theme appearance.
In some documentations(http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.rap.help%2Fhelp%2Fhtml%2Fadvanced%2Ftheming-custom.html) it states, that i have to register my widget as "themeableWidget" and add a ThemeAdapter. But the extensionpoint only allows classes of type "Control". I think this documentation is to old for rap 2.2.
I looked through the rap widgets to find some more information. The "ui.forms"-Widgets are registered via "themeableWidget" in the "plugin.xml" file. These Widgets are of type "Control", so they don't help me (mine is a Widget, no Control). All other Controls are registered by code, but i don't know if that's the correct way.
Thanks for any help!
|Re: How to make custom widgets themeable? [message #1231302 is a reply to message #1231274]
||Tue, 14 January 2014 04:59
| Tim Buschtoens
Registered: July 2009
> Dropdown-Widget as base and made the needed changes for my widget.
You should be aware that this widget uses internals and not the
recommended public API. (I can afford to use internals since I'm
The CKEditor would be a better template. However, the theming is
currently not officially supported by the new API either, so if you
absolutely require that you admittedly must use internals.
> In some
> it states, that i have to register my widget as "themeableWidget" and
> add a ThemeAdapter. But the extensionpoint only allows classes of type
> "Control". I think this documentation is to old for rap 2.2.
It should still be correct.
> So my question is, how do i properly register a css-file/appearance, so
DropDown widget requires you to use the ApplicationConfiguration API
to start your application. There any widget can be themeable.
Since this configuration code is not guaranteed to be present, the
DropDown code uses a try-catch. Please look at the getStyleMap function
to see how I it does that.
However, again, DropDown not being a control is a very special case and
not a good example (perhaps i should note that in the code). If you
build a custom widget, it should definitely extend a Composite.
I'm sorry for the confusion, I will add an entry on themeability to the
custom widget FAQ when I get around to it.
Professional services for RAP and RCP?
|Re: How to make custom widgets themeable? [message #1231763 is a reply to message #1231302]
||Wed, 15 January 2014 05:39
| Christian Mohr
Registered: June 2012
Hi, thanks for your reply.|
At the beginning i looked at both Incubator-Widgets(DropDown and CKEditor). The DropDown widget was closer to my custom widget, because it's an extension for a Text-Control, too. I don't absolutely require theming, but i wanted to keep the widget as customizable as possible (especially when i decide to make it available for others). I saw your try-catch block and used it the see whether the client gets the style information from the server, or not.
The "addThemableWidget" function was the missing hint that i needed, to understand how your DropDown widget registers its appearance. I was looking for it, but sadly i searched for themEable (with E), because the extension point for "plugin.xml" registration is written with E. And probably i've skipped this line unvoluntarily.
Do you think, there will be any plans on adding a plubic API for themes?
Thanks again for your help. I think i'll drop the theming for now and concentrate on the other parts
Powered by FUDForum
. Page generated in 0.03011 seconds