Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "RCP to RAP Migration Example"

(added some more instructions)
(Migration)
Line 55: Line 55:
 
As RAP does not support blocking dialogs (think of the client-server concept), we have an additional parameter in the <code>open</code> method of our dialogs. This is helpful to perform certain actions after the dialog is closed. As the additional paramter will be called after the close event, it's named "ICallback". In our current application we don't need to define a callback for the dialogs and just pass <code>null</code>.
 
As RAP does not support blocking dialogs (think of the client-server concept), we have an additional parameter in the <code>open</code> method of our dialogs. This is helpful to perform certain actions after the dialog is closed. As the additional paramter will be called after the close event, it's named "ICallback". In our current application we don't need to define a callback for the dialogs and just pass <code>null</code>.
 
These are the locations where we need to add the additional paramter:
 
These are the locations where we need to add the additional paramter:
* MessagePopupAction:23
+
 
* OpenViewAction:32
+
 
* View:53
+
'''MessagePopupAction:23'''
 +
 
 +
<code>
 +
MessageDialog.openInformation(window.getShell(), "Open", "Open Message Dialog!", '''null''');
 +
</code>
 +
 
 +
 
 +
'''OpenViewAction:32'''
 +
 
 +
<code>
 +
MessageDialog.openError(window.getShell(), "Error", "Error opening view:" + e.getMessage(), '''null''');
 +
</code>
 +
 
 +
 
 +
'''View:53'''
 +
 
 +
<code>
 +
MessageDialog.openInformation(getSite().getShell(), "Not Implemented", "Imagine the address book or a new message being created now.", '''null''');
 +
</code>
 +
 
 +
 
  
 
One last thing is to do: We currently don't support to open more than one workbench window we will just comment out this feature in the mail example.
 
One last thing is to do: We currently don't support to open more than one workbench window we will just comment out this feature in the mail example.
Line 65: Line 85:
 
* ApplicationActionBarAdvisor:55
 
* ApplicationActionBarAdvisor:55
 
* ApplicationActionBarAdvisor:74
 
* ApplicationActionBarAdvisor:74
 
  
 
== Run the mail demo ==
 
== Run the mail demo ==

Revision as of 11:09, 15 June 2007

Under heavy developement

This little tutorial will give you a little introduction in how to migrate a existing RCP application to an "ajaxified" RAP application. As RAP is a subset of the existing RCP infrastructure and trough it's nature a little but different, we will show you what you need to adapt in your application to run it as web application and why you need to do these changes.

But let's start with a little example which you maybe already know - RCP Mail Example

Installing RAP

Is this needed in this tutorial? Not sure how this is done for M4 cause of the namespace problems (updatesite/target/CVS?) B.muskalla.gmx.net

Setup of the example RCP application

New Project wizard

We will use the RCP Mail Example provided by the PDE team to show you the details of such a migration. To create the RCP Mail example, click on File | New | Project... and select Plug-in Project. We will give it the name "org.eclipse.rap.demo.mail" but you can also choose your own. Click on Next > to modify the existing plug-in settings. Be sure to have the This plug-in will make contributions to the UI checkbox checked and that you Would like to create a rich client application (see screenshot "New Project Wizard"). On the next page select the "RCP Mail Template" and click the Finish button.

Clicking on the "Launch an Eclipse application" link of your Plugin Manifest Editor which opened immediately after project creation should result in an RCP application the one shown in "RCP Mail Example".

RCP Mail Example

Migration

The first step is to replace the dependency to org.eclipse.ui of RCP in your org.eclipse.rap.demo.mail project. To do this, open the Manifest Editor (click on the plugin.xml or MANIFEST.MF file in your project) and switch to the "Dependencies" tab. Remove the org.eclipse.ui plugin from the list and add the org.eclipse.rap.ui.workbench plugin as a new dependency.

As the nature of RAP requires a little but different startup of the application, just delete the extension of org.eclipse.core.runtime.applications on your "Extensions" tab. If you like, you can also remove the according Application.java from your project.

To define a new entrypoint, add a new extension for the org.eclipse.rap.ui.workbench.entrypoint extension point. As paramater we will define "default" that our mail example is the default application in the running enviroment later on.

As class you can create a new one which implements the IEntryPoint interface. Look at the following code how we could implement it:

package org.eclipse.rap.demo.mail;

import org.eclipse.swt.lifecycle.IEntryPoint;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;

public class MailApplication implements IEntryPoint {

	public Display createUI() {
		Display display = PlatformUI.createDisplay();
		PlatformUI.createAndRunWorkbench(display,
				new ApplicationWorkbenchAdvisor());
		return display;
	}
}


As RAP does not support blocking dialogs (think of the client-server concept), we have an additional parameter in the open method of our dialogs. This is helpful to perform certain actions after the dialog is closed. As the additional paramter will be called after the close event, it's named "ICallback". In our current application we don't need to define a callback for the dialogs and just pass null. These are the locations where we need to add the additional paramter:


MessagePopupAction:23

MessageDialog.openInformation(window.getShell(), "Open", "Open Message Dialog!", null);


OpenViewAction:32

MessageDialog.openError(window.getShell(), "Error", "Error opening view:" + e.getMessage(), null);


View:53

MessageDialog.openInformation(getSite().getShell(), "Not Implemented", "Imagine the address book or a new message being created now.", null);


One last thing is to do: We currently don't support to open more than one workbench window we will just comment out this feature in the mail example. Here are the lines we don't need:

  • ApplicationActionBarAdvisor:32
  • ApplicationActionBarAdvisor:54
  • ApplicationActionBarAdvisor:55
  • ApplicationActionBarAdvisor:74

Run the mail demo

Back to the top