Posted in Tutorials
Welcome page in Eclipse provides you a unique way to introduce your product to the new users. Its very flexible and can be extended by other plugins. You can create the entire Welcome view by yourself by extending the org.eclipse.ui.intro and provide all the contents you want. That is little tedius, and in this tutorial, we are going to explore an easier one - the CustomizableIntroPart.
We are going to explore two scenarios. The first one is to extend the Welcome pages of an existing product with your plugin's element. This is pretty simple.
All you need to do is to extend org.eclipse.ui.intro.configExtension and provide your implementation.
The contents of the xml is XHTML, so you can have all those web goodies (CSS, images, etc) you want to have. Here is the schema for the XHTML. I have added a simple link to this Eclipse Tips website in the xml:
<?xml version="1.0" encoding="utf-8" ?>
<extensionContent id="comeclipsetipsintro-introExtension" style="css/sample.css" name="Sample Extension" path="webresources/@">
<group style-id="content-group" id="comeclipsetipsintro-introLink-group">
<link label="Eclipse Tips" url="http://www.eclipse-tips.com" id="comeclipsetipsintro-introLink" style-id="content-link">
<text>This site provides you helpful information, tips and tricks of Eclipse plug-in development</text>
The path element in the extensionContent defines where your content goes into. I've added my content to Web Resources. Instead if you want to add your content to other sections like Overview/Tutorials/Samples you can specify it here. Now launch the plugin you would see this nice link in the Web Resources of the Welcome page:
Now let us see the second scenario. You are building an IDE/RCP application and wanted to brand the Welcome page and let others contribute to it. First create the default RCP Mail Application and a product configuration. Next add org.eclipse.ui.intro and org.eclipse.ui.intro.universal to the plugin's dependencies. Edit the product configuration and these two plugins + org.eclipse.ui.forms as dependencies.
Now you can launch the product to see the default RCP Mail in action. We haven't configured the intro yet, so you won't see it. To have intro in our RCP App, first you need to bind an intro to the product. This is done by extending org.eclipse.ui.intro:
Now if you launch the product, you will see an intro page. But it would be something like this:
Lets fix the missing pieces. First, lets do the branding. We would need our own logo and our own intro title there. This is done by adding properties in the org.eclipse.core.runtime.products extension
<extension id="product" point="org.eclipse.core.runtime.products">
<product application="com.eclipse-tips.rcp.mail.application" name="RCP Product">
... other properties here ...
<property name="introBrandingImage" value="product:icons/eclipse_tips.png"/>
<property name="introTitle" value="RCP Mail in Eclipse Tips"/>
The branding image should be specified in the product:<path> format. Once you specify this, you would get these in the welcome page, yet, the page would be still odd. Its because you haven't specified the default theme to use. The theme is specificed in the plugin_customization.ini file. Create the file at the root of your plugin and add this line:
org.eclipse.ui.intro/INTRO_THEME = org.eclipse.ui.intro.universal.slate
You can choose other themes if you want. Now the initial welcome page will not have any root pages. Specify the root pages you want as a comma seperated value
org.eclipse.ui.intro.universal/INTRO_ROOT_PAGES = overview,tutorials,samples,whatsnew,webresources
Save and launch the application, now you have a nicely branded Welcome page:
Once the user closes this, there is no way for him to restore the welcome page. So lets add a menu item. This is done in the ApplicationActionBarAdvisor class. Along with other actions, create the Intro action and add it to the help menu:
// in makeActions()
introAction = ActionFactory.INTRO.create(window);
// in fillMenubar()
There you go:
Click here to download the source for both these projects.