I'm trying to simply update the look and feel of Eclipse Juno 4.2 via CSS stylesheets. There are a couple of tutorials I've seen, and a stackoverflow question:
I've installed the CSS spy tool, but this only lets me make temporary changes. Sigh. I've gone into the org.eclipse.platform_4.2.0.v201206081400
plugin folder, and mucked around with the plugin.xml
, but none of the changes I make there have any effects (even after a restart).
How do I create a new theme and apply it WITHOUT creating, compiling and installing an entire eclipse plugin project to my local environment? Or, even better, can I just modify an existing theme?
Here is how I got it working.
I have downloaded Eclipse UI Themes plugin as described here (direct link to an archive). But instead of extracting it into dropins
directory, I extracted it into plugins
. Also I changed its permissions to allow everyone to modify its files.
At this point you have:
plugins/com.github.eclipsecolortheme.themes_1.0.0.201207121019/ ├── com │ └── github │ └── eclipsecolortheme │ └── themes │ └── Activator.class ├── META-INF │ └── MANIFEST.MF ├── plugin.xml └── themes └── css └── juno.css
juno.css
file is what you want. After launching Eclipse, this theme will be available under Appearance -> Dark Juno.
After looking into plugin.xml
, I had an idea how to create a new theme without using any plugin.
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.e4.ui.css.swt.theme">
<theme
basestylesheeturi="themes/css/juno.css"
id="com.github.eclipsecolortheme.themes.darkjuno"
label="Dark Juno">
</theme>
</extension>
</plugin>
One can add org.eclipse.e4.ui.css.swt.theme
extension point to an existing plugin, say org.eclipse.platform_4.2.0.v201206081400
. Moreover, its plugin.xml
already have this extension point, and the only thing you have to do is to add an appropriate theme
. Please note, that it must have a unique id
.
<theme
basestylesheeturi="css/my_theme.css"
id="org.eclipse.e4.ui.css.theme.my_theme"
label="My Theme Name">
</theme>
A new CSS file can be placed into the css
directory, which already contains the default set of themes.
org.eclipse.platform_4.2.0.v201206081400/ ├── ... ├── css │ ├── e4_basestyle.css │ ├── e4_classic_win7.css │ ├── e4_classic_winxp.css │ ├── e4_default.css │ ├── e4_default_gtk.css │ └── ... ├── images │ ├── gtkGrey.png │ ├── gtkHandleDark.png │ ├── gtkHandle.png │ ├── gtkTSFrameDark.png │ ├── gtkTSFrame.png │ └── ... ├── META-INF │ ├── eclipse.inf │ ├── ECLIPSE_.RSA │ ├── ECLIPSE_.SF │ └── MANIFEST.MF ├── platform.jar ├── plugin.properties ├── plugin.xml └── ...
After restarting Eclipse with -clean
option you will see a newly created item in the list of all themes:
For my installation it seems that changes to CSS apply on Eclipse restarting (File -> Restart, or just quitting and starting it manually).
The only weird behavior I have noticed is that CSS files from ~/.e4css
directory (if any exists) override thus ones from the plugin directory. I'm not sure where it comes from, but I can safely remove any files from it. I also don't know this directory even exists on non-Linux systems, but if it does, I guess it should be located somewhere in a home directory of the user, or maybe in Documents
.
I just tried to add a new theme from scratch and noticed that there was a small mistake in the XML above. In order to get a new theme properly registered it must have a unique id
attribute. Otherwise you will get an error:
java.lang.IllegalArgumentException: A theme with the id 'org.eclipse.e4.ui.css.theme.e4_default' is already registered
at org.eclipse.e4.ui.css.swt.internal.theme.ThemeEngine.registerTheme(ThemeEngine.java:186)
...
And it seems that I were not right saying just restarting Eclipse to register a new theme is enough. However, eclipse -clean
does the trick.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With