Rcp by example

2,400 views

Published on

RCP

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,400
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
19
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Rcp by example

  1. 1. RCP by Example by Subramanian Thiruppathi
  2. 2. Agenda <ul><li>Talk about RCP </li></ul><ul><li>RCP Features </li></ul><ul><li>Real Time Examples </li></ul><ul><li>Discuss about Important Classes in RCP </li></ul><ul><li>Recommended Reading </li></ul>
  3. 3. End User Expectation … <ul><li>High Quality end-user experience </li></ul><ul><li>High-Speed local processing </li></ul><ul><li>Rich native UI </li></ul><ul><ul><li>drag-and-drop </li></ul></ul><ul><ul><li>Clipboard </li></ul></ul><ul><ul><li>Navigation </li></ul></ul><ul><ul><li>Customization </li></ul></ul>
  4. 4. Developer Expectation … <ul><li>Good Development Environment </li></ul><ul><li>Easy Deployment </li></ul><ul><li>Easy update latest code in Client side </li></ul><ul><li>And lot more …. </li></ul>
  5. 5. What is RCP <ul><li>An application that uses the windowing and GUI features of the operating system </li></ul>
  6. 6. RCP Features <ul><li>Components </li></ul><ul><li>Middleware and infrastructure </li></ul><ul><li>Native user experience </li></ul><ul><ul><li>Look and Feel </li></ul></ul><ul><li>Portability </li></ul><ul><ul><li>Even support Mobile Application (J2ME) </li></ul></ul><ul><li>Intelligent install and update </li></ul><ul><ul><li>Java web start </li></ul></ul><ul><li>Disconnected operation </li></ul><ul><ul><li>Local processing </li></ul></ul><ul><li>Development tooling support </li></ul><ul><ul><li>RCP IDE </li></ul></ul>
  7. 7. Real time Examples for RCP <ul><ul><li>IBM Workplace Client Technology </li></ul></ul><ul><ul><li>Maestro - NASA Space Mission Management </li></ul></ul><ul><ul><li>And lot more …. </li></ul></ul>
  8. 8. Important Classes <ul><li>Application </li></ul>
  9. 9. Application class <ul><ul><li>Must Implement IPlatformRunnable </li></ul></ul>Note: We can use any name as Class but here we are following RCP Standard naming convention.
  10. 10. Application class <ul><ul><li>Must Implement IPlatformRunnable </li></ul></ul><ul><ul><li>Implement run method </li></ul></ul>
  11. 11. Application class <ul><ul><li>Implement IPlatformRunnable </li></ul></ul><ul><ul><li>Implement run method </li></ul></ul><ul><ul><li>Run method is Main method </li></ul></ul>
  12. 12. Application class <ul><ul><li>Implement IPlatformRunnable </li></ul></ul><ul><ul><li>Implement run method </li></ul></ul><ul><ul><li>Run method is Main method </li></ul></ul><ul><ul><li>Starting point of your application and Ending of your application </li></ul></ul>
  13. 13. Application class <ul><ul><li>package com.rcp.example; </li></ul></ul><ul><ul><li>import org.eclipse.core.runtime.IPlatformRunnable; </li></ul></ul><ul><ul><li>import org.eclipse.swt.widgets.Display; </li></ul></ul><ul><ul><li>import org.eclipse.ui.PlatformUI; </li></ul></ul><ul><ul><li>/** </li></ul></ul><ul><ul><li>* This class controls all aspects of the application's execution </li></ul></ul><ul><ul><li>*/ </li></ul></ul><ul><ul><li>public class Application implements IPlatformRunnable { </li></ul></ul><ul><ul><li>public Object run(Object args) throws Exception { </li></ul></ul><ul><ul><li>Display display = PlatformUI. createDisplay (); </li></ul></ul><ul><ul><li>try { </li></ul></ul><ul><ul><li>int returnCode = PlatformUI. createAndRunWorkbench (display, </li></ul></ul><ul><ul><li>new ApplicationWorkbenchAdvisor()); </li></ul></ul><ul><ul><li> if (returnCode == PlatformUI. RETURN_RESTART ) { </li></ul></ul><ul><ul><li> return IPlatformRunnable. EXIT_RESTART ; </li></ul></ul><ul><ul><li> } </li></ul></ul><ul><ul><li> return IPlatformRunnable. EXIT_OK ; </li></ul></ul><ul><ul><li>} finally { </li></ul></ul><ul><ul><li>display.dispose(); </li></ul></ul><ul><ul><li>} </li></ul></ul><ul><ul><li>} </li></ul></ul><ul><ul><li>} </li></ul></ul>
  14. 14. Important Classes <ul><li>Application </li></ul><ul><li>ApplicationWorkbenchAdivsor </li></ul>
  15. 15. ApplicationWorkbenchAdivsor class <ul><ul><li>Extend WorkbenchAdvisor </li></ul></ul>
  16. 16. ApplicationWorkbenchAdivsor class <ul><ul><li>Must extend WorkbenchAdvisor </li></ul></ul><ul><ul><li>Application Level advice </li></ul></ul>
  17. 17. ApplicationWorkbenchAdivsor class <ul><ul><li>Must extend WorkbenchAdvisor </li></ul></ul><ul><ul><li>Application Level advice </li></ul></ul><ul><ul><li>Participates in the start up and shut down of the workbench </li></ul></ul>
  18. 18. ApplicationWorkbenchAdivsor class <ul><ul><li>Must extend WorkbenchAdvisor </li></ul></ul><ul><ul><li>Application Level advice </li></ul></ul><ul><ul><li>Participates in the start up and shut down of the workbench </li></ul></ul><ul><ul><li>One running Workbench per running Eclipse application </li></ul></ul>
  19. 19. ApplicationWorkbenchAdivsor class <ul><li>package com.rcp.example; </li></ul><ul><li>import org.eclipse.ui.application.IWorkbenchWindowConfigurer; </li></ul><ul><li>import org.eclipse.ui.application.WorkbenchAdvisor; </li></ul><ul><li>import org.eclipse.ui.application.WorkbenchWindowAdvisor; </li></ul><ul><li>public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor { </li></ul><ul><li>private static final String PERSPECTIVE_ID = &quot;RCPView.perspective&quot;; </li></ul><ul><li>public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor( </li></ul><ul><li>IWorkbenchWindowConfigurer configurer) { </li></ul><ul><li>return new ApplicationWorkbenchWindowAdvisor(configurer); </li></ul><ul><li>} </li></ul><ul><li>public String getInitialWindowPerspectiveId() { </li></ul><ul><li>return PERSPECTIVE_ID ; </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
  20. 20. Important Classes <ul><li>Application </li></ul><ul><li>ApplicationWorkbenchAdivsor </li></ul><ul><li>ApplicationWorkbenchWindowAdivsor </li></ul>
  21. 21. ApplicationWorkbenchWindowAdivsor class <ul><ul><li>Must Extend WorkbenchWindowAdvisor </li></ul></ul>
  22. 22. ApplicationWorkbenchWindowAdivsor class <ul><ul><li>Must Extend WorkbenchWindowAdvisor </li></ul></ul><ul><ul><li>Window-level advice </li></ul></ul>
  23. 23. ApplicationWorkbenchWindowAdivsor class <ul><ul><li>Must Extend WorkbenchWindowAdvisor </li></ul></ul><ul><ul><li>Window-level advice </li></ul></ul><ul><ul><li>Helps to show or hide the menu, cool bar etc., </li></ul></ul>
  24. 24. ApplicationWorkbenchWindowAdivsor class <ul><ul><li>Must Extend WorkbenchWindowAdvisor </li></ul></ul><ul><ul><li>Window-level advice </li></ul></ul><ul><ul><li>Helps to show or hide the menu, cool bar etc., </li></ul></ul><ul><ul><li>Only one instance for each window </li></ul></ul>
  25. 25. ApplicationWorkbenchWindowAdivsor class <ul><li>package com.rcp.example; </li></ul><ul><li>import org.eclipse.swt.graphics.Point; </li></ul><ul><li>import org.eclipse.ui.application.ActionBarAdvisor; </li></ul><ul><li>import org.eclipse.ui.application.IActionBarConfigurer; </li></ul><ul><li>import org.eclipse.ui.application.IWorkbenchWindowConfigurer; </li></ul><ul><li>import org.eclipse.ui.application.WorkbenchWindowAdvisor; </li></ul><ul><li>public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { </li></ul><ul><li>public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { </li></ul><ul><li>super (configurer); </li></ul><ul><li>} </li></ul><ul><li>public ActionBarAdvisor createActionBarAdvisor( </li></ul><ul><li>IActionBarConfigurer configurer) { </li></ul><ul><li>return new ApplicationActionBarAdvisor(configurer); </li></ul><ul><li>} </li></ul><ul><li>public void preWindowOpen() { </li></ul><ul><li>IWorkbenchWindowConfigurer configurer = getWindowConfigurer(); </li></ul><ul><li>configurer.setInitialSize( new Point(400, 300)); </li></ul><ul><li>configurer.setShowCoolBar( false ); </li></ul><ul><li>configurer.setShowStatusLine( false ); </li></ul><ul><li>configurer.setTitle(&quot;RCP Application&quot;); </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
  26. 26. Important Classes <ul><li>Application </li></ul><ul><li>ApplicationWorkbenchAdivsor </li></ul><ul><li>ApplicationWorkbenchWindowAdivsor </li></ul><ul><li>ActionBarAdvisor </li></ul>
  27. 27. ActionBarAdvisor class <ul><ul><li>Must extend ActionBarAdvisor </li></ul></ul><ul><ul><li>Important methods are </li></ul></ul><ul><ul><ul><li>makeActions </li></ul></ul></ul><ul><ul><ul><li>fillMenuBar </li></ul></ul></ul>
  28. 28. Important Classes <ul><li>Application </li></ul><ul><li>ApplicationWorkbenchAdivsor </li></ul><ul><li>ApplicationWorkbenchWindowAdivsor </li></ul><ul><li>ActionBarAdvisor </li></ul><ul><li>Perspective </li></ul>
  29. 29. Perspective class <ul><ul><li>Must implement IPerspectiveFactory </li></ul></ul><ul><ul><ul><li>Implement createInitialLayout method </li></ul></ul></ul>
  30. 30. Perspective class <ul><li>package com.rcp.example; </li></ul><ul><li>import org.eclipse.ui.IPageLayout; </li></ul><ul><li>import org.eclipse.ui.IPerspectiveFactory; </li></ul><ul><li>public class Perspective implements IPerspectiveFactory { </li></ul><ul><li>public void createInitialLayout(IPageLayout layout) { </li></ul><ul><li>String editorArea = layout.getEditorArea(); </li></ul><ul><li>layout.setEditorAreaVisible( false ); </li></ul><ul><li>layout.setFixed( true ); </li></ul><ul><li>layout.addStandaloneView(View. ID , false , IPageLayout. LEFT , 1.0f, editorArea); </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
  31. 31. Perspective class <ul><ul><li>Must implement IPerspectiveFactory </li></ul></ul><ul><ul><ul><li>Implement createInitialLayout method </li></ul></ul></ul><ul><ul><li>Generates the initial page layout </li></ul></ul>
  32. 32. Important Classes <ul><li>Application </li></ul><ul><li>ApplicationWorkbenchAdivsor </li></ul><ul><li>ApplicationWorkbenchWindowAdivsor </li></ul><ul><li>ActionBarAdvisor </li></ul><ul><li>Perspective </li></ul><ul><li>View </li></ul>
  33. 33. View class <ul><ul><li>Must extend ViewPart </li></ul></ul>
  34. 34. View class <ul><ul><li>Must extend ViewPart </li></ul></ul><ul><ul><li>Page design (Forms,Showing Buttons, etc) </li></ul></ul>
  35. 35. View class <ul><ul><ul><li>package com.rcp.example; </li></ul></ul></ul><ul><ul><ul><li>import org.eclipse.jface.viewers.TableViewer; </li></ul></ul></ul><ul><ul><ul><li>import org.eclipse.swt.SWT; </li></ul></ul></ul><ul><ul><ul><li>import org.eclipse.swt.widgets.Composite; </li></ul></ul></ul><ul><ul><ul><li>import org.eclipse.ui.part.ViewPart; </li></ul></ul></ul><ul><ul><ul><li>public class View extends ViewPart { </li></ul></ul></ul><ul><ul><ul><li>public static final String ID = &quot;RCPView.view&quot;; </li></ul></ul></ul><ul><ul><ul><li>private TableViewer viewer; </li></ul></ul></ul><ul><ul><ul><li>/** This is a callback that will allow us to create the viewer and initialize it */ </li></ul></ul></ul><ul><ul><ul><li>public void createPartControl(Composite parent) { </li></ul></ul></ul><ul><ul><ul><li>viewer = new TableViewer(parent, SWT. MULTI | SWT. H_SCROLL | SWT. V_SCROLL ); </li></ul></ul></ul><ul><ul><ul><li>viewer.setContentProvider( new ViewContentProvider()); </li></ul></ul></ul><ul><ul><ul><li>viewer.setLabelProvider( new ViewLabelProvider()); </li></ul></ul></ul><ul><ul><ul><li>viewer.setInput(getViewSite()); </li></ul></ul></ul><ul><ul><ul><li>} </li></ul></ul></ul><ul><ul><ul><li>/** Passing the focus request to the viewer's control. */ </li></ul></ul></ul><ul><ul><ul><li>public void setFocus() { </li></ul></ul></ul><ul><ul><ul><li>viewer.getControl().setFocus(); </li></ul></ul></ul><ul><ul><ul><li>} } </li></ul></ul></ul>
  36. 36. Flow
  37. 37. Plugin.xml <ul><li><?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?> </li></ul><ul><li><?eclipse version=&quot;3.2&quot;?> </li></ul><ul><li><plugin> </li></ul><ul><li><extension </li></ul><ul><li>id=&quot;application&quot; </li></ul><ul><li>point=&quot;org.eclipse.core.runtime.applications&quot;> </li></ul><ul><li><application> </li></ul><ul><li><run </li></ul><ul><li>class=&quot;com.rcp.example.Application&quot;> </li></ul><ul><li></run> </li></ul><ul><li></application> </li></ul><ul><li></extension> </li></ul><ul><li><extension </li></ul><ul><li>point=&quot;org.eclipse.ui.perspectives&quot;> </li></ul><ul><li><perspective </li></ul><ul><li>name=&quot;Perspective&quot; </li></ul><ul><li>class=&quot;com.rcp.example.Perspective&quot; </li></ul><ul><li>id=&quot;RCPView.perspective&quot;> </li></ul><ul><li></perspective> </li></ul><ul><li></extension> </li></ul><ul><li><extension </li></ul><ul><li>point=&quot;org.eclipse.ui.views&quot;> </li></ul><ul><li><view </li></ul><ul><li>name=&quot;View&quot; </li></ul><ul><li>class=&quot;com.rcp.example.View&quot; </li></ul><ul><li>id=&quot;RCPView.view&quot;> </li></ul><ul><li></view> </li></ul><ul><li></extension> </li></ul><ul><li></plugin> </li></ul>
  38. 38. Run the Application
  39. 39. Recommended Reading <ul><li>Eclipse Rich Client Platform </li></ul><ul><ul><li>By Jeff McAffer and Jean-Michel Lemieux </li></ul></ul><ul><ul><li>Addison-Wesley Professional </li></ul></ul><ul><ul><li>ISBN: 0321334612 </li></ul></ul><ul><li>SWT : The Standard Widget Toolkit, Volume 1 </li></ul><ul><ul><li>By Steve Northover, Mike Wilson </li></ul></ul><ul><ul><li>Addison-Wesley Professional </li></ul></ul><ul><ul><li>ISBN: 0321256638 </li></ul></ul><ul><li>Contributing to Eclipse: Principles, Patterns, and Plugins </li></ul><ul><ul><li>By Erich Gamma, Kent Beck </li></ul></ul><ul><ul><li>Addison-Wesley Professional </li></ul></ul><ul><ul><li>ISBN: 0321205758 </li></ul></ul>
  40. 40. Prerequisites <ul><li>Eclipse RCP Target download used is eclipse-RCP-SDK-3.1.2-win32.zip </li></ul><ul><li>j2sdk 1.4.2 or higher </li></ul>
  41. 41. <ul><li>Thanks for your time </li></ul>

×