Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 391672

Summary: Remove ThemeStore JavaScript Wrapper
Product: [RT] RAP Reporter: Holger Staudacher <holger.staudacher>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P1 CC: jeick, tbuschto
Version: 2.0   
Target Milestone: 2.0 M3   
Hardware: PC   
OS: Mac OS X   
Whiteboard: protocol
Bug Depends on: 391671    
Bug Blocks:    

Description Holger Staudacher CLA 2012-10-11 10:13:26 EDT
Currently the themestore files are loaded within the initial HTML as js files. Therefor the themestore JSON data is wrapped with a Javascript function call. This wrapper should be removed to support other clients.

Additionally it would be great to have either a fixed location of the themestore files or to be able to read the location from the initial JSON data.
Comment 1 Holger Staudacher CLA 2012-10-11 10:31:53 EDT
*** Bug 391585 has been marked as a duplicate of this bug. ***
Comment 2 Ralf Sternberg CLA 2012-10-18 09:40:54 EDT
I suggest that we register plain .json instead of .js files, i.e. without the wrapping JavaScript code. The web client should then read the JSON in an XHR request and apply it to the theme store.
Comment 3 Holger Staudacher CLA 2012-10-18 10:53:31 EDT
+1
I also noticed that there could be several theme files. So, what about to include them in the initial json? Any discovery method would be sufficient ;)
Comment 4 Tim Buschtoens CLA 2012-10-31 13:09:06 EDT
I implented a ThemeStore protocol adapter that can load the themes from any URL. 
It is in commit 426d84c6f393e7c9ac607b9c4ff3dcb7e72694c5, ThemeStoreAdapter.js

The old way to load the theme is also still supported.
When no longer required, remove the "currentTheme" property from DisplayAdapter.js and Display.js. 

The tests will also have to be fixed to load the themes in Startup.js. The code is already in place, ideally only the URLs have to be changed.

The file returned by the server should have this format:
{
  "values" : <values-map>,
  "theme" : <css-values-map>
}

This commit also removed the various no-chaching mechanisms in Request.js, as the themes are supposed to be cached, and the POST (ajax) requests should never be cached anyway.
Comment 5 Ivan Furnadjiev CLA 2012-11-01 09:19:16 EDT
Fixed in master with commit d1dc77375b7f88bad63205624834cd5fbb4c0d5b.

- Themes (fallback and current) are registered as json files like "rwt-resources/rap-rwt.theme.Fallback.json".
- ThemeStore protocol object is used to load the themes. Startup JSON message looks like:

{
"head": {
"url": "controls"
},
"operations": [ [ "call", "rwt.theme.ThemeStore", "loadFallbackTheme", {
"url": "rwt-resources/rap-rwt.theme.Fallback.json"
} ], [ "call", "rwt.theme.ThemeStore", "loadActiveTheme", {
"url": "rwt-resources/rap-rwt.theme.Default.json"
} ], [ "create", "w1", "rwt.widgets.Display" ] ]
}

- Removed rendering of "currentTheme" property from DisplayLCA
- Removed "currentTheme" property from DisplayAdapter.js and Display.js
- Adjusted the Startup.js URLs for loading the themes - both URLs points to Fallback theme