Scaring Children with Your User Interface

If you’ve found the “Colors and Fonts” page in the Eclipse Workspace Preferences, then you already know that you can customize Eclipse to look as awful as you’d like. Or maybe you went different route and changed the colors and fonts to better suit your personal tastes.

Many aspects of the workbench can be tuned. When you change a value, it’s stuffed into a preferences store and kept on your disc so that those preferences come back the next time you start. More specifically, those preferences are stored in files found in the [workspace]‌/.metadata‌/.plugins‌/org.eclipse.core.runtime‌/.settings directory.

You can override the default preferences in your Eclipse product (or RCP application) without making the user play around in the preferences dialog. This is done by providing preferences overrides. You do this by adding a property to your product declaration in the plugin.xml file like this:

<extension id="product" point="org.eclipse.core.runtime.products">
    <product application="PlayingWithPrefs.application" name="RCP Product">
        <property name="preferenceCustomization" value="preferences.ini"/>
    </product>
</extension>

With this addition in place, the preferences.ini file—located in the plug-in’s root—is defined. Here’s an example:

# Use curvy tabs
org.eclipse.ui/SHOW_TRADITIONAL_STYLE_TABS=false

# Tabs display in a large italicized font.
org.eclipse.ui.workbench/org.eclipse.ui.workbench.TAB_TEXT_FONT=1|Tahoma|15.75|2|WINDOWS|1|-21|0|0|0|400|1|0|0|0|3|2|1|34|Tahoma;

# The active tab displays as red to green gradient with blue text (yuck)
org.eclipse.ui.workbench/org.eclipse.ui.workbench.ACTIVE_TAB_BG_END=255,0,0
org.eclipse.ui.workbench/org.eclipse.ui.workbench.ACTIVE_TAB_BG_START=0,255,0
org.eclipse.ui.workbench/org.eclipse.ui.workbench.ACTIVE_TAB_TEXT_COLOR=0,0,255

# The inactive tab displays as blue to green gradient with red text (yuckers)
org.eclipse.ui.workbench/org.eclipse.ui.workbench.INACTIVE_TAB_BG_END=0,0,255
org.eclipse.ui.workbench/org.eclipse.ui.workbench.INACTIVE_TAB_BG_START=0,255,0
org.eclipse.ui.workbench/org.eclipse.ui.workbench.INACTIVE_TAB_TEXT_COLOR=255,0,0

And here’s what the RCP Mail sample application looks like with these customizations applied:

You can set more than just look and feel preferences as well. You can override any value that’s stored in preferences. If you look through the .settings directory, you can get a sense for the kinds of preferences you can override in your Eclipse product.

This entry was posted in Uncategorized. Bookmark the permalink.

5 Responses to Scaring Children with Your User Interface

  1. pookzilla says:

    Instead of dorking with the preference directly you could also make use of the Themes API and define your own Ugly RCP theme.

  2. Trace Windham says:

    Thanks for the tip Wayne.One point I would like to bring up is that these properties change only a small portion of the application.Are there any plans for the Eclipse team to make RCP applications completely “skinable”? By “completely”, I mean modifying the colors and fonts of the Menu Bar (WorkBench’s and View’s), Tool Bar (WorkBench’s and View’s), Status Line, Perspective Bar, Page Contents area, and Trim Area. It’s looking like I will have to do this in my application’s ApplicationWorkbenchWindowAdvisor in the createWindowContents method.I was hoping for a more elegant way, because now I will have to keep track of color changes in more than one place.Thanks for all your help.See you next time you’re in Dallas.

  3. Terry says:

    I was wondering if it was possible to mess with that stuff dynamically. I am writing emergency management software, and I would dearly love to flash the tab when there is an alarm on a tab that is not in the foreground.

  4. Wayne says:

    You can bring a view to the top by invoking showView() again. I’ll see if I can sort out how to flash the tab…

  5. Pingback: Marten Wakefield

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s