Rcp by example

41
RCP by Example by Subramanian Thiruppathi

description

RCP

Transcript of Rcp by example

Page 1: Rcp by example

RCP by Example

by

Subramanian Thiruppathi

Page 2: Rcp by example

Agenda

Talk about RCP RCP Features Real Time Examples Discuss about Important Classes in

RCP Recommended Reading

Page 3: Rcp by example

End User Expectation …

High Quality end-user experience High-Speed local processing Rich native UI

drag-and-drop Clipboard Navigation Customization

Page 4: Rcp by example

Developer Expectation …

Good Development Environment Easy Deployment Easy update latest code in Client

side And lot more ….

Page 5: Rcp by example

What is RCP

An application that uses the windowing and GUI features of the operating system

Page 6: Rcp by example

RCP Features Components Middleware and infrastructure Native user experience

Look and Feel Portability

Even support Mobile Application (J2ME) Intelligent install and update

Java web start Disconnected operation

Local processing Development tooling support

RCP IDE

Page 7: Rcp by example

Real time Examples for RCP

IBM Workplace Client Technology Maestro - NASA Space Mission

Management And lot more ….

Page 8: Rcp by example

Important Classes

Application

Page 9: Rcp by example

Application class

Must Implement IPlatformRunnable

Note: We can use any name as Class but here we are following RCP Standard naming convention.

Page 10: Rcp by example

Application class

Must Implement IPlatformRunnable Implement run method

Page 11: Rcp by example

Application class

Implement IPlatformRunnable Implement run method Run method is Main method

Page 12: Rcp by example

Application class

Implement IPlatformRunnable Implement run method Run method is Main method Starting point of your application and

Ending of your application

Page 13: Rcp by example

Application class

package com.rcp.example;

import org.eclipse.core.runtime.IPlatformRunnable;import org.eclipse.swt.widgets.Display;import org.eclipse.ui.PlatformUI;

/** * This class controls all aspects of the application's execution */public class Application implements IPlatformRunnable {

public Object run(Object args) throws Exception {Display display = PlatformUI.createDisplay();

try {int returnCode = PlatformUI.createAndRunWorkbench(display,new ApplicationWorkbenchAdvisor()); if (returnCode == PlatformUI.RETURN_RESTART) { return IPlatformRunnable.EXIT_RESTART; }

return IPlatformRunnable.EXIT_OK;} finally {

display.dispose();}

}

}

Page 14: Rcp by example

Important Classes

Application ApplicationWorkbenchAdivsor

Page 15: Rcp by example

ApplicationWorkbenchAdivsor class

Extend WorkbenchAdvisor

Page 16: Rcp by example

ApplicationWorkbenchAdivsor class

Must extend WorkbenchAdvisor Application Level advice

Page 17: Rcp by example

ApplicationWorkbenchAdivsor class

Must extend WorkbenchAdvisor Application Level advice Participates in the start up and shut

down of the workbench

Page 18: Rcp by example

ApplicationWorkbenchAdivsor class

Must extend WorkbenchAdvisor Application Level advice Participates in the start up and shut

down of the workbench One running Workbench per running

Eclipse application

Page 19: Rcp by example

ApplicationWorkbenchAdivsor class

package com.rcp.example;

import org.eclipse.ui.application.IWorkbenchWindowConfigurer;import org.eclipse.ui.application.WorkbenchAdvisor;import org.eclipse.ui.application.WorkbenchWindowAdvisor;

public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor {

private static final String PERSPECTIVE_ID = "RCPView.perspective";

public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {return new ApplicationWorkbenchWindowAdvisor(configurer);

}

public String getInitialWindowPerspectiveId() {return PERSPECTIVE_ID;

}

}

Page 20: Rcp by example

Important Classes

Application ApplicationWorkbenchAdivsor ApplicationWorkbenchWindowAdiv

sor

Page 21: Rcp by example

ApplicationWorkbenchWindowAdivsor class

Must Extend WorkbenchWindowAdvisor

Page 22: Rcp by example

ApplicationWorkbenchWindowAdivsor class

Must Extend WorkbenchWindowAdvisor

Window-level advice

Page 23: Rcp by example

ApplicationWorkbenchWindowAdivsor class

Must Extend WorkbenchWindowAdvisor

Window-level advice Helps to show or hide the menu, cool

bar etc.,

Page 24: Rcp by example

ApplicationWorkbenchWindowAdivsor class

Must Extend WorkbenchWindowAdvisor

Window-level advice Helps to show or hide the menu, cool

bar etc., Only one instance for each window

Page 25: Rcp by example

ApplicationWorkbenchWindowAdivsor class

package com.rcp.example;

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("RCP Application");

}}

Page 26: Rcp by example

Important Classes

Application ApplicationWorkbenchAdivsor ApplicationWorkbenchWindowAdiv

sor ActionBarAdvisor

Page 27: Rcp by example

ActionBarAdvisor class

Must extend ActionBarAdvisor Important methods are

makeActions fillMenuBar

Page 28: Rcp by example

Important Classes

Application ApplicationWorkbenchAdivsor ApplicationWorkbenchWindowAdiv

sor ActionBarAdvisor Perspective

Page 29: Rcp by example

Perspective class

Must implement IPerspectiveFactory Implement createInitialLayout method

Page 30: Rcp by example

Perspective class

package com.rcp.example;

import org.eclipse.ui.IPageLayout;import org.eclipse.ui.IPerspectiveFactory;

public class Perspective implements IPerspectiveFactory {

public void createInitialLayout(IPageLayout layout) {String editorArea = layout.getEditorArea();layout.setEditorAreaVisible(false);layout.setFixed(true);layout.addStandaloneView(View.ID, false, IPageLayout.LEFT, 1.0f, editorArea);

}

}

Page 31: Rcp by example

Perspective class

Must implement IPerspectiveFactory Implement createInitialLayout method

Generates the initial page layout

Page 32: Rcp by example

Important Classes

Application ApplicationWorkbenchAdivsor ApplicationWorkbenchWindowAdiv

sor ActionBarAdvisor Perspective View

Page 33: Rcp by example

View class

Must extend ViewPart

Page 34: Rcp by example

View class

Must extend ViewPart Page design (Forms,Showing Buttons,

etc)

Page 35: Rcp by example

View class

package com.rcp.example;import org.eclipse.jface.viewers.TableViewer;import org.eclipse.swt.SWT;import org.eclipse.swt.widgets.Composite;import org.eclipse.ui.part.ViewPart;public class View extends ViewPart {public static final String ID = "RCPView.view";private TableViewer viewer;/** This is a callback that will allow us to create the viewer and initialize it */public void createPartControl(Composite parent) {

viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL| SWT.V_SCROLL);viewer.setContentProvider(new ViewContentProvider());viewer.setLabelProvider(new ViewLabelProvider());viewer.setInput(getViewSite());

}/** Passing the focus request to the viewer's control. */public void setFocus() {

viewer.getControl().setFocus();} }

Page 36: Rcp by example

Flow

Page 37: Rcp by example

Plugin.xml<?xml version="1.0" encoding="UTF-8"?><?eclipse version="3.2"?><plugin>

<extension id="application" point="org.eclipse.core.runtime.applications"> <application> <run class="com.rcp.example.Application"> </run> </application> </extension> <extension point="org.eclipse.ui.perspectives"> <perspective name="Perspective" class="com.rcp.example.Perspective" id="RCPView.perspective"> </perspective> </extension> <extension point="org.eclipse.ui.views"> <view name="View" class="com.rcp.example.View" id="RCPView.view"> </view> </extension>

</plugin>

Page 38: Rcp by example

Run the Application

Page 39: Rcp by example

Recommended Reading Eclipse Rich Client Platform

By Jeff McAffer and Jean-Michel Lemieux Addison-Wesley Professional ISBN: 0321334612

SWT : The Standard Widget Toolkit, Volume 1 By Steve Northover, Mike Wilson Addison-Wesley Professional ISBN: 0321256638

Contributing to Eclipse: Principles, Patterns, and Plugins By Erich Gamma, Kent Beck Addison-Wesley Professional ISBN: 0321205758

Page 40: Rcp by example

Prerequisites

Eclipse RCP Target download used is eclipse-RCP-SDK-3.1.2-win32.zip

j2sdk 1.4.2 or higher

Page 41: Rcp by example

Thanks for your time