Mastering Eclipse Plug-in Development
()
About this ebook
Read more from Dr Alex Blewitt
Swift Essentials Rating: 0 out of 5 stars0 ratingsEclipse Plug-in Development: Beginner's Guide - Second Edition Rating: 0 out of 5 stars0 ratings
Related to Mastering Eclipse Plug-in Development
Related ebooks
Mastering Jenkins Rating: 3 out of 5 stars3/5JavaScript at Scale Rating: 0 out of 5 stars0 ratingsBuilding Web Services with Microsoft Azure Rating: 0 out of 5 stars0 ratingsScala for Data Science Rating: 0 out of 5 stars0 ratingsRestlet in Action: Developing RESTful web APIs in Java Rating: 0 out of 5 stars0 ratingsDjango Admin Cookbook Rating: 0 out of 5 stars0 ratingsLearning Azure DocumentDB Rating: 0 out of 5 stars0 ratingsPostgreSQL Development Essentials Rating: 5 out of 5 stars5/5Nginx Troubleshooting Rating: 0 out of 5 stars0 ratingsStruts 2 in Action Rating: 0 out of 5 stars0 ratingsPostgreSQL Replication - Second Edition Rating: 0 out of 5 stars0 ratingsApache Hive Cookbook Rating: 0 out of 5 stars0 ratingsNginx Essentials Rating: 0 out of 5 stars0 ratingsAkka Cookbook Rating: 2 out of 5 stars2/5Learning HBase Rating: 0 out of 5 stars0 ratingsOpa Application Development Rating: 0 out of 5 stars0 ratingsDynamoDB Cookbook Rating: 0 out of 5 stars0 ratingsExtending Docker Rating: 0 out of 5 stars0 ratingsMastering JBoss Drools 6 Rating: 0 out of 5 stars0 ratingsScala Functional Programming Patterns Rating: 0 out of 5 stars0 ratingsGit Version Control Cookbook Rating: 4 out of 5 stars4/5Scala in Depth Rating: 4 out of 5 stars4/5Building Scalable Apps with Redis and Node.js Rating: 0 out of 5 stars0 ratingsWebRTC Cookbook Rating: 0 out of 5 stars0 ratingsRedis Essentials Rating: 0 out of 5 stars0 ratingsMastering PostgreSQL 9.6 Rating: 0 out of 5 stars0 ratingsStep-by-Step Angular Routing: Learn To Create client-side and Single Page Apps with Routing and Navigation Rating: 0 out of 5 stars0 ratingsSpring Boot in Practice Rating: 0 out of 5 stars0 ratingsOSGi in Action: Creating Modular Applications in Java Rating: 0 out of 5 stars0 ratings
Internet & Web For You
HTML, CSS, & JavaScript All-in-One For Dummies Rating: 0 out of 5 stars0 ratingsGrokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5The $1,000,000 Web Designer Guide: A Practical Guide for Wealth and Freedom as an Online Freelancer Rating: 4 out of 5 stars4/5Python: Learn Python in 24 Hours Rating: 4 out of 5 stars4/5SEO For Dummies Rating: 4 out of 5 stars4/5Social Engineering: The Science of Human Hacking Rating: 3 out of 5 stars3/5Notion for Beginners: Notion for Work, Play, and Productivity Rating: 4 out of 5 stars4/5CSS in Depth Rating: 2 out of 5 stars2/5Learn JavaScript in 24 Hours Rating: 3 out of 5 stars3/5UX/UI Design Playbook Rating: 4 out of 5 stars4/5Principles of Web Design Rating: 0 out of 5 stars0 ratingsGet Into UX: A foolproof guide to getting your first user experience job Rating: 4 out of 5 stars4/5Token Economy: How the Web3 reinvents the Internet Rating: 4 out of 5 stars4/5The Beginner's Affiliate Marketing Blueprint Rating: 4 out of 5 stars4/5The Digital Marketing Handbook: A Step-By-Step Guide to Creating Websites That Sell Rating: 5 out of 5 stars5/5React Deep Dive Rating: 5 out of 5 stars5/52022 Adobe® Premiere Pro Guide For Filmmakers and YouTubers Rating: 5 out of 5 stars5/5The Logo Brainstorm Book: A Comprehensive Guide for Exploring Design Directions Rating: 4 out of 5 stars4/5Coding All-in-One For Dummies Rating: 4 out of 5 stars4/5Build a WordPress Website From Scratch 2024: WordPress 2024 Rating: 0 out of 5 stars0 ratingsCoding For Dummies Rating: 5 out of 5 stars5/5Stop Asking Questions: How to Lead High-Impact Interviews and Learn Anything from Anyone Rating: 5 out of 5 stars5/5Clean Code in JavaScript: Develop reliable, maintainable, and robust JavaScript Rating: 5 out of 5 stars5/5Python Projects for Kids Rating: 5 out of 5 stars5/5
Reviews for Mastering Eclipse Plug-in Development
0 ratings0 reviews
Book preview
Mastering Eclipse Plug-in Development - Dr Alex Blewitt
Table of Contents
Mastering Eclipse Plug-in Development
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Plugging in to JFace and the Common Navigator Framework
JFace wizards
Creating a feeds wizard
Creating the classes
Adding pages to the wizard
Adding content to the page
Testing the wizard
Adding titles and images
Adding help
Finishing the wizard
Adding the FeedWizard to the newWizards extension point
Adding a progress monitor
Showing a preview
Common navigator
Creating a content and label provider
Integrating into Common Navigator
Binding content navigators to views
Adding commands to the common navigator
Reacting to updates
Optimizing the viewer updates
Linking selection changes
Opening an editor
Finding the line
Setting the selection
Summary
2. Creating Custom Extension Points
Extensions and extension points
Creating an extension point
Creating an IFeedParser interface
Creating a MockFeedParser class
Creating the extension point schema
Using the extension point
Caching extension points
Integrating the extension with the content and label providers
Showing a feed in the browser
Implementing a real feed parser
Adding support for Atom
Making the parser namespace aware
Priority and ordering
Executable extensions and data
Executable extension factories
Using the extension registry outside of OSGi
Using the extension registry cache
Loading all extensions from the classpath
Summary
3. Using OSGi Services to Dynamically Wire Applications
Overview of services
Registering a service programmatically
Creating an activator
Registering the service
Priority of services
Using the services
Lazy activation of bundles
Comparison of services and extension points
Registering a service declaratively
Declarative Services
Properties and Declarative Services
Service references in Declarative Services
Multiple components and debugging Declarative Services
Dynamic service annotations
Processing annotations at Maven build time
Blueprint
Installing Gemini Blueprint
Installing Aries Blueprint
Using the Blueprint service
Passing properties in Blueprint
Bean references and properties
Comparison of Blueprint and DS
Dynamic services
Resolving services each time
Using a ServiceTracker
Sorting services
Filtering services
Obtaining a BundleContext without using an activator
A note on ServiceReference
Dependent services
Dynamic Service Configuration
Installing Felix FileInstall
Installing Config Admin
Configuring Declarative Services
Config Admin outside of DS
Services and ManagedService
Creating an EmptyFeedParser class
Configuring the EmptyFeedParser
Service factories
Creating the EchoServer class
Creating an EchoServiceFactory class
Configuring EchoService
Summary
4. Using the Gogo Shell and Commands
Consoles in Equinox
Host OSGi Console
Running commands
Variables and pipes
Functions and scripts
Literals and objects
Calling and chaining methods
Control flow
Running Equinox from the command line
Understanding osgi.bundles and config.ini
Connecting remotely
Securing the connection
Creating a JAAS configuration
Understanding the configuration options
Launching the SSH daemon
Extending the shell
Adding commands from existing methods
Getting a class from an existing instance
Loading a class via a ClassLoader
Writing commands in Java
Creating the project
Using Declarative Services to register the command
Test the command
Processing objects with console commands
Adding the print bundles command
Returning a list of bundles
Processing a list with each
Calling functions from commands
Looping and iteration
Summary
5. Native Code and Fragment Bundles
Native code and Eclipse
Creating a simple native library
Mac OS X
Linux
Windows
Loading the native library
Library dependencies
Native code patterns
Native libraries in OSGi bundles
Optional resolution of native code
Multiple libraries for the same platform
Multiple libraries with the same name
Additional filters and constraints
Reloading native libraries
OSGi fragment bundles
Adding native code with fragments
Adding classes to a bundle
Patching bundles with fragments
Adding imports and exports with fragments
Extension bundles
Summary
6. Understanding ClassLoaders
Overview of ClassLoaders
ClassLoaders and inheritance
ClassLoaders in web application servers
ClassLoaders and garbage collection
OSGi and ClassLoaders
OSGi services and ClassLoaders
ThreadContextClassLoaders
Java ServiceLoader
Problems with ServiceLoader, OSGi, and Eclipse
Creating a service producer
Downloading the required bundles
Running the producer
Creating a service consumer
Running the consumer
OSGi upgrade strategies
Embedding the library directly
Wrapping the library with bnd
Upgrading the library to use services
Dealing with class resolution issues
Summary
7. Designing Modular Applications
Semantic versioning
Public APIs and version ranges
Baselining and automatic versioning
Eclipse API baselines
Bnd baseline
Bndtools
Maven baselining
Design patterns
The whiteboard pattern
The extender pattern
Best practices
Separate API and implementation
Decouple packages
Decouple services
Prefer Import-Package to Require-Bundle
Version packages and bundles
Avoid split packages
Import and export packages
Avoid start ordering requirements
Avoid long Activator start methods
Use configuration admin for configuration
Share services, not implementation
Loosely coupled and highly cohesive
Compile with the lowest level execution environment
Avoid Class.forName
Avoid DynamicImport-Package
Avoid BundleActivator
Consider thread safety
Test in different frameworks
Summary
8. Event-driven Applications with EventAdmin
Understanding the OSGi EventAdmin service
Sending e-mails
Creating an event
Posting an event
Receiving an event
Filtering events
Threading and ordering of event delivery
Comparison between EventAdmin and services
Framework events
Events and E4
Sending events with E4
Receiving events with E4
Subscribing E4 EventHandlers directly
Comparison between EventAdmin and IEventBroker
Designing an event-based application
Componentizing the application
Identifying the channels
Identifying the properties
Mapping the channels to topics
Simulating events
Versioning and loose typing
Event object contents
Comparison with JMS
Summary
9. Deploying and Updating with P2
Eclipse P2
Provisioning with the P2 director
Installing content into existing applications
Running P2 applications
Launching the JVM
Starting Equinox
P2 repositories
P2 artifacts and contents files
Binary and packed files
Creating P2 mirrors
Generating P2 metadata
Categorizing update sites
Composite update sites
The classic update manager
Touchpoints
Categorizing features with P2
Adding update sites automatically
Registering touchpoint actions
Adding JVM or program arguments
Custom touchpoints
Summary
10. User Assistance in Eclipse
Help pages in Eclipse
Adding help pages
Nested table of contents
Anchors and links
Linking to anchors in other plug-ins
Conditional enablement
Context-sensitive help
Active help
DocBook and Eclipse help
Mylyn WikiText and Eclipse help
Help Server and RCP
Help and Eclipse 3.x
Help and Eclipse 4.x
Running an InfoCenter standalone
Cheat sheets
Creating a cheat sheet
Adding commands
Optional steps
Responding to choice
Composite cheat sheets
Summary
Index
Mastering Eclipse Plug-in Development
Mastering Eclipse Plug-in Development
Copyright © 2014 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: August 2014
Production reference: 1210814
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78328-779-6
www.packtpub.com
Cover image by Asher Wishkerman (<wishkerman@hotmail.com>)
Credits
Author
Dr Alex Blewitt
Reviewers
Carla Guillen
Jeff MAURY
Peter Rice
Commissioning Editor
Kartikey Pandey
Acquisition Editor
Sam Wood
Content Development Editor
Susmita Panda Sabat
Technical Editor
Dennis John
Copy Editors
Roshni Banerjee
Mradula Hegde
Karuna Narayanan
Adithi Shetty
Project Coordinator
Kartik Vedam
Proofreaders
Simran Bhogal
Maria Gould
Ameesha Green
Paul Hindle
Indexers
Mariammal Chettiyar
Rekha Nair
Tejal Soni
Graphics
Abhinash Sahu
Production Coordinator
Komal Ramchandani
Cover Work
Komal Ramchandani
About the Author
Dr Alex Blewitt has been developing Java applications since version 1.0 was released in 1996, and has been using the Eclipse platform since its first release as part of the IBM WebSphere Studio product suite. He even migrated some plug-ins from VisualAge for Java to WebSphere Studio / Eclipse as part of his PhD in Automated Verification of Design Patterns. He got involved in the open source community as a tester when Eclipse 2.1 was being released for Mac OS X, and then subsequently as an editor for EclipseZone, including being a finalist for Eclipse Ambassador in 2007.
More recently, Alex has been writing for InfoQ, covering generic Java, specifically Eclipse and OSGi subjects. He was the keynote speaker at the OSGi Community Event 2011 on the past, present, and future of OSGi. The coverage of both new releases of the Eclipse platform as well as its projects and video interviews with some of the Eclipse project leads can be found on the InfoQ home page; for this, he won the Eclipse Top Contributor award in 2012.
Alex currently works for an investment bank in London. He also has a number of apps on the App Store through Bandlem Limited.
Alex blogs at http://alblue.bandlem.com and tweets via Twitter as @alblue regularly and is the author of Eclipse 4 Plug-in Development by Example Beginner's Guide, Packt Publishing.
Acknowledgments
I'd like to thank my wife, Amy, who has been behind me for over 15 years, supporting me during the development of this and other books. Behind every man is a great woman, and I wouldn't be where I am today if it were not for her.
I'd also like to thank my parents, Derek and Ann, for introducing me to technology at an early age with a ZX81 and setting me on a path and career that would take me across the globe, even though the name of my first company could have been better chosen.
Special thanks are due to Ann Ford, Carla Guillen, Jeff MAURY, and Peter Rice, who provided detailed feedback about every chapter and the exercises therein. Without their diligence and attention, this book would contain many more errors than I would like. Thanks are also due to the Packt Publishing editing team, especially Dennis John, who was very patient with my rewrites. I'd also like to thank Sam Wood for keeping the book on the straight and narrow as well as Susmita Panda and Binny Babu, who were involved through the production process.
During the later stages of the book, I was also fortunate enough to receive some good feedback and advice from Lars Vogel and Ian Bull, both of whom are heavily involved in the Eclipse platform. I am especially grateful for Lars Vogel's website, www.vogella.com, which has been an invaluable resource over the years.
To Sam, Holly, and all the Akeley Wood Code Clubbers, this is just the start of your journey through life. Aim high, work hard, and do what you love.
Finally, I'd like to thank OD, DJ, and JC for their support in making this book possible.
About the Reviewers
Carla Guillen has a Master's degree in Computational Science and Engineering and is working at the Leibniz Supercomputing Centre of the Bavarian Academy of Sciences and Humanities. She is currently pursuing a PhD in monitoring performance of supercomputers in the field of Computer Architecture Organization. As part of the annual courses offered at the Leibniz Supercomputing Centre, she has been teaching a course on the use of the Eclipse IDE with the CDT and Photran plug-in for the past 4 years.
Jeff MAURY is currently working as the technical lead for the Java team at SYSPERTEC, a French ISV offering mainframe integration tools. He is also a PMC member for the Apache MINA project.
Prior to SYSPERTEC, he co-founded a French ISV called SCORT in 1996, which was the precursor of the application server concept and offered J2EE-based integration tools.
He started his career in 1988 at MARBEN, a French integration company specializing in telecommunication protocols. At MARBEN, he started as a software developer and finished as an X.400 team technical lead and Internet division strategist.
I would like to dedicate my work to Jean-Pierre Ansart, my mentor, and would also like to thank my wife, Julia, for her patience and my three sons, Robinson, Paul, and Ugo.
Peter Rice is a retired professor of Mathematics and has been active in IT consulting for the past 20 years. He is a certified trainer for IBM and Microsoft, and has worked through independent training vendors offering courses in programming languages (Java, C, C++, Perl, and so on), advanced systems (Eclipse, Eclipse Plug-in Development, Rich Client Platform, and Java EE), and various other technologies. He has also been consulted with on many projects and is currently working with Trail Management Systems on the development of a new generation of business management software.
www.PacktPub.com
Support files, eBooks, discount offers, and more
You might want to visit www.PacktPub.com for support files and downloads related to your book.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
http://PacktLib.PacktPub.com
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books.
Why subscribe?
Fully searchable across every book published by Packt
Copy and paste, print and bookmark content
On demand and accessible via web browser
Free access for Packt account holders
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.
Preface
The Eclipse platform provides an extensible system for building plug-ins and applications in a modular fashion. While other books discuss the general mechanism to create plug-ins, this book dives deeper into the underlying mechanisms, including how to create plug-ins that have their own extension points and how to use OSGi services within an Eclipse application. It is expected that you are familiar with Eclipse plug-in development already and you understand the content covered in Eclipse 4 Plug-in Development by Example Beginner's Guide, Packt Publishing. By the end of this book, you will know how to write extensible plug-ins for both Eclipse extensions as well as standalone OSGi frameworks and provide end-to-end delivery of Eclipse applications with help and update sites.
What this book covers
Chapter 1, Plugging in to JFace and the Common Navigator Framework, demonstrates how to create JFace wizards and how to integrate content into the Common Navigator Framework, which is then used by Package Explorer to provide a tree view of the project's contents.
Chapter 2, Creating Custom Extension Points, shows how the Eclipse extension registry can be used to create an extensible plug-in that allows other plug-ins to contribute functionalities and how it can be used outside of an OSGi or Eclipse runtime.
Chapter 3, Using OSGi Services to Dynamically Wire Applications, introduces OSGi services as a means to extend an application's functionality. This chapter shows how these services can be configured declaratively with Declarative Services or Blueprint and how they can be configured using Config Admin along with the new changes in OSGi R6.
Chapter 4, Using the Gogo Shell and Commands, discusses how to use the Gogo shell embedded in Eclipse 4 and how to extend it by creating custom commands in Gogo script and Java.
Chapter 5, Native Code and Fragment Bundles, demonstrates how to load native code into an OSGi or Eclipse application and how fragment bundles can be used to extend the capabilities of the framework or existing OSGi bundles.
Chapter 6, Understanding ClassLoaders, goes into detail as to how the key concepts of a Java ClassLoader work and how they are used in an OSGi runtime. It also explains how non-OSGi workarounds, such as the Thread Context ClassLoader and ServiceLoader, can be used in an OSGi framework, along with presenting upgrade strategies for non-OSGi JARs.
Chapter 7, Designing Modular Applications, discusses modular design patterns such as the whiteboard pattern and extender pattern along with 18 best practices, including how to use semantic versioning and tools that can automate version number management.
Chapter 8, Event-driven Applications with EventAdmin, introduces the OSGi EventAdmin service and how E4 uses events under the covers to provide an interactive workspace, along with 7 steps for designing event-driven applications.
Chapter 9, Deploying and Updating with P2, shows how to create and manage P2 repositories (update sites) along with creating custom touchpoints and categories.
Chapter 10, User Assistance in Eclipse, demonstrates how to write help documentation for an Eclipse- or RCP-based product along with cheat sheets and running a public facing help server.
What you need for this book
To run the exercises in this book, you will need a computer with an up-to-date operating system (running Windows, Linux, or Mac OS X). Java also needs to be installed; the book's exercises were tested against JDK 1.7, but newer versions of Java should also work. The exercises were written and tested against both Eclipse Standard 4.4 (Luna) as well as 4.3 (Kepler). The principles should work for future versions of Eclipse as well, but note that each release of Eclipse has a migration guide in the Platform Plug-in Developer Guide help topic that will list any incompatibilities. This help information is also available online at http://help.eclipse.org/ for the current release.
The exercises are available on the Packt website as well as on GitHub at https://github.com/alblue/com.packtpub.e4.advanced/. Using the GitHub code will require a Git installation such as EGit for Eclipse (available from the Eclipse Marketplace) or a standalone Git client from http://git-scm.com/.
Who this book is for
This book is aimed at existing Eclipse plug-in developers who know the basics of plug-in development but want to learn some of the techniques in greater detail.
Developers wishing to write extensible plug-ins will find the advice in chapters 1 and 2 useful to integrate with some parts of the Eclipse framework that they may not have previously used.
Those that are unfamiliar with OSGi services or don't know how to integrate into Eclipse will find chapter 3 a good introduction, which is usually not covered in other Eclipse plug-in development books. Those wishing to extend the Gogo shell will find the information in chapter 4 beneficial, and chapter 5 will benefit those who need help in including native code dependencies. Developers who need to include non-OSGi JARs will find the techniques discussed in chapter 6 to be useful.
For those who are looking for advice on how to structure modular applications, the practices in chapters 7 and 8 will be beneficial.
Finally, for developers responsible for providing products, chapters 9 and 10 show how to customize and publish P2 repositories as well as provide user assistance (help) for applications.
Conventions
In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: A cursor need to be closed to free the resource the object holds by calling the close() method.
A block of code is set as follows:
public void deleted(String pid) {
System.out.println(Removing echo server with pid
+ pid);
EchoServer removed = echoServers.remove(pid);
if (removed != null) {
removed.stop();
}
}
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
Any command-line input or output is written as follows:
$ mvn install $ mvn versions:set -DnewVersion=1.0.1 ... make changes to Java files ... $ mvn package
New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: Clicking on Reset (to scan the directory) followed by Finish will set up the baseline.
Note
Warnings or important notes appear in a box like this.
Tip
Tips and tricks appear like this.
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.
To send us general feedback, simply send an e-mail to <feedback@packtpub.com>, and mention the book title via the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
Downloading the example code
You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you. Alternatively, the code is available on GitHub at the book's repository https://github.com/alblue/com.packtpub.e4.advanced/.
Errata
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.
Piracy
Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <copyright@packtpub.com> with a link to the suspected pirated material.
We appreciate your help in protecting our authors, and our ability to bring you valuable content.
Questions
You can contact us at <questions@packtpub.com> if you are having a problem with any aspect of the book, and we will do our best to address it.
Chapter 1. Plugging in to JFace and the Common Navigator Framework
JFace is the set of widgets that comprise the Eclipse user interface, and it builds on top of the Standard Widget Toolkit (SWT). JFace also provides a number of standard higher-level tools that can provide interaction with users, such as wizards and standard navigator plug-ins.
In this chapter, we will create a news feed reader using a JFace wizard, and then we will contribute it to the common navigator so that it shows up in views such as the Package Explorer view.
JFace wizards
Whenever a new project or file is created in Eclipse, the standard JFace wizard is used. For example, the following screenshots show the wizards to create a new Plug-in Project or Java Class:
A JFace wizard has a common section at the top and bottom of the dialog, which provides the title/icon and transition buttons along with an optional help link. Each wizard consists of one or more linked pages that define the visible content area and the button bar. The window title is shared across all pages; the page title and page message allow information to be shown at the top. The page adds per-page content into the content area by exposing a page control. The wizard can be displayed with a wizard dialog or by integrating with the workbench functionality, such as the newWizards extension point. The following diagram illustrates this:
Creating a feeds wizard
A wizard is created as a subclass of Wizard or another class that implements the IWizard interface. Create a new plug-in project called com.packtpub.e4.advanced.feeds.ui and ensure that the Generate an activator and This plug-in will make contributions to the UI options are selected. Click on Finish to accept the defaults.
Creating the classes
Create a new class called com.packtpub.e4.advanced.feeds.ui.NewFeedWizard that extends org.eclipse.jface.wizard.Wizard. This creates a skeleton file with a performFinish method.
To add content, one or more pages must be created. A page is a subclass of WizardPage or another class that implements the IWizardPage interface. Pages are typically added within the constructor or addPages methods of the owning wizard.
Create a new class called com.packtpub.e4.advanced.feeds.ui.NewFeedPage that extends org.eclipse.jface.wizard.WizardPage. The default implementation will be missing a constructor; create a default constructor that passes the string NewFeedPage
to the superclass' constructor.
The code should now look like the following code snippet:
package com.packtpub.e4.advanced.feeds.ui;
import org.eclipse.jface.wizard.Wizard;
public class NewFeedWizard extends Wizard {
public boolean performFinish()