Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » How to make custom widgets themeable?
How to make custom widgets themeable? [message #1231274] Tue, 14 January 2014 08:38 Go to next message
Christian Mohr is currently offline Christian MohrFriend
Messages: 34
Registered: June 2012
Member
Hi there,

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.

So my question is, how do i properly register a css-file/appearance, so that i'am able to access it on clientside(javascript)?

Thanks for any help!
Re: How to make custom widgets themeable? [message #1231302 is a reply to message #1231274] Tue, 14 January 2014 09:59 Go to previous messageGo to next message
Tim Buschtoens is currently offline Tim BuschtoensFriend
Messages: 396
Registered: July 2009
Senior Member
Hi.

> Dropdown-Widget as base and made the needed changes for my widget.

You should be aware that this widget uses internals[1] and not the
recommended public API[2]. (I can afford to use internals since I'm
doing or at least approving all RAP internal JavaScript changes myself.)
The CKEditor[3] 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
> 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.
>

It should still be correct[4].

> So my question is, how do i properly register a css-file/appearance, so
> that i'am able to access it on clientside(javascript)?

DropDown widget requires you to use the ApplicationConfiguration API[5]
to start your application. There any widget can be themeable[6].
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[7].

I'm sorry for the confusion, I will add an entry on themeability to the
custom widget FAQ when I get around to it.

[1]
https://wiki.eclipse.org/RAP/Custom_Widgets_FAQ#Isn.27t_RAP_based_on_qooxdoo.3F_Can.2FShould_I_use_that.3F
[2]
http://download.eclipse.org/rt/rap/doc/2.2/guide/reference/jsdoc/index.html
[3] https://github.com/eclipsesource/rap-ckeditor
[4]
http://download.eclipse.org/rt/rap/doc/2.2/guide/reference/extension-points/org_eclipse_rap_ui_themeableWidgets.html
[5]
http://eclipse.org/rap/developers-guide/devguide.php?topic=application-configuration.html&version=2.2
[6]
http://download.eclipse.org/rt/rap/doc/2.2/guide/reference/api/org/eclipse/rap/rwt/application/Application.html#addThemableWidget%28java.lang.Class%29
[7]
http://wiki.eclipse.org/RAP/Custom_Widgets_FAQ#What_is_the_basic_architecture_of_a_Custom_Widget.3F
--
Tim Buschtöns

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: How to make custom widgets themeable? [message #1231763 is a reply to message #1231302] Wed, 15 January 2014 10:39 Go to previous messageGo to next message
Christian Mohr is currently offline Christian MohrFriend
Messages: 34
Registered: June 2012
Member
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 Smile

Re: How to make custom widgets themeable? [message #1231814 is a reply to message #1231763] Wed, 15 January 2014 13:18 Go to previous messageGo to next message
Tim Buschtoens is currently offline Tim BuschtoensFriend
Messages: 396
Registered: July 2009
Senior Member
Hi.

> Do you think, there will be any plans on adding a plubic API for themes?

Yes, but I currently don't think it will make it in 2.3 (Luna), more
likely our winter release.

Greetings,
Tim

--
Tim Buschtöns

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: How to make custom widgets themeable? [message #1232119 is a reply to message #1231763] Thu, 16 January 2014 09:14 Go to previous message
Ralf Sternberg is currently offline Ralf SternbergFriend
Messages: 1313
Registered: July 2009
Senior Member

> 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.

Thanks for pointing this out. You're completely right, we decided to
spell "themeable" with an "e" everywhere. This is actually a typo that
slipped through the API review :( I've opened bug 425845 [1] for it.

Regards,
Ralf

[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=425845

--
Ralf Sternberg

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Previous Topic:Unresolved compilation problem
Next Topic:Graphic is disposed
Goto Forum:
  


Current Time: Sat May 04 15:15:06 GMT 2024

Powered by FUDForum. Page generated in 0.03827 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top