Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 428715 - [CSS] [Themes] org.eclipse.ui.themes plugin throws java.net.MalformedURLException when used in RCP app
Summary: [CSS] [Themes] org.eclipse.ui.themes plugin throws java.net.MalformedURLExce...
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.4   Edit
Hardware: PC Windows 8
: P3 normal (vote)
Target Milestone: 4.4 M6   Edit
Assignee: Daniel Rolka CLA
QA Contact: Daniel Rolka CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-21 04:42 EST by Phil Beauvoir CLA
Modified: 2014-03-04 12:26 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Phil Beauvoir CLA 2014-02-21 04:42:25 EST
Build id: I20140218-0800

I added the the org.eclipse.ui.themes plugin (See Bug #420836) to the Run configuration of my RCP application (e3 based but using the compatibility layer). When selecting the dark theme I get:

java.net.MalformedURLException
	at java.net.URL.<init>(URL.java:619)
	at java.net.URL.<init>(URL.java:482)
	at java.net.URL.<init>(URL.java:431)
	at org.eclipse.e4.ui.css.core.impl.engine.AbstractCSSEngine.parseStyleSheet(AbstractCSSEngine.java:203)
	at org.eclipse.e4.ui.css.swt.internal.theme.ThemeEngine.setTheme(ThemeEngine.java:421)
	at org.eclipse.e4.ui.css.swt.internal.theme.ThemeEngine.setTheme(ThemeEngine.java:382)
	at org.eclipse.e4.ui.css.swt.internal.theme.ThemeEngine.restore(ThemeEngine.java:546)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.initializeStyling(PartRenderingEngine.java:1248)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1009)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1006)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:147)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:620)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:571)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at com.archimatetool.editor.Application.start(Application.java:73)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)

Setting a breakpoint on engine.parseStyleSheet(source); I get this URL:

platform:/plugin/org.eclipse.ui.themes/css/e4-dark.css
Comment 1 Phil Beauvoir CLA 2014-02-21 04:48:43 EST
The URL is:

file:/C:/dev/eclipse4.4/plugins/org.eclipse.ui.themes_1.0.0.v20140212-1427/css/e4-dark.css
Comment 2 Lars Vogel CLA 2014-02-21 04:50:36 EST
(In reply to Phillipus B from comment #1)
> The URL is:
> 
> file:/C:/dev/eclipse4.4/plugins/org.eclipse.ui.themes_1.0.0.v20140212-1427/
> css/e4-dark.css

Can you try to use the platform URI? That is what we are using in the platform. See dark theme for an example how to use it.
Comment 3 Phil Beauvoir CLA 2014-02-21 04:53:42 EST
In AbstractCSSEngine#parseStyleSheet(InputSource source) this is what happens:

String path = getResourcesLocatorManager().resolve(((CSSImportRule) rule).getHref());

path is null so the next line fails:

testFile = new File(new URL(path).getFile());

and the exception is thrown.
Comment 4 Phil Beauvoir CLA 2014-02-21 04:56:43 EST
(In reply to Lars Vogel from comment #2)
> (In reply to Phillipus B from comment #1)
> > The URL is:
> > 
> > file:/C:/dev/eclipse4.4/plugins/org.eclipse.ui.themes_1.0.0.v20140212-1427/
> > css/e4-dark.css
> 
> Can you try to use the platform URI? That is what we are using in the
> platform. See dark theme for an example how to use it.

Setting a breakpoint on engine.parseStyleSheet(source); I get this URL:

platform:/plugin/org.eclipse.ui.themes/css/e4-dark.css

I don't do anything special. I get registered themes like this:

List<ITheme> themes = fThemeEngine.getThemes();

Get the dark theme and call:

fThemeEngine.setTheme(theme, true);
Comment 5 Phil Beauvoir CLA 2014-02-21 05:04:27 EST
I created my own theme plugin which is a copy of the org.eclipse.ui.themes plugin. I included that in the Run config of my RCP app.

Same problem.
Comment 6 Phil Beauvoir CLA 2014-02-21 05:22:58 EST
If I remove the lines:

@import url("platform:/plugin/org.eclipse.platform/css/e4_basestyle.css"); 
@import url("platform:/plugin/org.eclipse.ui.themes/css/e4-dark-config-parts.css");

from the dark theme it works OK.
Comment 7 Phil Beauvoir CLA 2014-02-21 05:28:10 EST
So I changed the lines to:

@import url(""platform:/plugin/org.eclipse.platform/css/e4_basestyle.css"); 
@import url("e4-dark-config-parts.css");

And it works OK.
Comment 8 Lars Vogel CLA 2014-02-21 05:31:35 EST
(In reply to Phillipus B from comment #7)
> So I changed the lines to:
> 
> @import url(""platform:/plugin/org.eclipse.platform/css/e4_basestyle.css"); 
> @import url("e4-dark-config-parts.css");
> 
> And it works OK.

Thanks for the testing. Looks like the error is in public StyleSheet parseStyleSheet(InputSource source) throws IOException  of AbstractCSSEngine.java

I continue to investigate
Comment 9 Phil Beauvoir CLA 2014-02-21 05:33:43 EST
So, it's my bad.

Include

org.eclipse.ui.themes
org.eclipse.platform

in dependencies and it's OK.

Sorry to waste your time and the noise. ;-)
Comment 10 Paul Webster CLA 2014-02-21 05:47:16 EST
(In reply to Phillipus B from comment #9)
> So, it's my bad.
> 
> Include
> 
> org.eclipse.ui.themes
> org.eclipse.platform

Are you saying you had to include org.eclipse.platform to get this plugin to work?  That still sounds like there's something wrong with the plugin or themes.

PW
Comment 11 Paul Webster CLA 2014-02-21 05:49:09 EST
Lars, have you been able to reproduce?  We still have references to org.eclipse.platform in org.eclipse.e4.ui.css.swt.internal.theme.ThemeEngine.ThemeEngine(Display)  They should probably default to org.eclipse.ui.themes now.

PW
Comment 12 Lars Vogel CLA 2014-02-21 05:59:16 EST
(In reply to Phillipus B from comment #9)
> So, it's my bad.
> 
> Include
> 
> org.eclipse.ui.themes
> org.eclipse.platform
> 
> in dependencies and it's OK.
> 
> Sorry to waste your time and the noise. ;-)

Are you using the platform URI for this or the local one?
Comment 13 Lars Vogel CLA 2014-02-21 06:21:08 EST
(In reply to Paul Webster from comment #11)
> Lars, have you been able to reproduce?  We still have references to
> org.eclipse.platform in
> org.eclipse.e4.ui.css.swt.internal.theme.ThemeEngine.ThemeEngine(Display) 
> They should probably default to org.eclipse.ui.themes now.
> 

Gerrit review for the change of the default, https://git.eclipse.org/r/#/c/22353 I still need to clean this up, it includes the functional change as well as @Override changes.
Comment 14 Lars Vogel CLA 2014-02-21 06:28:22 EST
(In reply to Lars Vogel from comment #13)
> (In reply to Paul Webster from comment #

https://git.eclipse.org/r/#/c/22353 should be fine now.
Comment 15 Phil Beauvoir CLA 2014-02-21 06:32:17 EST
(In reply to Paul Webster from comment #10)
> (In reply to Phillipus B from comment #9)
> > So, it's my bad.
> > 
> > Include
> > 
> > org.eclipse.ui.themes
> > org.eclipse.platform
> 
> Are you saying you had to include org.eclipse.platform to get this plugin to
> work?  That still sounds like there's something wrong with the plugin or
> themes.
> 
> PW

Yes.
Comment 16 Lars Vogel CLA 2014-02-21 06:46:50 EST
(In reply to Phillipus B from comment #15)
> (In reply to Paul Webster from comment #10)
> > > org.eclipse.ui.themes
> > > org.eclipse.platform
> > Are you saying you had to include org.eclipse.platform to get this plugin to
> > work?  That still sounds like there's something wrong with the plugin or
> > themes.
> > 
> > PW
> 
> Yes.

I think the processing of the CSS import statements was not considering the situation in which the import specifies the platform:/ URI. Proposed fix:

https://git.eclipse.org/r/#/c/22355/
Comment 17 Lars Vogel CLA 2014-02-21 06:50:14 EST
Phillipus, are your familiar enough with the Eclipse platform code to test the change in the Gerrit review? Would be great to see if your Eclipse 3.X example work. I tested with an Eclipse 4 RCP application and the includes work fine for my test scenario. To test this you would clone the eclipse platform repo and apply the Gerrit change on top of it. See http://www.vogella.com/tutorials/Gerrit/article.html for a little introduction into Gerrit.
Comment 19 Lars Vogel CLA 2014-02-21 08:16:38 EST
(In reply to Daniel Rolka from comment #18)
> Thanks for patch. Released as:
> http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/
> ?id=a68ba21575cd6402c83d00781c740ad66bc37a4a
> 
> Daniel

Thanks. As discussed with should remove the default platform URL from the CSS import logic. I updated the other Gerrit review to include that change (depends on this released patch)

https://git.eclipse.org/r/#/c/22353
Comment 20 Lars Vogel CLA 2014-03-04 12:25:56 EST
Verified in Build id: I20140303-2000

Created style sheet with only one instruction

@import url("platform:/plugin/org.eclipse.ui.themes/css/e4-dark.css");

Added org.eclipse.ui.themes to product and entered the applicationCSS to platform:/plugin/test/css/default.css -> application is "dark"
Comment 21 Lars Vogel CLA 2014-03-04 12:26:11 EST
Verified