Book Image

Eclipse 4 Plug-in Development by Example : Beginner's Guide

By : Dr Alex Blewitt
Book Image

Eclipse 4 Plug-in Development by Example : Beginner's Guide

By: Dr Alex Blewitt

Overview of this book

<p>As a highly extensible platform, Eclipse is used by everyone from independent software developers to NASA. Key to this is Eclipse’s plug-in ecosystem, which allows applications to be developed in a modular architecture and extended through its use of plug-ins and features.<br /><br />"Eclipse 4 Plug-in Development by Example Beginner's Guide" takes the reader through the full journey of plug-in development, starting with an introduction to Eclipse plug-ins, continued through packaging and culminating in automated testing and deployment. The example code provides simple snippets which can be developed and extended to get you going quickly.</p> <p>This book covers basics of plug-in development, creating user interfaces with both SWT and JFace, and interacting with the user and execution of long-running tasks in the background.</p> <p>Example-based tasks such as creating and working with preferences and advanced tasks such as well as working with Eclipse’s files and resources. A specific chapter on the differences between Eclipse 3.x and Eclipse 4.x presents a detailed view of the changes needed by applications and plug-ins upgrading to the new model. Finally, the book concludes on how to package plug-ins into update sites, and build and test them automatically.</p>
Table of Contents (19 chapters)
Eclipse 4 Plug-in Development by Example Beginner's Guide
Credits
About the Author
Acknowledgement
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

This book provides a general introduction to developing plug-ins for the Eclipse platform. No prior experience, other than Java, is necessary to be able to follow the examples presented in this book. By the end of the book, you should be able to create an Eclipse plug-in from scratch, as well as be able to create an automated build of those plug-ins.

What this book covers

Chapter 1, Creating Your First Plug-in, provides an overview of how to download Eclipse, set it up for plug-in development, create a sample plug-in, launch, and debug it.

Chapter 2, Creating Views with SWT, provides an overview of how to build views with SWT, along with other custom SWT components such as system trays and resource management.

Chapter 3, Creating JFace Viewers, discusses creating views with JFace using TableViewers and TreeViewers, along with integration with the properties view and user interaction.

Chapter 4, Interacting with the User, discusses using commands, handlers, and menus to interact with the user, as well as the Jobs and Progress APIs.

Chapter 5, Storing Preferences and Settings, tells how to store preference information persistently, as well as displaying it via the preferences pages.

Chapter 6, Working with Resources, teaches how to load and create Resources in the workbench, as well as how to create a builder and nature for automated processing.

Chapter 7, Understanding the Eclipse 4 Model, discusses the key differences between the Eclipse 3.x and Eclipse 4.x models, as well as how to migrate existing content to the new model.

Chapter 8, Creating Features, Update Sites, Applications, and Products, tells how to take the plug-ins created so far in this book, aggregate them into features, publish to update sites, and how applications and products are used to create standalone entities.

Chapter 9, Automated Testing of Plug-ins, teaches how to write automated tests that exercise Eclipse plug-ins, including both UI and non-UI components.

Chapter 10, Automated builds with Tycho, details how to build Eclipse plug-ins, features, update sites, applications, and products automatically with Maven Tycho.

What you need for this book

To run the exercises for 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; JDK 1.7 is the current released version although the instructions should work for a newer version of Java as well.

This book has been tested with the Eclipse SDK (Classic/Standard) for Juno (4.2) and Kepler (4.3). Newer versions of Eclipse may also work. Care should be taken while installing Eclipse for RCP and RAP developers, as this will cause the applications created in Chapter 7, Understanding the Eclipse 4 Model and Chapter 8, Creating Features, Update Sites, Applications, and Products.

The first chapter explains how to get started with Eclipse, including how to obtain and install both Eclipse and Java.

Who this book is for

This book is aimed at Java developers who are interested in learning how to create plug-ins, products, and applications for the Eclipse platform. The book starts with how to install and use Eclipse to build and debug plug-ins, covers different types of user interfaces, and finishes with how to create update sites and build and test plug-ins automatically.

This book will also be useful to those who already have some experience in building Eclipse plug-ins and want to know how to create automated builds using Maven Tycho, which has become the de-facto standard for building Eclipse plug-ins.

Finally, those Eclipse developers who are familiar with the Eclipse 3.x model but are interested in learning about the changes that the Eclipse 4.x model brings will find the information presented in Chapter 7, Understanding the Eclipse 4 Model a useful summary of what opportunities the new model provides.

Note

E4: In this book, both the Eclipse 3.x and Eclipse 4.x models are covered. The Eclipse 4 platform contains a backwards-compatible runtime for the Eclipse 3.x APIs. Where the Eclipse 3.x APIs differ from the Eclipse 4.x APIs, the icon E4 will be used to call out a difference. A full explanation of the Eclipse 4 concepts will be covered in Chapter 7, Understanding the Eclipse 4 Model; so the E4 notes can be skipped on the first reading if necessary.

If you are developing an Eclipse IDE-based plug-in, you should consider using the Eclipse 3.x APIs, as these will work in both older Eclipse instances, as well as newer ones. If you are developing an Eclipse RCP-based application and do not need to support older versions, consider building an Eclipse 4-based application. Future versions of the Eclipse platform (4.4/Luna and afterwards) will make it possible to use some of the Eclipse 4 APIs in the IDE.

Conventions

In this book, you will find several headings appear frequently.

To give clear instructions of how to complete a procedure or task, we use:

Time for action – heading

  1. Action 1

  2. Action 2

  3. Action 3

Instructions often need some extra explanation so that they make sense, so they are followed with:

What just happened?

This heading explains the working of tasks or instructions that you have just completed.

You will also find some other learning aids in the book, including:

Pop quiz – heading

These are short multiple-choice questions intended to help you test your own understanding.

Have a go hero – heading

These practical challenges give you ideas for experimenting with what you have learned.

You will also 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 are shown as follows: "You may notice that we used the Unix command rm to remove the Drush directory rather than the DOS del command."

A block of code is set as follows:

# * Fine Tuning
#
key_buffer = 16M
key_buffer_size = 32M
max_allowed_packet = 16M
thread_stack = 512K
thread_cache_size = 8
max_connections = 300

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

# * Fine Tuning
#
key_buffer = 16M
key_buffer_size = 32M
max_allowed_packet = 16M
thread_stack = 512K
thread_cache_size = 8
max_connections = 300

Any command-line input or output is written as follows:

cd /ProgramData/Propeople
rm -r Drush
git clone --branch master http://git.drupal.org/project/drush.git

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: "On the Select Destination Location screen, click on Next to accept the default destination".

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 , and mention the book title through 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.

The code samples from this book are also available from the GitHub repository at http://github.com/alblue/com.packtpub.e4. There are ten branches, each corresponding to the state of the book's examples at the end of each chapter.

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 to our website, or added to any list of existing errata, under the Errata section of that title.

See also the book's GitHub repository at http://github.com/alblue/com.packtpub.e4. If any code samples need to be updated, they will be updated there.

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 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 com if you are having a problem with any aspect of the book, and we will do our best to address it.