Difference between revisions of "RCP to RAP Migration Example"

From Eclipsepedia

Jump to: navigation, search
(Migration)
(Replaced content with "This page was obsolete and has been deleted. Please see the history if you need to access the content.")
 
Line 1: Line 1:
== <font color="red">Under heavy developement</font> ==
+
This page was obsolete and has been deleted. Please see the history if you need to access the content.
 
+
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 ==
+
 
+
<font color="red">Is this needed in this tutorial? Not sure how this is done for M4 cause of the namespace problems (updatesite/target/CVS?) [[User:B.muskalla.gmx.net|B.muskalla.gmx.net]]</font>
+
 
+
== Setup of the example RCP application ==
+
 
+
{|align="right"
+
|[[Image:RAPmigration_newproject.png|right|thumb|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 <code>File | New | Project...</code> and select <code>Plug-in Project</code>.
+
We will give it the name "org.eclipse.rap.demo.mail" but you can also choose your own. Click on <code>Next &gt;</code> to modify the existing plug-in settings.
+
Be sure to have the <code>This plug-in will make contributions to the UI</code> checkbox checked and that you <code>Would like to create a rich client application</code> (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".
+
 
+
[[Image:RAPmigration_rcpmail.png|thumb|RCP Mail Example]]
+
 
+
== Migration ==
+
The first step is to replace the dependency to <code>org.eclipse.ui</code> of RCP in your <code>org.eclipse.rap.demo.mail</code> project. To do this, open the Manifest Editor (click on the <code>plugin.xml</code> or <code>MANIFEST.MF</code> file in your project) and switch to the "Dependencies" tab. Remove the <code>org.eclipse.ui</code> plugin from the list and add the <code>org.eclipse.rap.ui.workbench</code> plugin as a new dependency.
+
 
+
As the nature of RAP requires a little but different startup of the application, just delete the extension of <code>org.eclipse.core.runtime.applications</code> on your "Extensions" tab. If you like, you can also remove the according <code>Application.java</code> from your project.
+
 
+
To define a new entrypoint, add a new extension for the <code>org.eclipse.rap.ui.workbench.entrypoint</code> extension point. As <code>paramater</code> we will define "default" that our mail example is the default application in the running enviroment later on.
+
 
+
As <code>class</code> you can create a new one which implements the <code>IEntryPoint</code> interface. Look at the following code how we could implement it:
+
 
+
<pre>
+
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;
+
}
+
}
+
</pre>
+
 
+
 
+
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:
+
 
+
 
+
'''MessagePopupAction:23'''
+
 
+
 
+
<code style="padding: 1em;border: 1px dashed #2f6fab;color: black;background-color: #f9f9f9;line-height: 1.1em;">
+
MessageDialog.openInformation(window.getShell(), "Open", "Open Message Dialog!", '''null''');
+
</code>
+
 
+
 
+
 
+
'''OpenViewAction:32'''
+
 
+
 
+
<code style="padding: 1em;border: 1px dashed #2f6fab;color: black;background-color: #f9f9f9;line-height: 1.1em;">
+
MessageDialog.openError(window.getShell(), "Error", "Error opening view:" + e.getMessage(), '''null''');
+
</code>
+
 
+
 
+
 
+
'''View:53'''
+
 
+
 
+
<code style="padding: 1em;border: 1px dashed #2f6fab;color: black;background-color: #f9f9f9;line-height: 1.1em;">
+
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.
+
Here are the lines we don't need:
+
 
+
ApplicationActionBarAdvisor (lines 32, 54, 55, 74)
+
 
+
 
+
...
+
 
+
<del>private IWorkbenchAction newWindowAction;</del>
+
 
+
&hellip;
+
 
+
<s>newWindowAction = ActionFactory.OPEN_NEW_WINDOW.create(window);</s>
+
 
+
<s>register(newWindowAction);</s>
+
 
+
&hellip;
+
 
+
<s>fileMenu.add(newWindowAction);</s>
+
 
+
== Run the mail demo ==
+

Latest revision as of 13:42, 17 November 2013

This page was obsolete and has been deleted. Please see the history if you need to access the content.