Web Development | Ios and Android App Development Company in Charlotte Nc
+1 704 215 4622
[email protected]

Convertion of an eclipse plugin to a standalone RCP application

The platform-independent Eclipse RCP architecture makes rich-client applications easy to write as the business logic is organized into reusable components called plugins. In this article, We are going to convert Mylyn 2.2 Release Plugin to a standalone RCP application. I choose Mylyn because it is one of the most popular eclipse plugin known to all. I assume that Eclipse IDE is already installed and running. I have used Eclipse Europa 3.3.0 in this tutorial.

1.Firstly we need to get the Mylyn 2.2 Release plugin and install it in our eclipse IDE. There are two different ways to have it done. One is to install the Plugin from eclipse itself using the Software update option. The procedure is nicely illustrated here.

Second method is to install the plugin manually. For that get the Mylyn 2.2 Release archive from here . Uncompress it and copy the contents of plugin directory to the eclipsebasedir/plugin and contents of features directory to the eclipsebasedir/features.

2.We need to restart the Eclipse IDE for the newly added plugins to work. For that close the eclipse IDE if it is already running and start it cleanly. We will use eclipse.exe -clean from command prompt in windows or eclipse -clean from shell prompt in Linux.

3.Now we need to Verify that the newly added mylyn plugin is working in our Eclipse IDE. Mylyn uses a perspective called “Planning”.In Eclipse, a perspective is a way to organize and view the files associated with our program. We can open the perspective from Window -> Open Perspective -> Other

We will select the perspective “Planning” and continue by clicking the Ok button.

Now Eclipse has opened the “Planning” perspective for us which shows a Task List view. To verify that the plugin is working properly, we can create a new Task using the New Wizard. For that Go to File ->New ->Task

A New Task will be opened for us and it will be listed in the Task List as shown below.

Now we have verified that the mylyn plugin is working properly. It is time to move on to our actual goal ie. Converting this Plugin to a standalone RCP application.

5.We start by creating a new Plugin project in eclipse using the New wizard.

For that go to File-> New-> Project

We will select Plugin Project and continue by clicking next.

6.We need to fill in a suitable name for our project for eg.“mylyn” and continue by clicking next.

7.In the next Screen we will see an option “would you like to create a Rich Client Application “ with radio buttons “Yes” or “NO”. Since we are going to create a Rich Client Application enable it by selecting “Yes” and continue by clicking the Next button.

8.Now Eclipse will show us a list of available Templates for our RCP. We will take the simplest of all “Hello RCP” template. Firstly we will enable “Create a plugin using one of the templates” by clicking the checkbox. We will select “Hello RCP” and continue by clicking Next. Please note “Hello RCP” is the simplest template available to which we add only those components that our application needs.

9.In the next screen Eclipse will allow us to name our application. Give an appropriate name

eg. “Mylyn Application”.This name comes on the title bar of our application. Give an appropriate package name too. I have used “mylyn” in this tutorial. Branding is an option provided by eclipse to brand our application. Branding includes adding splash image,custom icons etc. Enable branding as we will be branding our application in the final stage. Move on by clicking Finish.

If you had followed with me in this tutorial, eclipse will be in “Planning perspective” and will prompt to switch to “Plugin-in Development perspective”. Please select “yes” at this prompt.

6.Eclipse creates the Project for us and opens up the manifest file as shown below.

7.So far we have created an RCP application using the “Hello Template” and its time to see for ourself how it looks like. We can start the application from eclipse by Clicking the “Launch an Eclipse Application” link present in the manifest file. The application pops up as shown below. This is the basic building block of our Mylyn RCP application and we will add features to it in an iterative manner.

8.We can notice that the application screen area is small. This is because by default the size is set to (400,300) in a method preWindowOpen() inside ApplicationWorkbenchWindowAdvisor class.We will open up the ApplicationWorkbenchWindowAdvisor .java and set it to (800,600). Change the setShowCoolBar value to true as we will be adding some Coolbar menus to spice up our application.

9.Right now our application is a plain template. There are no menus or icons or Actions. Eclipse allows us to define and declare all the actions/menus that we need in our RCP application. All these are to be done in ApplicationActionBarAdvisor class. So we will open this file and define all the menus/actions/sub menus etc that we want for our entry level application programaticaly.

So after adding all the Actions/Menus etc we want for our Mylyn application, our ApplicationActionBarAdvisor.java looks like as shown below.

package mylyn;

import org.eclipse.core.runtime.IExtension;

import org.eclipse.jface.action.IContributionItem;

import org.eclipse.jface.action.ICoolBarManager;

………

public class ApplicationActionBarAdvisor extends ActionBarAdvisor {

//Declaring all the Workbench Actions

private IWorkbenchAction newAction;

private IWorkbenchAction saveAction;

private IWorkbenchAction openPerspective;

………….

public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {

super(configurer);

protected void makeActions(IWorkbenchWindow window) {

//All the actions are defined here.

newAction=ActionFactory.NEW.create(window);

newAction.setText(“New”);

register(newAction);

saveAction=ActionFactory.SAVE.create(window);

register(saveAction);

openPerspective= ActionFactory.OPEN_PERSPECTIVE_DIALOG.create(window);

register(openPerspective);

…………..

}

protected void fillCoolBar(ICoolBarManager coolBar) {

//Adding the Actions to the CoolBar.

IToolBarManager toolbar = new ToolBarManager(SWT.FLAT | SWT.RIGHT);

coolBar.add(new ToolBarContributionItem(toolbar, “main”));

toolbar.add(newAction);

toolbar.add(saveAction);

………….

}

protected void fillMenuBar(IMenuManager menuBar) {

//Adding the Actions to the Menu Bar.

MenuManager fileMenu = new MenuManager(“&File”,IWorkbenchActionConstants.M_FILE);

menuBar.add(fileMenu);

MenuManager windowMenu= new MenuManager(“&Window”,IWorkbenchActionConstants.WINDOW_EXT);

menuBar.add(windowMenu);

………….

fileMenu.add(newAction);

fileMenu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));

fileMenu.add(new Separator());

fileMenu.add(saveAction);

windowMenu.add(openPerspective);

………….

}

}

10.So we have completed adding the Menus/Actions for our application and it is time to define a product Configuration for our mylyn project. A product configuration is required to brand or package our final application. Product configuration manages information about splash screens,launcher icons,about text, plugin and features list,window images etc together for our application. To create a product configuration right click the mylyn project Go to New-> Product Configuration as shown below.

11.We need to give a name for the product configuration eg.“mylyn.product” and continue by clicking finish.

12.Eclipse will open the Product configuration file in a manifest editor for us. We can notice that eclipse has automatically selected “mylyn.application” as the application to run on launching this product. If it is not, select the same from the drop down menu.

13. So far so good. We need to check whether the application is working from our product configuration. For that click “Launch an Eclipse application” link in the product configuration file which will pop up the application. Make sure all the menus that we added in step 9 shows up but these menus wont work unless we include all the necessary Plugins. We can notice that the application comes up in (800*600) mode.

14.Now its time for us to include all the necessary mylyn Plugins and Fragments to our product configuration. We will do that by clicking the Configuration tab in the Product configuration file. We can see that all the plugins and fragments required for the basic application from template are already shown here.

15.For adding the mylyn Plugins and fragments to the product configuration, we will Click the add button which brings up a pop up list of Plugins and fragments. We need to scroll down and select only those mylyn Plugins which are required. Click the Ok button to continue. Now we need to resolve the plugin dependencies. Click “Add Required Plugins” link and eclipse will automatically add the dependencies for us. We need to save the project for the changes to take effect.

16.So far we have created a base application,defined the menus/actions, defined a product configuration, added the mylyn Plugins and fragments, resolved the dependencies. Now its time for us to check whether everything plug-in well and works well together. For that we need to get back to the “overview” Tab. We need to Click the Synchronise link. This ensures that all the changes that we have made in the product configuration and the mylyn.application synchronize with each other. We can start the application by clicking “Launch an Eclipse application” link present in product configuration.

17.We can see that the Mylyn Application starts in a new window. We can check whether the perspective “planning”,the views,creating a new task etc work successfully following the same procedure we have done in step 3.

18.We need to give a name for our application launcher and provide custom icons for our application. Eclipse provides a variety of tools to get it done. In the product Configuration click the “Launching Tab”. Give a Launcher name eg.“mylyn” and click save. We can provide the icon files required for branding here.(Note:-I have not done this below)

19.We want a standalone mylyn RCP application. So we will Export the application from our eclipse environment to our operating system’s directory structure. For doing this, in the product configuration file click “Eclipse Product Export wizard” which will bring up a pop up. We want the Root directory to be called “mylyn” and not the default name “eclipse”.Change the root directory name to “mylyn”,make sure the “synchronization” checkbox is checked. Browse through the directory structure to the folder to which we want to export the application and click finish to export.

20.Eclipse will export the application for us and if it is successful no errors will be thrown in the eclipse error log or problems view.

21.So everything done and its time for us to check out the final application. Browse through the directory structure to the folder to which we exported the application. We can start the application by clicking mylyn.exe. Make sure everything works creating a task,the views the planning perspective etc. Final application screen shot is shown below.


So thats it. We have successfully completed converting mylyn plugin to a standalone RCP application.

Please note the full code of ApplicationActionBarAdvisor.java can be obtained from here.

I hope this post would help some one.Please feel free to leave comments/Suggestions/Correct me.

HTH,

Anoop Menon

About author View all posts Author website

anoopmenon

19 CommentsLeave a comment

  • Hi, this is a nice article. But can you also post an article on doing the reverse of it. I mean, can you please show by example, how to convert RCP application to plugin. You may take any open source RCP application.
    Thanks.

  • Hello prajwalan,

    I fear I didn’t understand your question correctly. Do you mean taking an open source RCP application and convert it back to a plugin jar file?

    Can you tell me what you are trying to do and Why you want to do this? If I am creating an RCP application based on the tutorial I have compiled above, say the RCP plugin project name is “x”, x.jar (a plugin) will be created and will be present inside the plugin class of my RCP application.Is this what you are looking for?

    HTH,

    Anoop Menon

  • Actually, I am developing a RCP application. When I select “Run as eclipse application”, it opens into a separate window of its own. But, I want to run it within Eclipse IDE as other plugins by opening its perspective from Window > Open Perspective. I have not been able to do this. I tried to put the exported Jar to the plugins folder also, but that did not work.

    I am bit new to Eclipse framework, so maybe its being hard to understand difference between plugin and RCP.

  • Hello prajwalan,

    I was also like you When I started working on an RCP project almost 1 and half years ago.The peculiarity of this framework is that the learning curve is bit steep.But once you understand what you do, it will be very easy.I will help you with what I know.

    Plugin is actually the smallest deployable unit that we can use.Usually its a jar.A plugin adds a specific functionality to our Eclipse which is also in effect an RCP application.

    Eg. I believe you will be knowing subversion source control mechanism.You can use Subversion from your eclipse by using their plugin subclipse.When you add this plugin/s to the plugins folder of your eclipse and restart…you are being offered the new functionality in your eclipse ie.subversion source control for your files right from eclipse with GUI interfaces for commit,update etc.Usually its better to run eclipse with a “eclipse.exe -clean command” after you add a new plugin.

    So what basically an RCP is?

    Its the minimum number of plugins required for making a Stand alone RCP application.Some of the plugins will be custom specific to your domain(Plugins made by you or your company). And some of the plugins will be eclipse UI plugins and also a lot of dependency plugins. The true goodness of this feature is that…we don’t need to re invent the wheel for lots of things required for our RCP application.We can reuse code..to be more specfic we are reusing bundles/Plugins.

    So basically an RCP application is a standalone running application which has got custom plugins and eclipse plugins.

    From what you have said in the first part of the comment:

    “Actually, I am developing a RCP application. When I select “Run as eclipse application”, it opens into a separate window of its own. But, I want to run it within Eclipse IDE as other plugins by opening its perspective from Window > Open Perspective.”

    This is the default way it works as far as I know, when we are testing an RCP application/Plugin from your eclipse.Once you export your application you don’t need to depend on your eclipse development platform.By opening up your independent application you can open its perspective as you have told above.

    I have got in to a new doubt after hearing from you? Are you planning to develop a plugin and add to your eclipse for some additional functionality for your development stuff or a standalone RCP application? If its the latter your final product will be a plugin and you need to add it to your eclipse/Plugins folder manually.If its former, exporting the application will serve your need. Any doubts or if you want me to help you in this in anyway let me know.

    HTH,

    Anoop Menon

  • Thanks for such a comprehensive explanation. I should really be grateful to you that you spent your time for replying in such detail.

    My final product will be standalone RCP application. But, for some clients, I will require it to be developed as a plugin that can be added to Eclipse or other (their own) RCP application. So, is it just a matter of exporting to right format ? Or something else.

  • Hello prajwalan,

    Sorry for replying late. I had been to my native place Kerala and back in Bangalore only today morning.

    Its always a pleasure to help.This is the way I learn also , asking questions and understand.

    From what I understand from your requirement, the best solution will be to develop your own plugin/plugins. Once you are done with all the testing, you can export your plugin/plugins are jar files.

    This answers to two scenarios.

    1. To export as a RCP application.

    My tutorial/post above will answer this issue.Use your custom plugins for developing the RCP application. If you come across any problems with this let me know. I can help you with what I know.As a tip -In the run configuration check “Validate Plugins” this will help you to resolve any dependency plugin issues.

    2. For the other clients, give them the exported plugin/plugins jars and ask them to install it in their eclipse or custom RCP application and restart the application with “-clean”. Both the cases make sure they have all the dependency plugins required by the custom plugins you give. Best option is when you are doing #1, You can know what all plugins are required for running your plugins in your RCP application make a list of it and give it to the clients. If the dependencies are not satisfied your plugins wont work in a custom RCP or eclipse, the client has.

    Hope this helps.

    HTH,

    Anoop

  • Hello Anoop,

    This is a great article and it helped me a lot to understand the rcp development. Nevertheless I’m still facing some problems converting my plugin into a standalone RCP. You started by creating a RCP Application usiing a simple template and then added some Actions in ApplicationActionBarAdvisor Class. Now this is the point where I dont really understand where these Actions are coming from. Are they specific for mylyn plugin or just some standard Actions, which every RCP application should include? My plugin is some type of a ftp client with two views and own preference page. Thank you for your reply.

    Igor.

  • Hello Igor,

    Happy to know that this article is useful to you.

    Regarding your question. You need to add only those actions which are required for your application. And What ever actions that you are adding to the ApplicationActionBarAdvisor class should be clearly defined in your custom plugin’s plugin.xml via extension points to the base plugin in the framework.

    For eg. If you have a new wizard for your plugin it should extend it to “org.eclipse.ui.newWizards” in its plugin.xml

    In the case of Mylyn all these actions are defined in the plugin.Thats why the actions work when we install it in our eclipse.

    If you create an RCP application from scratch using the simple template, and add File>Print in the ApplicationActionBarAdvisor and you run with out adding custom or external plugins to your product configuration, still the menu File>Print will show up but clicking it will show it wont do anything.

    So best of my knowledge by adding these actions in our ApplicationActionBarAdvisor class we draw these menu items and they link directly to the eclipse framework’s Action Factory.If your plugin wants to make use of it, then it must define it using the extension points.

    HTH,

    Anoop

  • Hi Anoop
    This is a useful article.I have developed a Graphical Editor with Flyout palette and other stuff,its all fine.Now I wanted to create a stand alone RCP application for this plugin, after the 19th step i.e after exporting I did not get any exe file ,but I found that all the plugins(including the dependencies were present), and there were other eclipse config stuff.Could u pls tell me where am i wrong.
    Thanks
    kalyan

  • Hey kalyan,

    Which eclipse version are you using? I am not able to reproduce the issue you said above. Did you define a product configuration for your application?

    Anoop

  • Hi Anoop,

    Thank you for this article. It helps me a lot. Right now, I’m trying to convert the collab example in the new Eclipse Communication Framework (org.eclipse.ecf.example.collab) to an RCP. I have a few questions I hope you can help me with.

    1. I see that you add the Mylyn plugins in the product configuration. Can I add it in the dependencies tab of the plugin.xml file?
    2. How do I find the actions that a plugin contributes in its plugin.xml file? Take the collab example I’m wrestling with, it is so intertwined with others that I’m losing my way among them.

    Thank you very much.
    Hoang

  • Hello Hoang,

    Sorry that, I am so late to reply. .

    And regarding your query.

    # 1. Yup, it will work as far as I know. I haven’t tried this though.Logically, if you do that, you just need to click the “Add Required Plugins button” .

    # 2. I truly agree that it is hard to find actions by looking through a plugin.xml file. I really don’t know whether any shortcuts or easy paths. Are you using the Plugin Manifest editor to view the file or opening plugin.xml in text editor from inside the eclipse? Former is much easier to understand what actions a plugin contributes.

    HTH,

    Anoop

  • Thank you for this article. It helps me a lot. Right now.
    but i want to ask ?

    i converted plugin project into rcp project but at the time of running project i am not able to see the project structure in my custom perspective view but able to see in java perspective package explorer.

  • Hello KK,

    Happy to know that the article was helpful to you.Have you defined the views you wanted in your custom perspective.Check everything once again to see whether you missed out anything. I will be able to help you if you can show me some part of the code where you defined your perspective etc.

    HTH,

    Anoop Menon

  • Hi Anoop,

    You look to be very expert in Eclipse RCP development. I am now initiating a product devlopment using Pure Eclipse Java platform. It will be using SWT, JFace and will be a stand alone RCP application.

    My and my teams knowledge is very basic in RCP development. Can you suggest how we should start?Also suggestions about acquiring knowledge in RCP, SWT,JFace, any free or commercial GUI building tool, Multithreading models for high performance.

    • Hi Prashanth,

      Good to hear from you. The best way to learn everything regarding eclipse RCP development is to stick on to the RCP newsportal. I have found it very useful.
      Learning curve is steep but its worth the effort. I believe Myeclipse has a GUI building tool, I haven’t used it though…

      HTH,
      Anoop

  • I tried to follow the same thing on Eclipse Indigo (3.7.2).
    But I could not run my plugin as a standalone RCP.
    My plugin works fine in the Eclipse though.
    In the Dependencies tab, when I click on Add, I can see my plugin.
    But even after selecting it and clicking ‘Add Required Plug-ins’, when I try to run the application from Overview tab, it does not shows the Views I have in my plugin which I want to run as a standalone.

    If you can point me to some direction, it will be great.

    thanks!

  • Hi Anoop,
    Thanks a lot for your article. Sorry to interrupt you. I have a question that
    0
    down vote
    favorite
    I need to set passwords for eclipse. In other words, only authorized user can access to the platform. I want to add custom login function for eclipse. When I click the shortcut of eclipse, there will come out a popup window needing me to input the username and password. After that, the eclipse platform can be visited. How to implement by eclipse plug-in development?

Leave a Reply

Your email address will not be published. Required fields are marked *