Home » Eclipse Projects » Remote Application Platform (RAP) » Themes in RAP 2.0 M3(Problems using Themes in RAP 2.0 M3)
Themes in RAP 2.0 M3 [message #987848] |
Wed, 28 November 2012 11:36 |
|
Has anyone got an example of Themes working with e4.2.1 + RAP 2.0M3 yet?
Really struggling with this, although have read the "new and noteworthy".
Just trying to use a simple SWT-style helloworld project to begin with, run as RWT, but doesn't seem to matter what I do, the Themes defined in Extensions don't get applied.
Could do with an example project, or step-by-step tutorial to show how to set it up...
It is quite possible I am totally misunderstanding how to use Themes/CSS with RWT/RAP, as I am new to it (not migrating from previous release of Eclipse or RAP).
This is my plugin.xml content:
<extension
point="org.eclipse.rap.ui.themes">
<theme
file="css/mytheme.css"
id="helloRAP.mytheme"
name="mytheme">
</theme>
</extension>
<extension
point="org.eclipse.rap.ui.entrypoint">
<entrypoint
brandingId="helloRAP.mybrand"
class="hellorap.EntryPoint"
id="helloRAP.myentrypoint"
path="mytheme">
</entrypoint>
</extension>
<extension
point="org.eclipse.rap.ui.branding">
<branding
id="helloRAP.mybrand"
themeId="helloRAP.mytheme"
title="My Theme">
</branding>
</extension>
Here is my EntryPoint code (very simple):
package hellorap;
import org.eclipse.rap.rwt.lifecycle.IEntryPoint;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class EntryPoint implements IEntryPoint {
public int createUI() {
Display display = new Display();
Shell shell = new Shell( display );
shell.setLayout( new GridLayout( 1, false ) );
Button button = new Button( shell, SWT.PUSH );
button.setText( "Hello world!" );
shell.pack();
shell.open();
return 0;
}
}
The Run Configuration is an RWT Application, starting classname:
and Servlet Path:
No other parms or arguments.
The RWT Application starts up no problem in the internal browser, and displays ok, but without my CSS customisations applied. Here is my CSS:
* { background-color: white; }
Button[PUSH], Button[TOGGLE] {
order: 2px solid yellow;
color: rgb( 0,0,255 );
background-color: #ffff00;
}
Button[PUSH]:hover, Button[TOGGLE]:hover
background-color: red;
}
Button-CheckIcon:selected {
background-image: url( images/tick.png );
}
I'm probably missing something simple here, perhaps a startup parameter, or something with the servlet path, but don't understand what is happening enough to work it out. I'm concerned it might simply be a bug in RAP 2.0M3 too...?
Any help welcome!
Thanks, John
|
|
|
Re: Themes in RAP 2.0 M3 [message #988257 is a reply to message #987848] |
Thu, 29 November 2012 07:08 |
Ivan Furnadjiev Messages: 2427 Registered: July 2009 Location: Sofia, Bulgaria |
Senior Member |
|
|
Hi Joh,
if you are using extension points you must run your application as "RAP
Application". In case of "RWT standalone" or plain OSGi application you
have to configure your application with the new Application
Configuration API [1]. See [2] for different setups possible with RAP.
[1]
http://help.eclipse.org/juno/topic/org.eclipse.rap.help/help/html/advanced/application-configuration.html
[2]
http://help.eclipse.org/juno/topic/org.eclipse.rap.help/help/html/advanced/application-setup.html
HTH,
Ivan
On 11/28/2012 5:54 PM, John Gymer wrote:
> Has anyone got an example of Themes working with e4.2.1 + RAP 2.0M3 yet?
> Really struggling with this, although have read the "new and noteworthy".
> Just trying to use a simple SWT-style helloworld project to begin
> with, run as RWT, but doesn't seem to matter what I do, the Themes
> defined in Extensions don't get applied.
> Could do with an example project, or step-by-step tutorial to show how
> to set it up...
> It is quite possible I am totally misunderstanding how to use
> Themes/CSS with RWT/RAP, as I am new to it (not migrating from
> previous release of Eclipse or RAP).
>
> This is my plugin.xml content:
>
>
> <extension
> point="org.eclipse.rap.ui.themes">
> <theme
> file="css/mytheme.css"
> id="helloRAP.mytheme"
> name="mytheme">
> </theme>
> </extension>
> <extension
> point="org.eclipse.rap.ui.entrypoint">
> <entrypoint
> brandingId="helloRAP.mybrand"
> class="hellorap.EntryPoint"
> id="helloRAP.myentrypoint"
> path="mytheme">
> </entrypoint>
> </extension>
> <extension
> point="org.eclipse.rap.ui.branding">
> <branding
> id="helloRAP.mybrand"
> themeId="helloRAP.mytheme"
> title="My Theme">
> </branding>
> </extension>
>
>
> Here is my EntryPoint code (very simple):
>
>
> package hellorap;
>
> import org.eclipse.rap.rwt.lifecycle.IEntryPoint;
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.layout.GridLayout;
> import org.eclipse.swt.widgets.Button;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Shell;
>
> public class EntryPoint implements IEntryPoint {
>
> public int createUI() {
> Display display = new Display();
> Shell shell = new Shell( display );
> shell.setLayout( new GridLayout( 1, false ) );
>
> Button button = new Button( shell, SWT.PUSH );
> button.setText( "Hello world!" );
>
> shell.pack();
> shell.open();
> return 0;
> }
> }
>
>
> The Run Configuration is an RWT Application, starting classname:
> hellorap.EntryPoint
> and Servlet Path:
> rap
> No other parms or arguments.
>
> The RWT Application starts up no problem in the internal browser, and
> displays ok, but without my CSS customisations applied. Here is my CSS:
>
>
> * { background-color: white; }
> Button[PUSH], Button[TOGGLE] {
> order: 2px solid yellow;
> color: rgb( 0,0,255 );
> background-color: #ffff00;
> }
> Button[PUSH]:hover, Button[TOGGLE]:hover background-color: red;
> } Button-CheckIcon:selected {
> background-image: url( images/tick.png );
> }
>
>
> I'm probably missing something simple here, perhaps a startup
> parameter, or something with the servlet path, but don't understand
> what is happening enough to work it out. I'm concerned it might simply
> be a bug in RAP 2.0M3 too...?
>
> Any help welcome!
>
> Thanks, John
--
Ivan Furnadjiev
Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/
Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
|
|
|
Re: Themes in RAP 2.0 M3 [message #988381 is a reply to message #988257] |
Thu, 29 November 2012 16:45 |
|
Thanks Ivan,
Have been reading like crazy through all your links and related docs, but still cannot get my theme applied at runtime.
I'm running RWT as Standalone, and have added the Application Configuration as you suggested (note it is a different project to previous example, but same principle):
package iet.rap.launcher;
import org.eclipse.rap.rwt.application.Application;
import org.eclipse.rap.rwt.application.ApplicationConfiguration;
public class RapierConfiguration implements ApplicationConfiguration {
public void configure(Application application) {
application.addEntryPoint( "/rapier", RapierEntryPoint.class, null );
}
}
Have also added web.xml definition for the application as follows:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="...blah blah...">
<context-param>
<param-name>org.eclipse.rap.applicationConfiguration</param-name>
<param-value>iet.rap.launcher.RapierConfiguration</param-value>
</context-param>
<context-param>
<param-name>org.eclipse.rap.rwt.themes</param-name>
<param-value>css/aqua.css</param-value>
</context-param>
<listener>
<listener-class>org.eclipse.rap.rwt.engine.RWTServletContextListener</listener-class>
</listener>
<servlet>
<servlet-name>rwtServlet</servlet-name>
<servlet-class>org.eclipse.rap.rwt.engine.RWTServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>rwtServlet</servlet-name>
<url-pattern>/rapier</url-pattern>
</servlet-mapping>
</web-app>
I think that the reference to the theme above is bogus, but not sure where and how this is supposed to be applied?
The project's plugin.xml now looks like this, although I'm guessing none of this is relevant as I'm launching through the web.xml using Application Configuration:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.rap.ui.themes">
<theme
id="rapier"
name="RapIEr Aqua Theme"
file="css/aqua.css" />
</extension>
<extension
point="org.eclipse.rap.ui.branding">
<branding
id="rapier"
servletName="rapier"
defaultEntrypointId="rapier.entrypoint"
themeId="rapier">
</branding>
</extension>
<extension
point="org.eclipse.rap.ui.entrypoint">
<entrypoint
brandingId="rapier"
class="iet.rap.launcher.RapierEntryPoint"
id="rapier"
path="rapier">
</entrypoint>
</extension>
</plugin>
The CSS (css/aqua.css in this case) is very basic and looks like this (I just put some obviously bold colours in to see if it picked up the CSS at all):
Button[PUSH], Button[TOGGLE] {
border: 2px solid blue;
color: rgb( 255,0,0 );
background-color: #0,255,0;
}
Text[SINGLE] {
border: 2px solid blue;
color: rgb( 255,127,0 );
background-color: #0,127,255;
}
Button[PUSH]:hover, Button[TOGGLE]:hover {
background-color: white;
}
The RunAs Configuration uses web.xml from my WEB-INF/lib folder and specifies a Servlet Path of 'rapier'. The application starts up and runs just fine, but without the CSS styling applied anywhere.
Perhaps my expectations are incorrect here and I'm not launching it correctly, but I'm just not understanding whether I've specified the theme usage correctly. Should I be specifying the theme somehow at launch time, or in the Application Configuration java... or something else?
More help greatly appreciated!
John
|
|
|
Re: Themes in RAP 2.0 M3 [message #988388 is a reply to message #988381] |
Thu, 29 November 2012 17:23 |
Ivan Furnadjiev Messages: 2427 Registered: July 2009 Location: Sofia, Bulgaria |
Senior Member |
|
|
Hi John,
you have to change your RapierConfiguration#configure method:
....
public class RapierConfiguration implements ApplicationConfiguration {
public void configure(Application application) {
Map<String, String> properties = new HashMap<String, String>();
properties.put( WebClient.THEME_ID, "rapier" );
application.addEntryPoint( "/rapier", RapierEntryPoint.class,
properties );
application.addStyleSheet( "rapier", "css/aqua.css" );
}
}
....
HTH,
Ivan
On 11/29/2012 6:45 PM, John Gymer wrote:
> Thanks Ivan,
>
> Have been reading like crazy through all your links and related docs,
> but still cannot get my theme applied at runtime.
>
> I'm running RWT as Standalone, and have added the Application
> Configuration as you suggested (note it is a different project to
> previous example, but same principle):
>
>
> package iet.rap.launcher;
>
> import org.eclipse.rap.rwt.application.Application;
> import org.eclipse.rap.rwt.application.ApplicationConfiguration;
>
> public class RapierConfiguration implements ApplicationConfiguration {
> public void configure(Application application) {
> application.addEntryPoint( "/rapier", RapierEntryPoint.class,
> null );
> }
> }
>
>
> Have also added web.xml definition for the application as follows:
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <web-app xmlns="...blah blah...">
>
> <context-param>
> <param-name>org.eclipse.rap.applicationConfiguration</param-name>
> <param-value>iet.rap.launcher.RapierConfiguration</param-value>
> </context-param>
>
> <context-param>
> <param-name>org.eclipse.rap.rwt.themes</param-name>
> <param-value>css/aqua.css</param-value>
> </context-param>
>
> <listener>
> <listener-class>org.eclipse.rap.rwt.engine.RWTServletContextListener</listener-class>
> </listener>
>
> <servlet>
> <servlet-name>rwtServlet</servlet-name>
> <servlet-class>org.eclipse.rap.rwt.engine.RWTServlet</servlet-class>
> </servlet>
>
> <servlet-mapping>
> <servlet-name>rwtServlet</servlet-name>
> <url-pattern>/rapier</url-pattern>
> </servlet-mapping>
> </web-app>
>
> I think that the reference to the theme above is bogus, but not sure
> where and how this is supposed to be applied?
>
> The project's plugin.xml now looks like this, although I'm guessing
> none of this is relevant as I'm launching through the web.xml using
> Application Configuration:
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <?eclipse version="3.4"?>
> <plugin>
> <extension
> point="org.eclipse.rap.ui.themes">
> <theme
> id="rapier"
> name="RapIEr Aqua Theme"
> file="css/aqua.css" />
> </extension>
> <extension
> point="org.eclipse.rap.ui.branding">
> <branding
> id="rapier"
> servletName="rapier"
> defaultEntrypointId="rapier.entrypoint"
> themeId="rapier">
> </branding>
> </extension>
> <extension
> point="org.eclipse.rap.ui.entrypoint">
> <entrypoint
> brandingId="rapier"
> class="iet.rap.launcher.RapierEntryPoint"
> id="rapier"
> path="rapier">
> </entrypoint>
> </extension>
> </plugin>
>
>
> The CSS (css/aqua.css in this case) is very basic and looks like this
> (I just put some obviously bold colours in to see if it picked up the
> CSS at all):
>
>
> Button[PUSH], Button[TOGGLE] {
> border: 2px solid blue;
> color: rgb( 255,0,0 );
> background-color: #0,255,0;
> }
>
> Text[SINGLE] {
> border: 2px solid blue;
> color: rgb( 255,127,0 );
> background-color: #0,127,255;
> }
>
> Button[PUSH]:hover, Button[TOGGLE]:hover {
> background-color: white;
> }
>
>
> The RunAs Configuration uses web.xml from my WEB-INF/lib folder and
> specifies a Servlet Path of 'rapier'. The application starts up and
> runs just fine, but without the CSS styling applied anywhere.
>
> Perhaps my expectations are incorrect here and I'm not launching it
> correctly, but I'm just not understanding whether I've specified the
> theme usage correctly. Should I be specifying the theme somehow at
> launch time, or in the Application Configuration java... or something
> else?
>
> More help greatly appreciated!
> John
>
--
Ivan Furnadjiev
Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/
Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
|
|
|
Re: Themes in RAP 2.0 M3 [message #988530 is a reply to message #988388] |
Fri, 30 November 2012 11:26 |
|
Thanks again Ivan, that solution makes sense. Feel like I'm almost there now...
However, for some reason it cannot access the CSS file as a resource, which is included in the binary of the project. Here is the runtime error:
2012-11-30 11:21:08.468:INFO:oejs.Server:jetty-8.1.3.v20120522
2012-11-30 11:21:08.631:INFO:oejw.StandardDescriptorProcessor:NO JSP Support for /, did not find org.apache.jasper.servlet.JspServlet
2012-11-30 11:21:08.691:INFO:oejsh.ContextHandler:started o.e.j.w.WebAppContext{/,file:/C:/JVM/Eclipse421/workspace/.metadata/.plugins/org.eclipse.rap.ui.launch.rwt/RWT%20from%20web.xml/web-app/},C:\JVM\Eclipse421\workspace\.metadata\.plugins\org.eclipse.rap.ui.launch.rwt\RWT from web.xml\web-app
2012-11-30 11:21:08.691:INFO:oejsh.ContextHandler:started o.e.j.w.WebAppContext{/,file:/C:/JVM/Eclipse421/workspace/.metadata/.plugins/org.eclipse.rap.ui.launch.rwt/RWT%20from%20web.xml/web-app/},C:\JVM\Eclipse421\workspace\.metadata\.plugins\org.eclipse.rap.ui.launch.rwt\RWT from web.xml\web-app
2012-11-30 11:21:08.988:WARN:oejw.WebAppContext:Failed startup of context o.e.j.w.WebAppContext{/,file:/C:/JVM/Eclipse421/workspace/.metadata/.plugins/org.eclipse.rap.ui.launch.rwt/RWT%20from%20web.xml/web-app/},C:\JVM\Eclipse421\workspace\.metadata\.plugins\org.eclipse.rap.ui.launch.rwt\RWT from web.xml\web-app
java.lang.IllegalArgumentException: Could not open resource css/aqua.css
at org.eclipse.rap.rwt.internal.theme.css.CssFileReader.readStyleSheet(CssFileReader.java:52)
at org.eclipse.rap.rwt.internal.application.ApplicationImpl.readStyleSheet(ApplicationImpl.java:159)
at org.eclipse.rap.rwt.internal.application.ApplicationImpl.addStyleSheet(ApplicationImpl.java:123)
at org.eclipse.rap.rwt.internal.application.ApplicationImpl.addStyleSheet(ApplicationImpl.java:115)
at iet.rap.launcher.RapierConfiguration.configure(RapierConfiguration.java:14)
...
css/aqua.css exists off the root of the project.
Thanks, John
---
Just because you can doesn't mean you should
|
|
|
Re: Themes in RAP 2.0 M3 [message #988654 is a reply to message #988530] |
Fri, 30 November 2012 21:50 |
Ivan Furnadjiev Messages: 2427 Registered: July 2009 Location: Sofia, Bulgaria |
Senior Member |
|
|
Hi John,
my first suspicion is spaces in the path - "RWT from web.xml"... Try to
make the path without spaces.
Best,
Ivan
On 11/30/2012 1:26 PM, John Gymer wrote:
> Thanks again Ivan, that solution makes sense. Feel like I'm almost
> there now...
>
> However, for some reason it cannot access the CSS file as a resource,
> which is included in the binary of the project. Here is the runtime
> error:
>
>
> 2012-11-30 11:21:08.468:INFO:oejs.Server:jetty-8.1.3.v20120522
> 2012-11-30 11:21:08.631:INFO:oejw.StandardDescriptorProcessor:NO JSP
> Support for /, did not find org.apache.jasper.servlet.JspServlet
> 2012-11-30 11:21:08.691:INFO:oejsh.ContextHandler:started
> o.e.j.w.WebAppContext{/,file:/C:/JVM/Eclipse421/workspace/.metadata/.plugins/org.eclipse.rap.ui.launch.rwt/RWT%20from%20web.xml/web-app/},C:\JVM\Eclipse421\workspace\.metadata\.plugins\org.eclipse.rap.ui.launch.rwt\RWT
> from web.xml\web-app
> 2012-11-30 11:21:08.691:INFO:oejsh.ContextHandler:started
> o.e.j.w.WebAppContext{/,file:/C:/JVM/Eclipse421/workspace/.metadata/.plugins/org.eclipse.rap.ui.launch.rwt/RWT%20from%20web.xml/web-app/},C:\JVM\Eclipse421\workspace\.metadata\.plugins\org.eclipse.rap.ui.launch.rwt\RWT
> from web.xml\web-app
> 2012-11-30 11:21:08.988:WARN:oejw.WebAppContext:Failed startup of
> context
> o.e.j.w.WebAppContext{/,file:/C:/JVM/Eclipse421/workspace/.metadata/.plugins/org.eclipse.rap.ui.launch.rwt/RWT%20from%20web.xml/web-app/},C:\JVM\Eclipse421\workspace\.metadata\.plugins\org.eclipse.rap.ui.launch.rwt\RWT
> from web.xml\web-app
> java.lang.IllegalArgumentException: Could not open resource css/aqua.css
> at
> org.eclipse.rap.rwt.internal.theme.css.CssFileReader.readStyleSheet(CssFileReader.java:52)
> at
> org.eclipse.rap.rwt.internal.application.ApplicationImpl.readStyleSheet(ApplicationImpl.java:159)
> at
> org.eclipse.rap.rwt.internal.application.ApplicationImpl.addStyleSheet(ApplicationImpl.java:123)
> at
> org.eclipse.rap.rwt.internal.application.ApplicationImpl.addStyleSheet(ApplicationImpl.java:115)
> at
> iet.rap.launcher.RapierConfiguration.configure(RapierConfiguration.java:14)
> ..
>
>
> css/aqua.css exists off the root of the project.
>
> Thanks, John
>
--
Ivan Furnadjiev
Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/
Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
|
|
|
Re: Themes in RAP 2.0 M3 [message #988806 is a reply to message #988654] |
Mon, 03 December 2012 09:59 |
|
Nice guess, but unfortunately not the one... same problem...
2012-12-03 09:35:54.588:INFO:oejs.Server:jetty-8.1.3.v20120522
2012-12-03 09:35:54.732:INFO:oejw.StandardDescriptorProcessor:NO JSP Support for /, did not find org.apache.jasper.servlet.JspServlet
2012-12-03 09:35:54.781:INFO:oejsh.ContextHandler:started o.e.j.w.WebAppContext{/,file:/C:/JVM/Eclipse421/workspace/.metadata/.plugins/org.eclipse.rap.ui.launch.rwt/RAPFromWeb.xml/web-app/},C:\JVM\Eclipse421\workspace\.metadata\.plugins\org.eclipse.rap.ui.launch.rwt\RAPFromWeb.xml\web-app
2012-12-03 09:35:54.781:INFO:oejsh.ContextHandler:started o.e.j.w.WebAppContext{/,file:/C:/JVM/Eclipse421/workspace/.metadata/.plugins/org.eclipse.rap.ui.launch.rwt/RAPFromWeb.xml/web-app/},C:\JVM\Eclipse421\workspace\.metadata\.plugins\org.eclipse.rap.ui.launch.rwt\RAPFromWeb.xml\web-app
2012-12-03 09:35:55.072:WARN:oejw.WebAppContext:Failed startup of context o.e.j.w.WebAppContext{/,file:/C:/JVM/Eclipse421/workspace/.metadata/.plugins/org.eclipse.rap.ui.launch.rwt/RAPFromWeb.xml/web-app/},C:\JVM\Eclipse421\workspace\.metadata\.plugins\org.eclipse.rap.ui.launch.rwt\RAPFromWeb.xml\web-app
java.lang.IllegalArgumentException: Could not open resource css/aqua.css
at org.eclipse.rap.rwt.internal.theme.css.CssFileReader.readStyleSheet(CssFileReader.java:52)
...
Is this whole Theme business registered and applied programmatically now, or do I need to register it in Extensions/ExPoints? I'm assuming the whole thing is programmatic (i.e. in my ApplicationConfiguration implementation class)? This looks like this now:
package iet.co.uk.rapier.launcher;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.rap.rwt.application.Application;
import org.eclipse.rap.rwt.application.ApplicationConfiguration;
import org.eclipse.rap.rwt.client.WebClient;
public class RapierConfiguration implements ApplicationConfiguration {
public void configure(Application application) {
Map<String, String> properties = new HashMap<String, String>();
properties.put(WebClient.THEME_ID, "rapier");
application.addStyleSheet("rapier", "css/aqua.css");
application.addEntryPoint( "/rapier", RapierEntryPoint.class, properties);
}
}
I've even tried referencing the CSS file as an absolute path on my workstation, but that didn't work.
It is almost like it is insisting that the CSS file is somehow included as a special resource, and I need to register it via a resource loader, and goodness knows what.
Unfortunately I'm not offay enough was RAP to understand what it is trying to do under the covers, so it is hard to guess what to try next.
Is there a possibility that there is actually a problem with CSS themes in RAP 2.0M3? Could someone actually create an example (I'm using Eclipse 4.2.1 remember), and post it as reference to show it working please?
Any suggestions most welcome.
Thanks, John
---
Just because you can doesn't mean you should
|
|
|
Re: Themes in RAP 2.0 M3 [message #988829 is a reply to message #988806] |
Mon, 03 December 2012 11:15 |
|
Hold the press!
Got it working... the problem was the location of the CSS files... I assumed that the resources should be loaded relative to the project root, but in fact it was relative to the source root. Moving the CSS folder alongside my 'SRC' source folder was enough for it to start working (hopefully the image will display ok...):
Job done... thanks Ivan for your responses on this too!
John
---
Just because you can doesn't mean you should
|
|
|
Goto Forum:
Current Time: Thu Oct 31 23:52:11 GMT 2024
Powered by FUDForum. Page generated in 0.07150 seconds
|