Colorado Software Summit: October 24 – 29, 2004 © Copyright 2004, IBM Corporation
The Eclipse Rich Client Platform (RCP)
Chris Laffra IBM Ottawa Labs http://eclipsefaq.org/chris
Chris Laffra — The Eclipse Rich Client 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 computer 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 Thin Client (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 Java 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:
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:
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