Creating a simple "Hello World" RCP Application

This will be a series of tutorials for RCP completeing everything about RCP. Let us start from what RCP is.

What is RCP (Rich Client Platform)

RCPs are simple Java application with Graphical User Interface. RCP is created based on Eclipse applications. It is pretty easy to learn RCP and Eclipse provides us simple RCP wizard as well.

Let us create a simple RCP application. But, before that we need to download the Eclipse editor for this purpose as normal Eclipse for Java/JEE doesn't support this.

Here is the link for downloading Eclipse for RCP developers(luna)

Once you are done with downloading , extract the eclipse to your preferred location. And, you are ready to go!



Creating Simple RCP Application.

Step 1: Click on File -> New -> Other -> Plugin-project


Step 2: Click on Next . Then , provide name of the plugin you are going to create. I provided the name "HelloWorld". Left all the fields untouched. 



Step 3: Click on Next. A new window will be opened where we need to give more details. Or, you can simple accept the data which is provided by Eclipse. In vendor field, you can provide your own name or your company's name.
Note: Make the yes radio button selected for Would you like to create a 3.x rich client Application?


Step 4: Click Next. Some available templates will be displayed in the window. Select  Hello RCP template and click Finish. A window will be opened to ask if you want to open the perspective for Plugin development. If you don't want to open, click on No. After that the project will be created and MANIFEST.MF will be opened as overview of the project in Eclipse.



Step 5: Check the project structure.


Step 6: Run the Prject.
You can run it by
 a. Right click on the project ->  Run As -> Eclipse Application
or
b. On Overview of MANIFEST.MF, there is a link Launch an Eclipse Application . Click on that.

Here is the output.


Pretty easy!


But, if you are wondering how to add more functionalities to it, I will say, more post are coming on this. Believe me, I have wasted a lot of time on this.
But, a simple modification in this. Where does this name comes from on the title bar of the window? 
We will have to see the code for this.








Open file ApplicationWorkbenchWindowAdvisor.java.

import org.eclipse.swt.graphics.Point;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
import org.eclipse.ui.application.WorkbenchWindowAdvisor;

public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {

    public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
        super(configurer);
    }

    public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) {
        return new ApplicationActionBarAdvisor(configurer);
    }
    
    public void preWindowOpen() {
        IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
        configurer.setInitialSize(new Point(400, 300));
        configurer.setShowCoolBar(false);
        configurer.setShowStatusLine(false);
        configurer.setTitle("Hello RCP"); //$NON-NLS-1$
    }
}

Simply change the text in line :  configurer.setTitle("Hello RCP");   and write whatever you want. And run it!

Also Read:

Exporting a RCP Application as a Product
Adding a View in RCP

Happy Learning!