Colorado Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

The Rich Platform (RCP)

Chris Laffra IBM Ottawa Labs http://eclipsefaq.org/chris

Chris Laffra — The Eclipse Platform (RCP) Page 1 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Roadmap ƒ Introduction ƒ Rich Client Programming ƒ The Eclipse RCP Project ¾Examples of RCP applications ¾All about plug-ins ¾Building your own Eclipse RCP application ƒ Conclusions

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 2 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Source of Materials ƒ Material sources: ¾ RCP tutorials at eclipse.org ¾ RCP samples from eclipse.org ¾ Feedback from Eclipse committers

¾ The Official Eclipse 3.0 FAQs Æ

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 3 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Format ƒ Each slide is one question with an answer ƒ We will introduce ¾ Some background; what is a Rich Client? ¾ The Eclipse project and RCP ¾ Show lots of sample code and demos ƒ After this presentation, you should be able to develop your own Eclipse RCP application.

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 4 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

What Is a Rich Client? ƒ Google dictionary: A program that can download files for manipulation, run applications, or request application- based services from a file server. ƒ Need some form of ‘installation’. ƒ Not a (like a Web site). ƒ A ‘client’ with rich UI and interaction

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 5 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Rich Client Examples ƒ Applets in a browser ƒ JavaScript applications (e.g., Bindows) ƒ J2ME MIDP Midlets on a phone/PDA ƒ Macromedia Flash MX ƒ Microsoft Foundation Class (MFC) apps ƒ Eclipse Rich Clients

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 6 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Rich Client Criterias ƒ Mind-share (following the current trend) ƒ Support for various platforms ƒ Ease of installation ƒ Look-and-Feel ƒ The ‘Richness’ of the solution ƒ Interoperability with other solutions ƒ Tooling support ƒ Performance

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 7 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

The Eclipse RCP in a Nutshell ƒ The Eclipse Rich Client Platform is a subset of the Eclipse platform designed for developing Rich Clients written in Java, using the Eclipse plug-in model for defining individual components using XML manifests. ƒ Open Source, free. ƒ Uses SWT for close-to-native feeling

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 8 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Eclipse RCP Sample 1

ƒ See the EclipseCon website

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 9 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Eclipse RCP Sample 1

GDF Suite Mgmt. Center

See the EclipseCon website

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 10 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Eclipse RCP Sample 2

IBM Lotus Workplace Suite

See the EclipseCon website

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 11 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Eclipse RCP Motivation ƒ Modular approach, using plug-ins written in XML and Java. Connections between plug-ins are loose. ƒ Lots of open source plug-ins easily added to your application ƒ Eclipse behaves like a native application (due to SWT). ƒ Eclipse is a framework. Lots of lessons learned and decisions have been made for you, leaving you more time to focus on your value add. The learning curve will pay off. ƒ Upgradeability. Use plug-ins to upload content handlers, and provide users with a given set of abilities and plugins based on their credentials. ƒ Versioning. Plug-ins are versioned, platform manages them. ƒ Momentum. Coolness factor. Great to put on your resume.

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 12 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

The Eclipse RCP in Detail ƒ We will use selected FAQs from the Eclipse FAQ book to address the Rich Client Platform (RCP) sub-set of Eclipse. ƒ Each question is modified for the purpose of this presentation and to improve the flow. ƒ More details on each topic can be found at http://eclipsefaq.org or in the book. ƒ Notice the FAQ number listed at the bottom:

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 13 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Eclipse FAQs Book Structure Book has 3 Parts: 1. Introduction 2. RCP 3. IDE Focus is on Part II, but a plug-in from Part III could easily be added to your RCP application

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 14 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

What Is Eclipse? An open IDE platform for anything, and for nothing in particular. ƒ Open: allows for easy extension by third parties. ƒ IDE: tooling to manage workspaces; to build, launch and debug applications; team sharing; easy customization of the programming experience. ƒ Platform: not a finished application ƒ Anything: Java, Web-services, games, etc. ƒ Nothing in particular: Java focus is historical.

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 15 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Where Did Eclipse Come From? ƒ Core of OTI/IBM products since late 90’s ƒ VisualAge for Java (written in Smalltalk with Common Widget Toolkit – CWT) ƒ VisualAge Micro Edition (written in Java, first use of SWT) ƒ VAME framework generalized into Eclipse ƒ Eclipse open source project, Fall 2001

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 16 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

What Articles Are There? ƒ More than 50 at http://eclipse.org/articles ƒ Printable format is over 500 pages ƒ Covers wide range of Eclipse topics; from SWT to preferences to RCP to Wizards to style guides to internationalization to editor support to using CVS branching. ƒ IBM DeveloperWorks also hosts a few dozen articles on Eclipse and products

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 17 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

What Books Are Available? ƒ More than 22 were counted in July 2004 ƒ Many are introductory with wide coverage ƒ Others focus on vertical domain (SWT, EMF) ƒ FYI: Amazon lists 1 book for Netbeans

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 18 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Where to Download Eclipse? ƒ Eclipse.org/downloads: ¾ Latest Release tested, may be 6 months old ¾ Stable/milestone build, 6 weeks apart ¾ Integration build, each week ¾ Nightly build, mileage varies ¾ directly from CVS, not for the faint of heart ƒ Builds are tested and results are posted

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 19 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Eclipse Supported Platforms ƒ Microsoft Windows 2000/XP ƒ Red Hat Enterprise Linux ƒ SuSE Linux 8.2 ƒ Sun Solaris 8 SPARC Motif ƒ HP HP−UX 11i hp9000 ƒ IBM AIX 5L PowerPC Motif ƒ Apple Mac OS X ƒ Mac OS X ƒ QNX Neutrino RTOS

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 20 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

How to Upgrade Eclipse? ƒ Use the included Update Manager ¾ works for Eclipse IDE and RCP ¾ upgrade existing plug-ins to later versions ¾ install new plug-ins from third party locations ƒ Allows you to build a rich client and have extensions added later (like content handlers or additional business logic)

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 21 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Where to Get Help? ƒ Included in your plug-ins/application: ¾Help > Help Contents… ¾F1, context-sensitive help ¾Can be added to an RCP application ƒ During development: ¾http://eclipse.org (articles, newsgroups, etc.) ¾Books, tutorials, portals ¾“Use the source, Luke!”

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 22 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Writing Java Code in Eclipse ƒ Beyond the scope of this presentation ƒ Main distinguishing factors for Eclipse: ¾Incremental building in background ¾Content Assist ¾Quick Fixes ¾Searching, navigating, class browsing ¾Refactoring ¾Debugging and hot code replace ¾Sharing in a repository

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 23 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

How Do I Create a Plug-in? ƒ Plug-in Development Environment (PDE) has special wizards to get you going quickly ƒ Use code templates to create a plug-in with: ¾A toolbar button and a menu option ¾An editor ¾A view (with a tree or a table) ¾A property page ¾A new perspective ƒ Help > Cheat Sheet…

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 24 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

How Do I Edit a Plug-in? Plug-in Manifest editor provides a graphical view on the plug-in XML file.

F1 can be used to get Help.

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 25 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

How Do I Run My Plug-in? ƒ Run > Run as > Run-time Workbench ƒ Run… or F11 to launch the last workbench ƒ Ctrl-F11 to debug your plug-in

Development workbench with my plug-ins

F11

Runtime workbench

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 26 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Extension Point Creation ƒ Plug-ins can publish extension points ƒ Create them ala “Monkey see, Monkey do” ƒ Alternatively, use PDE manifest editor: ¾Extension Points > Add… ¾Choose an ID and a name ¾Choose a name for your schema ¾Add one or more elements and save ƒ Generated code ends up in plugin.xml file ƒ Click F1 to get Help

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 27 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Extension Point Activation ArrayList contributors = new ArrayList(); IExtensionPoint point = Platform. getExtensionRegistry().getExtensionPoint(ID); IExtension[] extensions = point.getExtensions(); for (int i = 0; i < extensions.length; i++) { IExtension ext = extensions[i]; IConfigurationElement[] elements = ext.getConfigurationElements(); for (int j = 0; j < elements.length; j++) { contributors.add( elements[j].createExecutableExtension("class")); } }

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 28 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

How Do I Create a Feature? ƒ A special PDE wizard can create a feature: File > New > Other... > Plug−in Development > Feature Project ƒ Just add the plug-ins you want to add ƒ Features are the next step up from plug-ins ƒ A product is shipped as a collection of features, each containing one/more plug-ins

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 29 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

What Is the Update Manager? ƒ Help > Software Updates… ƒ Allows you to find new features on your workstation, network, or the Internet ƒ Manages configurations, allowing installation and deactivation of features ƒ Needs “update sites” to download features

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 30 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

How to Create an Update Site? ƒ A special PDE wizard: File > New > Other... > Plug−in Development > Update Site Project ƒ Just add the features you want to add ƒ Generates site.xml ƒ Editor has a special “Build All” button

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 31 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Plug-in, Feature, Update Site ƒ Update site has one or more features ƒ Features have one or more plug-ins ƒ Plug-ins provide icons, plugin.xml and Java implementation ƒ Supports versioning

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 32 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

What Is a Plug-in? ƒ An encapsulation of behavior that cooperates with other plug-ins to construct a program ƒ Plug-ins typically consists of: ¾Manifest, described in plugin.xml ¾Icons and resource bundles ¾Java code in one or more jars ƒ In Eclipse, everything is a plug-in

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 33 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

What Is the plugin.xml File? ƒ Here is an example:

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 34 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

How Do I Connect Plug-ins? ƒ To access classes from other plug-ins, add those to your plugin.xml: ƒ To publish certain classes from your plug-in, use a library and a wild-card:

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 35 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

How Do I Connect Plug-ins? ƒ Use extension points published by other plug-ins to add your behavior to Eclipse

ƒ Define (publish) new extension points to allow others to customize your implementation

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 36 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

What Are Extension Points? ƒ Extension points (e.p.) are all about loose coupling of complex system ƒ Interface is described in XML ƒ Implementation is done in Java ƒ Allow for extending/customizing existing systems

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 37 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

What Is an e.p. Schema? ƒ Each e.p. has a schema ƒ Defines the e.p. elements/grammar ƒ Also contains documentation ƒ Used only during development ƒ Not used for runtime validation ƒ See PDE Manifest Editor to edit

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 38 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

When Is a Plug-in Started? ƒ Plug-in has declarative and code parts ƒ Declarative part is analyzed to show UI ƒ Code part is started lazily, as late as possible, only when really needed: ¾When executable extension is generated ¾When published classes are used by others ¾When explicitly created (e.g. early startup) ƒ Plug-in class is loaded before any other

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 39 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

What’s the Plug-in’s classpath? ƒ This is a question often asked by ‘traditional’ Java programmers ƒ A plug-in’s classpath lookup order is: 1. OSGi parent classloader (bootloader, rt.jar) 2. Exported libraries from required plug-ins 3. Plug-in’s own libraries ƒ You could declare your own custom classloader (e.g., done by Ant and Help)

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 40 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

What Is a Plug-in Fragment? ƒ Plug-ins can have optional parts, each declared in a fragment, using fragment.xml ƒ Example: SWT + 1 fragment per platform ƒ Behaves similarly to regular plug-in ƒ Main mechanism for plug-in customization ƒ Fragments are added to plug-in classpath ƒ Infrequently used

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 41 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

What Is a Dynamic Plug-in? ƒ Dynamic plug-ins avoid a platform restart ƒ Four classes of dynamicity: ¾ Nondynamic, lots of hard links to other plug- ins ¾ Dynamic-aware, expects other plug-ins to be unloaded at any given time ¾ Dynamic-enabled, can be unloaded without needing to restart the platform ¾ Fully Dynamic, uses OSGi to the fullest power to unload or reload itself

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 42 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Runtime Support ƒ The Eclipse Runtime has support for ¾ Progress monitors ¾ Logging and debug tracing ¾ Preferences storage ¾ Management of background jobs ƒ Plug-in: org.eclipse.core.runtime

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 43 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

What Is a ProgressMonitor? ƒ Here is an example: ProgressMonitor monitor = ...; try { monitor.beginTask("Performing decathlon: ", 10); monitor.subTask("hammer throw"); //perform the hammer throw monitor.worked(1); //... repeat for remaining nine events } finally { monitor.done(); }

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 44 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

What Is a Job? ƒ Runs in background and not in UI thread ƒ Used for long-running activities, such as building, server connections, etc. ƒ Here is an example:

Job myJob = new Job("Sample Job") { public IStatus run(IProgressMonitor monitor) { System.out.println("This runs in a job"); } }; myJob.schedule();

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 45 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Job Advantages? ƒ Runs in background and not in UI thread ƒ Less overhead, uses thread pooling ƒ Support for progress and cancellation ƒ Priorities and mutual exclusion ƒ Advanced scheduling features ƒ Centralized UI

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 46 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

What Is SWT? ƒ SWT = Standard Widget Toolkit ƒ Goal: “efficient, portable access to the user interface features of the operating systems on which it is implemented.” ƒ Thin native mapping layers. For instance, Tree widget is Java API that maps directly to a native widget on Windows. ƒ Runs on Win32, Linux, AIX, HPUX, MacOS, Photon, and Pocket PC

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 47 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Why Does Eclipse Use SWT? ƒ Historical: VisualAge for Java, writing in Smalltalk, used the Common Widget toolkit ƒ Early experiments used the brand new Swing toolkit in 1998. For IDEs, the design team chose for native look & feel. Hence CW was ported to Java, and adopted in Eclipse ƒ Eclipse is an integration platform; integrating closely with the OS makes a lot of sense ƒ SWT and Swing are interoperable

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 48 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Is SWT Better than Swing? ƒ Is a hammer better than a screwdriver? ƒ Different tools, with different goals ƒ SWT goals: native look and feel, high performance, deep platform integration ƒ Swing goals: high customization, same look and feel across platforms ƒ Answer depends on your tradeoffs and customer preference

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 49 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

The JFace Framework ƒ UI Framework on viewers wizards top of SWT, adding actions JFace commonly used dialogs components preferences ƒ Like SWT, loosely based on Eclipse; button menu tree table can be used in shell SWT isolation easily layout …

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 50 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

What Is a Viewer? ƒ Model-view-controller on top of SWT ƒ Adds lower-level management to a widget: add/remove items, sort, filter, refresh, etc. ƒ Example of a TableViewer:

int style = SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL; Table table = new Table(parent, style); TableViewer viewer = new TableViewer(table); viewer.setContentProvider(new BookshelfContentProvider()); viewer.setLabelProvider(new BookshelfLabelProvider()); viewer.setInput(createBookshelf());

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 51 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

What Is a Viewer? ƒ Various kinds of viewers: ¾ TreeViewer ¾ TableViewer ¾ ListViewer ¾ TableTreeViewer ¾ TextViewer ¾ CheckBoxTreeViewer ¾ CheckBoxTableViewer ƒ Example of a TreeViewer Æ

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 52 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

What Is a Viewer? ƒ Corresponding Spider diagram:

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 53 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

What Is a Wizard? ƒ A wizard contains: ¾ Series of Pages ¾ Back/Next buttons ¾ Finish/Cancel buttons ¾ A title ¾ A message area A sample wizard ¾ A progress monitor ƒ May be in a Dialog but not necessarily ƒ API controls page order

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 54 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

How Do I Show a Wizard? ƒ Implement IWizardContainer (such as the JFace WizardDialog does)

ƒ Here is an example:

Shell shell = window.getShell(); MyWizard wizard = new MyWizard(); WizardDialog dialog = new WizardDialog(shell, wizard); int result = dialog.open();

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 55 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

How Do I Ask a Question? ƒ Two kinds of questions: ¾ MessageDialog.openQuestion(…) Yes/No ¾ MessageDialog.openConfirm(…) OK/Cancel ƒ Here is an example: IStatus warning = new Status(IStatus.WARNING, ExamplesPlugin.ID, 1, “Final warning.", null); ErrorDialog.openError(window.getShell(), "This is your final warning", null, warning); ƒ Custom message dialogs are also possible

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 56 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

The Generic Workbench ƒ The generic elements in the workbench ƒ Naming history for “workbench”: ¾ Used to be called “Desktop” in older Eclipses ¾ With IDE focus, renamed to “Workbench” ¾ With RCP focus, renamed to RCP ƒ Generic workbench contains: ¾ The Workbench itself, with its parts, pages, windows, progress view, status bar, menu, etc.

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 57 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Parts, Pages, Sites, Windows, eh? ƒ The entire UI is called “Workbench” ƒ Displayed in one or more “Windows”: ¾ Title bar, Menu bar, and Cool bar ¾ Fast view bar ¾ Status line + Progress view ¾ Workbench pages contents: • One or more workbench parts: Editors + Views • Layout is controlled by a “Perspective”

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 58 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Parts, Pages, Sites, Windows, eh? ƒ Example: ContentOutline knows its site, which provides API to its page, which is hosted by a window, which belongs to the workbench:

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 59 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Creating Preference Pages ƒ Extension point in org.eclipse.ui.workbench ƒ Implement either IPreferencePage or IFieldEditorPreferencePage ƒ Preference pages can also be used stand-alone, without using extension points See: Programmer’s Guide > Preference pages and three Eclipse articles on Preference pages

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 60 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Using an ImageRegistry ƒ Images are OS resources that need to be managed carefully to avoid waste & leaks ƒ Here is an example: public class ExamplesPlugin extends AbstractUIPlugin { public static final String PLUGIN_ID = "org.eclipse.faq.examples"; public static final String IMAGE_ID = "sample.image"; ... protected void initializeImageRegistry(ImageRegistry registry) { Bundle bundle = Platform.getBundle(PLUGIN_ID); IPath path = new Path("icons/sample.gif"); URL url = Platform.find(bundle, path); ImageDescriptor desc = ImageDescriptor.createFromURL(url); registry.put(IMAGE_ID, desc); } }

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 61 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Creating New Perspectives ƒ Extension point: org.eclipse.ui.perspectives ƒ Defines initial layout relative to editor area and contents of menubar and toolbar ƒ API allows for whatever you can do in Window > Customize Perspective ƒ See Help for a good explanation in the PDE section to create new perspectives

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 62 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Views and Editors ƒ Workbench contains Views and Editors. Create one using the PDE plug-in template wizard.

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 63 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Views and Editors Compared

Views Editors e.g., Outline/Navigator e.g., Java Editor/PDE Arbitrary contents Arbitrary contents Arbitrary layout Arbitrary layout One per page Multiple per page Anywhere on page At fixed page location Nothing to save Can be “dirty” Have a local toolbar Use global toolbar

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 64 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

A Minimal Editor ƒ Step one: declare extension point, specify what file extensions to handle, and class name of editor.

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 65 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

A Minimal Editor ƒ Step two: Implementation.

public class MinimalEditor extends EditorPart { private Label contents; public void createPartControl(Composite parent) { contents = new Label(parent, SWT.NONE); contents.setText("Minimal Editor"); } public void init(IEditorSite site, IEditorInput input) { setSite(site); setInput(input); } public void setFocus() { contents.setFocus(); } }

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 66 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

More Elaborate Editors ƒ For form-based editors, such as the PDE plugin.xml editor, use the org.eclipse.ui.forms extension point ƒ For graphical editors, see the Eclipse Graphical Editor Framework (GEF) project at http://eclipse.org/gef ƒ For nested editors, see the PDE wizard that creates a multi-page editor, using the MultiPageEditorPart. ƒ For text editors, see Chapter 15 and 19 of the Eclipse FAQ book

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 67 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Buttons and Menus ƒ Menus and toolbars use ‘Actions’ to define content: ƒ See the PDE wizard for the ‘Hello World’ plug-in

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 68 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

What Is an Eclipse Application? ƒ Only one ‘application’ per Eclipse instance; the equivalent of ‘main’. Here is a plugin.xml sample:

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 69 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

What Is an Eclipse Application? ƒ Here is the Java part for this sample:

public class HelloWorld implements IPlatformRunnable { public Object run(Object args) { System.out.println("Hello"); return EXIT_OK; } }

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 70 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

What Is an Eclipse Application? ƒ Here is how the sample is executed: eclipse −application acme.hello ƒ The fully qualified ID is the plugin ID + application ID (i.e., “acme” + “.” + “helloworld”). ƒ Application get to fully control contents of menu, toolbar, views, etc. Much more control than plug- ins hosted by the Eclipse IDE. ƒ Eclipse Application can have UI or be headless ƒ See also IDEApplication in org.eclipse.ui.ide.

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 71 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

What Is an Eclipse Application? ƒ Here is the Java part for this sample:

public class HelloWorld implements IPlatformRunnable { public Object run(Object args) { System.out.println("Hello"); return EXIT_OK; } }

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 72 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Minimal Eclipse RCP App? ƒ RCP apps have full control over how UI is created. ƒ Control is implemented in WorkbenchAdvisor:

public class MinimalRCPApp extends WorkbenchAdvisor implements IPlatformRunnable { public String getInitialWindowPerspectiveId() {...} public void preWindowOpen(...) {...} public Object run(...) {...} }

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 73 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Minimal Eclipse RCP App? ƒ First, tell the configurer what perspective to use:

public String getInitialWindowPerspectiveId() { return "org.eclipse.faq.minimalperspective"; }

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 74 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Minimal Eclipse RCP App? ƒ Then, tell the configurer what to show:

public void preWindowOpen( IWorkbenchWindowConfigurer wwc) { wwc.setShowMenuBar(false); wwc.setShowFastViewBars(false); wwc.setShowStatusLine(false); wwc.setShowCoolBar(false); }

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 75 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Minimal Eclipse RCP App? ƒ Finally, get an SWT display, and launch the platform on it, using your workbench advisor:

public Object run(Object args) throws Exception { Display d = PlatformUI.createDisplay(); int ret = PlatformUI.createAndRunWorkbench(d, this); if (ret == PlatformUI.RETURN_RESTART) return EXIT_RESTART; return EXIT_OK; }

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 76 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Minimal Eclipse RCP App? ƒ The result; no menu bar, no toolbar, no status bar, no views, no editors:

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 77 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Customizing the RCP Menu ƒ Method implemented by WorkbenchAdvisor: public void fillActionBars(IWorkbenchWindow window, IActionBarConfigurer configurer, int flags) { if ((flags & FILL_MENU_BAR) == 0) return; IMenuManager mainMenu = configurer.getMenuManager(); MenuManager windowMenu = new MenuManager("&Window", IWorkbenchActionConstants.M_WINDOW); mainMenu.add(windowMenu); windowMenu.add(ActionFactory.MAXIMIZE.create(window)); MenuManager helpMenu = new MenuManager("&Help", IWorkbenchActionConstants.M_HELP); mainMenu.add(helpMenu); helpMenu.add(new AboutAction()); }

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 78 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Enabling Action Key Bindings ƒ Key bindings are made for free when you use the actionSet extension point in your plugin.xml ƒ When you create actions on the fly, make sure your action has a command ID, and then use:

IWorkbenchWindowConfigurer wwc = ...; IAction action = ...; wwc.registerGlobalAction(action);

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 79 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Just Use SWT and JFace? ƒ FAQ 247 discusses how simple that is ƒ Complete source is offered at http://eclipsefaq.org

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 80 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Storing Application Data ƒ Data is stored in the ‘workspace’ ƒ Simplest way is to rely on the -data argument ƒ Make sure to lock the workspace ƒ See Platform.getInstanceLocation(); ƒ You can choose your own location ƒ See IDEApplication for all the subtleties

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 81 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Enabling Action Key Bindings ƒ Key bindings are made for free when you use the actionSet extension point in your plugin.xml ƒ When you create actions on the fly, make sure your action has a command ID, and then use:

IWorkbenchWindowConfigurer wwc = ...; IAction action = ...; wwc.registerGlobalAction(action);

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 82 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Application vs. Product ƒ Application has program logic written in Java ƒ Product is entirely declarative and specifies: ¾ Icons, text, splash screen, etc. ƒ One product, can have multiple applications ƒ Example: Eclipse IDE is one product, but has multiple applications, such as the workbench and custom Ant runners

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 83 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Product Distribution ƒ Zip it up, add a JRE, use an installer ƒ Use features and an Update for upgrades ƒ Add multiple languages (lots of support here) ƒ Use install handlers to do post-installation fixes ƒ Add your own splash screen and workbench icon ƒ Write your own platform launcher (eclipse.exe) ƒ Use art from http://eclipse.org/artwork/main.html

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 84 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Customizing RCP Apps ƒ See the plugin_customization.ini file ƒ Example to use curved view header tabs: org.eclipse.ui/SHOW_TRADITIONAL_STYLE_ TABS=false

ƒ See Help > Help Contents > Platform Plug-in Developers Guide > Programmer’s Guide > Packaging and Delivering Eclipse-based Products > What is a Product? > Customizing a Product

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 85 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

References ƒ http://eclipse.org ƒ http://dev.eclipse.org/viewcvs/index.cgi/ ~checkout~/platform-ui-home/rcp ƒ http://eclipsefaq.org

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 86 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Eclipse 3.0 Statistics

Eclipse 3.0 by the numbers Use the Source, Luke The following statistics for the Eclipse 3.0 development Java source files: 9,689, Lines of code: 1,903,219 period only, from March 28, 2003, until June 28, Lines of XML source code: 33,280, GIF files: 1,674 2004, and cover only the Eclipse SDK components (Platform, JDT, and PDE). Figures on the Eclipse Automated JUnit tests run every build: 21,332 source code refer to the deployed SDK code, Most tests for single component (JDT Core): 9,747 excluding all test Least tests for single component (PDE Core/UI): 0 and example code. Instances of the word "foo" in the source: 224 Instances of the word "todo" in the source: 1,085 View from the top Instances of the word "hack" in the source: 43 Plug-ins: 76, New plug-ins in 3.0: 17 Most CVS revisions for file (JavaCore.java): 413 SDK download size increase(from 2.1): 23,881 KB Size of the smallest plug-in (org.eclipse.core.boot): 3 KB Trial and error Size of the largest plug-in (org.eclipse.jdt.ui): 5,750 KB Number of different "new looks": 4 Days in the Eclipse 3.0 development period: 458 Different background progress animations: 7 Integration builds: 356, Milestone builds: 9 Terms for scalable UI proposals (activity, context, Donuts consumed (North American committers): 1,120 role, scope, capability): 5 Cigarettes inhaled (European committers): 14,656 API changes after "official" API freeze (May 7): 49 3.0 plan items: 95, 3.0 plan items marked fixed: 43 Deadlock bugs fixed while adding jobs support: 129 Number of boolean or numeric preferences: 638 Number of color preferences: 94

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 87 Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation

Eclipse 3.0 Statistics

Learning to communicate More Eclipszilla Number of newsgroup posts: 47,427 Most bugs entered (Darin Swanson): 746 Most posts in newsgroup thread (M8 Look and feel): 78 Most by non-committer (Sebastian Davids): 363 Most newsgroup posts (Steve Northover): 763 Most bugs marked fixed (Darin Swanson): 680 Most mailing list posts (Sonia Dimitrov): 2,617 Most bug comments (Darin Wright): 6,511 Lines of poetry sent to the platform.releng mailing list: 45 Most bugs owned (Tod Creasey): 943 Most bugs marked invalid, worksforme, or Just Google it duplicate by an individual (Dani Megert): 786 Google hits for the "Eclipse 3.0": 91,900 Most comments on a single bug (bug 37683): 195 Google hits for "OSGi" and "Eclipse": 45,500 Most votes for a single bug (bug 9355): 109 Google hits for “RCP" and "Eclipse": 26,800 Largest bug CC list (36938 and 37997): 79 Google hits for the "new look" and "Eclipse": 16,500 Bugs fixed with more than one vote: 262 Google hits for the "JDK 1.5" and "Eclipse": 11,300 Bug reports containing "running man": 100 Google hits for "Responsiveness" and "Eclipse": 6,720 Making a commitment Eclipzilla Active committers: 62, New committers: 22 Bugzilla bug or enhancement reports entered: 26,778 Children born to committers during the 3.0 cycle: 6 Bugs resolved (fixed, wontfix, duplicate, etc): 24,365 Most files in local history (Dirk): 30,339 Bugzilla reports fixed: 11,772 Committers who skipped EclipseCon because of Distinct bug reporters: 4,513 unpaid U.S. parking tickets: 1

Chris Laffra — The Eclipse Rich Client Platform (RCP) Page 88