Eclipse Plug-in Development: Beginner's Guide - Second Edition - Dr Alex Blewitt - E-Book

Eclipse Plug-in Development: Beginner's Guide - Second Edition E-Book

Dr Alex Blewitt

0,0
41,99 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

Develop skills to build powerful plug-ins with Eclipse IDE through examples

About This Book

  • Create useful plug-ins to make Eclipse work for you
  • Learn how to migrate Eclipse 3.x plug-ins to Eclipse 4.x
  • From automation to testing, find out how to get your IDE performing at an impressive standard

Who This Book Is For

This book is for Java developers familiar with Eclipse who need more from the IDE. This book will sharpen your confidence and make you a more productive developer with a tool that supports rather than limits you.

What You Will Learn

  • Create plug-ins for Eclipse 4.x
  • Test plug-ins automatically with JUnit
  • Display tree and table information in views
  • Upgrade Eclipse 3.x plug-ins to Eclipse 4.x
  • Find out how to build user interfaces from SWT and JFace
  • Run tasks in the background and update the user interface asynchronously
  • Automate builds of plug-ins and features
  • Automate user interface tests with SWTBot

In Detail

Eclipse is used by everyone from indie devs to NASA engineers. Its popularity is underpinned by its impressive plug-in ecosystem, which allows it to be extended to meet the needs of whoever is using it. This book shows you how to take full advantage of the Eclipse IDE by building your own useful plug-ins from start to finish.

Taking you through the complete process of plug-in development, from packaging to automated testing and deployment, this book is a direct route to quicker, cleaner Java development. It may be for beginners, but we're confident that you'll develop new skills quickly. Pretty soon you'll feel like an expert, in complete control of your IDE.

Don't let Eclipse define you - extend it with the plug-ins you need today for smarter, happier, and more effective development.

Style and approach

Packed with plenty of examples so you're never stuck, or never left simply reading instructions, this book encourages you to get started immediately. This book is for developers who want to develop, not just learn.

Sie lesen das E-Book in den Legimi-Apps auf:

Android
iOS
von Legimi
zertifizierten E-Readern

Seitenzahl: 533

Veröffentlichungsjahr: 2016

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

Eclipse Plug-in Development Beginner's Guide Second Edition
Credits
Foreword
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
eBooks, discount offers, and more
Why subscribe?
Preface
What this book covers
What you need for this book
Who this book is for
Sections
Time for action – heading
What just happened?
Pop quiz – heading
Have a go hero – heading
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Creating Your First Plug-in
Getting started
Time for action – setting up the Eclipse environment
What just happened?
Creating your first plug-in
Time for action – creating a plug-in
What just happened?
Pop quiz – Eclipse workspaces and plug-ins
Running plug-ins
Time for action – launching Eclipse from within Eclipse
What just happened?
Pop quiz: launching Eclipse
Have a go hero – modifying the plug-in
Debugging a plug-in
Time for action – debugging a plug-in
What just happened?
Time for action – updating code in the debugger
What just happened?
Debugging with step filters
Time for action – setting up step filtering
What just happened?
Using different breakpoint types
Time for action – breaking at method entry and exit
What just happened?
Using conditional breakpoints
Time for action – setting a conditional breakpoint
What just happened?
Using exceptional breakpoints
Time for action – catching exceptions
What just happened?
Time for action – inspecting and watching variables
What just happened?
Pop quiz: debugging
Have a go hero – working with breakpoints
Summary
2. Creating Views with SWT
Creating views and widgets
Time for action – creating a view
What just happened?
Manifest.mf
plugin.xml
Time for action – drawing a custom view
What just happened?
Time for action – drawing a seconds hand
What just happened?
Time for action – animating the second hand
What just happened?
Time for action – running on the UI thread
What just happened?
Time for action – creating a reusable widget
What just happened?
Time for action – using layouts
What just happened?
Pop quiz: understanding views
Have a go hero – drawing hour and minute hands
Managing resources
Time for action – getting colorful
What just happened?
Time for action – finding the leak
What just happened?
Time for action – plugging the leak
What just happened?
Pop quiz – understanding resources
Have a go hero
Interacting with the user
Time for action – getting in focus
What just happened?
Time for action – responding to input
What just happened?
Pop quiz: understanding widgets
Have a go hero – updating the clock widget
Using other SWT widgets
Time for action – adding items to the tray
What just happened?
Time for action – responding to the user
What just happened?
Time for action – modal and other effects
What just happened?
Time for action – groups and tab folders
What just happened?
Pop quiz: using SWT
Have a go hero: enhancing the time zones
Summary
3. Creating JFace Viewers
Why JFace?
Creating TreeViewers
Time for action – creating a tree viewer
What just happened?
Time for action – using Images in JFace
What just happened?
Time for action – styling label providers
What just happened?
Pop quiz – understanding JFace
Have a go hero – adding images for regions
Sorting and filtering
Time for action – sorting items in a viewer
What just happened?
Time for action – filtering items in a viewer
What just happened?
Pop quiz – understanding sorting and filters
Have a go hero – expanding and filtering
Interaction
Time for action – adding a double-click listener
What just happened?
Pop quiz – understanding interaction
Tabular data
Time for action – viewing time zones in tables
What just happened?
Pop quiz: understanding tables
Selection
Time for action – propagating selection
What just happened?
Time for action – responding to selection changes
What just happened?
Have a go hero – adding selection support to the table view
Pop quiz – understanding selection
Summary
4. Interacting with the User
Creating menus, commands, and handlers
Time for action – installing the E4 tools
What just happened?
Time for action – creating commands and handlers
What just happened?
Time for action – binding commands to keys
What just happened?
Time for action – changing contexts
What just happened?
Time for action – enabling and disabling menus items
What just happened?
Time for action – contributing commands to pop-up menus
What just happened?
Have a go hero – using view menus and toolbars
Pop quiz – understanding menus
Jobs and progress
Time for action – running operations in the background
What just happened?
Have a go hero – using a UIJob
Time for action – reporting progress
What just happened?
Time for action – dealing with cancellation
What just happened?
Time for action – using subtasks and sub-progress monitors
What just happened?
Time for action – using null progress monitors and sub monitors
What just happened?
Time for action – setting job properties
What just happened?
Have a go hero – displaying in the taskbar
Pop quiz – understanding Jobs
Reporting errors
Time for action – showing errors
What just happened?
Pop quiz – understanding errors
Summary
5. Working with Preferences
Eclipse Preferences
Time for action – persisting a value
What just happened?
Time for action – injecting preferences
What just happened?
Time for action – injecting individual preferences
What just happened?
Time for action – responding to preference changes
What just happened?
Preference pages
Time for action – creating a preference page
What just happened?
Time for action – creating warning and error messages
What just happened?
Time for action: choosing from a list
What just happened?
Time for action – aligning field editors with a grid
What just happened?
Time for action – placing the preferences page
What just happened?
Time for action: using other field editors
What just happened?
Time for action – searching for preferences
What just happened?
Have a go hero – translating into different languages
Pop quiz – understanding preferences
Summary
6. Working with Resources
Using the workspace and resources
Time for action – creating an editor
What just happened?
Time for action – writing the markup parser
What just happened?
Time for action – building the builder
What just happened?
Time for action – iterating through resources
What just happened?
Time for action – creating resources
What just happened?
Time for action – implementing incremental builds
What just happened?
Time for action: handling deletion
What just happened?
Have a go hero – builder upgrades
Using natures
Time for action – creating a nature
What just happened?
Have a go hero – enable for selected object type
Using markers
Time for action – error markers if file is empty
What just happened?
Time for action – registering a marker type
What just happened?
Have a go hero – work out when the file is really empty
Pop quiz – understanding resources, builders, and markers
Summary
7. Creating Eclipse 4 Applications
Time for action – installing E4 tooling
What just happened?
Time for action – creating an E4 application
What just happened?
Time for action – creating a part
What just happened?
Using services and contexts
Time for action – adding logging
What just happened?
Time for action – getting the window
What just happened?
Time for action – obtaining the selection
What just happened?
Time for action – dealing with events
What just happened?
Time for action – calculating values on demand
What just happened?
Time for action – interacting with the UI
What just happened?
Using commands, handlers, and menu items
Time for action – wiring a menu to a command with a handler
What just happened?
Time for action: passing command parameters
What just happened?
Time for action – creating a direct menu and keybindings
What just happened?
Time for action – creating a pop-up menu and a view menu
What just happened?
Creating custom injectable classes
Time for action – creating a simple service
What just happened?
Time for action – injecting subtypes
What just happened?
Have a go hero – using the tools bridge
Pop quiz – understanding E4
Summary
8. Migrating to Eclipse 4.x
Why Eclipse 4.x?
Time for action – creating a migration component
What just happened?
Time for action – updating to e4view
What just happened?
Time for action – upgrading the actions
What just happened?
Time for action – creating toolbars
What just happened?
Have a go hero – optimising the handler lookup
Time for action – adding the view menu
What just happened?
Time for action – adding the pop-up
What just happened?
Migrating to Eclipse 4.x patterns
Time for action – creating a model fragment
What just happened?
Time for action – migrating the commands and handlers
What just happened?
Time for action – creating the view menu
What just happened?
Time for action – defining the pop-up view in the fragment
What just happened?
Have a go hero – invoking the handler from the hookDoubleClick action
Pop quiz
Summary
9. Styling Eclipse 4 Applications
Styling Eclipse with CSS
Time for action – styling the UI with CSS
What just happened?
Have a go hero – experiment with other CSS properties
Time for action – using custom CSS classes
What just happened?
Using the Eclipse spies
Time for action – using the CSS Spy
What just happened?
Time for action – integrating the spy into a product
What just happened?
Styling a custom widget
Time for action – adding the clock
What just happened?
Time for action – using a CSS property
What just happened?
Themes
Time for action – going to the dark side
What just happened?
Time for action – adding themes
What just happened?
Time for action – switching between themes
What just happened?
Have a go hero
Pop quiz – styling Eclipse 4
Summary
10. Creating Features, Update Sites, Applications, and Products
Grouping plug-ins with features
Time for action – creating a feature
What just happened?
Time for action – exporting a feature
What just happened?
Time for action – installing a feature
What just happened?
Time for action – categorizing the update site
What just happened?
Time for action – depending on other features
What just happened?
Time for action – branding features
What just happened?
Have a go hero – publishing the content remotely
Building applications and products
Time for action – creating a headless application
What just happened?
Time for action – creating a product
What just happened?
Have a go hero – creating a product based on features
Target platforms
Time for action – creating a target definition
What just happened?
Time for action – switching to a specific version
What just happened?
Have a go hero – configuring target platforms for other releases
Pop quiz – understanding features, applications, and products
Summary
11. Automated Testing of Plug-ins
Using JUnit for automated testing
Time for action – adding dependencies to the target platform
What just happened?
Time for action – writing a simple JUnit 4 test case
What just happened?
Time for action – writing a plug-in test
What just happened?
Using SWTBot for user interface testing
Time for action – writing an SWTBot test
What just happened?
Time for action – working with menus
What just happened?
Have a go hero – using resources
Working with SWTBot
Time for action – hiding the welcome screen
What just happened?
Time for action – avoiding SWTBot runtime errors
What just happened?
Working with views
Time for action: showing views
What just happened?
Time for action – interrogating views
What just happened?
Interacting with the UI
Time for action – getting values from the UI
What just happened?
Time for action – waiting for a condition
What just happened?
Have a go hero – driving the new class wizard
Pop quiz – understanding swtbot
Summary
12. Automated Builds with Tycho
Using Maven to build Eclipse plug-ins with Tycho
Time for action – installing Maven
What just happened?
Time for action – building with Tycho
What just happened?
Building features and update sites with Tycho
Time for action – creating a parent project
What just happened?
Time for action – building a feature
What just happened?
Time for action – building an update site
What just happened?
Time for action – building a product
What just happened?
Time for action – using the target platform
What just happened?
Have a go hero – depending on Maven components
Testing and releasing
Time for action – running automated tests
What just happened?
Time for action – changing the version numbers
What just happened?
Have a go hero – enabling builds for other plug-ins
Signing update sites
Time for action – creating a self-signed certificate
What just happened?
Time for action – signing the plug-ins
What just happened?
Time for action – serving an update site
What just happened?
Pop quiz – understanding automated builds and update sites
Summary
13. Contributing to Eclipse
Open source contributions
Importing the source
Time for action – installing the sources
What just happened?
Time for action – debugging the platform
What just happened?
Time for action – modifying the platform
What just happened?
Checking out from Git
Time for action – checking out from EGit and Git
What just happened?
Time for action – configuring the SWT project
What just happened?
Contributing to Eclipse
Creating bugs on Bugzilla
Time for action – creating an account at Eclipse
What just happened?
Time for action – creating a bug
What just happened?
Have a go hero
Submitting fixes
Time for action – setting up a Gerrit profile
What just happened?
Time for action – committing and pushing a patch
What just happened?
Have a go hero
Summary
A. Using OSGi Services to Dynamically Wire Applications
Services overview
Registering a service programmatically
Creating an activator
Registering a 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
Dynamic services
Resolving services each time
Using a ServiceTracker
Filtering services
Obtaining a BundleContext without using an activator
Dependent Services
Dynamic service configuration
Installing Felix FileInstall
Installing ConfigAdmin
Configuring Declarative Services
Service factories
Creating the EchoService
Creating an EchoServiceFactory
Configuring the EchoServices
Summary
B. Pop Quiz Answers
Chapter 1 – Creating Your First Plug-in
Eclipse workspaces and plug-ins
Launching Eclipse
Debugging
Chapter 2 – Creating Views with SWT
Understanding views
Understanding resources
Understanding widgets
Using SWT
Chapter 3 – Creating JFace Viewers
Understanding JFace
Understanding sorting and filters
Understanding interaction
Understanding tables
Understanding selection
Chapter 4 – Interacting with the User
Understanding menus
Understanding jobs
Understanding errors
Chapter 5 – Storing Preferences and Settings
Understanding preferences
Chapter 6 – Working with Resources
Understanding resources, builders, and markers
Chapter 7 – Creating Eclipse 4 Applications
Understanding E4
Chapter 8 – Migrating to Eclipse 4.x
Chapter 9 – Styling Eclipse 4 Applications
Styling Eclipse 4
Chapter 10 – Creating Features, Update Sites, Applications, and Products
Understanding features, applications, and products
Chapter 11 – Automated Testing of Plug-ins
Understanding swtbot
Chapter 12 – Automated Builds with Tycho
Understanding automated builds and update sites
Index

Eclipse Plug-in Development Beginner's Guide Second Edition

Eclipse Plug-in Development Beginner's Guide Second Edition

Copyright © 2016 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 edition: June 2013

Second published: July 2016

Production reference: 1280716

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham B3 2PB, UK.

ISBN 978-1-78398-069-7

www.packtpub.com

Credits

Author

Dr Alex Blewitt

Reviewers

Carla Guillen

Tom Seidel

Commissioning Editor

Kartikey Pandey

Acquisition Editor

Denim Pinto

Content Development Editor

Deepti Thore

Technical Editor

Vivek Arora

Copy Editor

Vikrant Phadke

Project Coordinator

Shweta H Birwatkar

Proofreader

Safis Editing

Indexer

Hemangini Bari

Graphics

Disha Haria

Production Coordinator

Aparna Bhagat

Cover Work

Aparna Bhagat

Foreword

The Eclipse platform is one of the world's most successful open source software projects. Millions of developers use Eclipse every day as their development tools. Millions of people use applications built on top of the Eclipse Rich Client Platform every day. The Eclipse community has hundreds of dedicated committers and thousands of contributors. Speaking on their behalf, I thank you for your interest in Eclipse, and wish you great success building your project with our free software platform. This book will provide you with an excellent introduction to the key aspects of the Eclipse platform, including the plug-in model, SWT, JFace, user interactions, and resources.

The success of the Eclipse platform has been based to a very large extent on its extensibility. Originally conceived as a platform for building integrated development environments, Eclipse quickly evolved into a platform for building portable desktop applications as well. For over a decade, the Eclipse Rich Client Platform has been one of the leading technologies for creating compelling user interfaces for business applications. The major refresh of the Eclipse application platform that came in 2012 with the launch of Eclipse 4 has seen even further adoption. The chapters on Eclipse 4 and styling your user interface do an excellent job of portraying those new features.

Eclipse projects are driven by great developers, and the Eclipse 4 project has had many important contributors. I would like to recognize the contributions of just a few: the present Eclipse platform leader Mike Wilson (IBM), and project leaders Dani Megert (IBM) and Lars Vogel (vogella), and past leaders John Arthorne (formerly IBM, now Shopify), and Boris Bokowski (formerly IBM, now Google). I would also like to recognize the special contributions to Eclipse 4 of Brian de Alwis, Oleg Besedin, Danail Branekov, Eric Moffatt, Bogdan Gheorghe, Paul Webster, Thomas Schindl, Remy Suen, Kai Tödter, and Lars Vogel.

As an open source product, Eclipse owes its success to the contributions of many people. I highly encourage everyone to follow the chapter on contributing to the Eclipse platform. The Eclipse community is a worldwide phenomenon, and we would love to welcome your contributions.

Alex Blewitt has been actively involved in the Eclipse community for many years. His knowledge of both the Eclipse platform and plug-in development is second to none. He has written an in-depth and fun-to-read introduction to plug-in development that I am sure will help many to build, test, deploy, and update their Eclipse-based products or applications. I am sure that you will find it to be an excellent addition to your Eclipse library.

Mike Milinkovich

Executive Director of the Eclipse Foundation

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 got involved in the open source community as a tester when Eclipse 2.1 was being released for macOS, 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 Java and specifically Eclipse and OSGi subjects.

He is co-founder of the Docklands.LJC, a regional branch of the London Java Community in the Docklands, and a regular speaker at conferences.

Alex currently works for an investment bank in London, and is a Director of Bandlem Limited. Alex blogs at https://alblue.bandlem.com and tweets as @alblue on Twitter, and is the author of both Mastering Eclipse 4 Plug-in Development, and Swift Essentials, both by Packt Publishing.

Acknowledgments

I'd like to thank my wife Amy who has been behind me for over fifteen 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 a career that would take me across the globe, even if my first company's name 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 for the first edition, and to Tom Seidel and Roberto Lo Giacco for the second edition. Without their diligence and attention, this book would contain many more errors than I would like. Thanks are also due to the Packt editing team, Kajal Thapar, Preeti Singh and Mohita Vyas for making this possible.

During the latter stages of the first edition 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' website at www.vogella.com which has been an invaluable resource.

Thanks to Scott James, David Jones and Charles Humble for all the help you have given me over the years. Thanks also to my Docklands.LJC co-founder Robert Barr who tweets from @DocklandsLJC.

Finally, congratulations to both Sam and Holly on all your achievements in music, maths and school. Keep up the good work!

About the Reviewers

Carla Guillen, PhD, works at the Leibniz Supercomputing Centre of the Bavarian Academy of Sciences in the field of performance and energy optimization of supercomputers. 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 4 years. Additionally, she reviewed a book on advanced Eclipse plug-in development in 2014.

Tom Seidel works as an independent software engineer with focus on projects using Eclipse technology. He has worked for over a decade with the Eclipse technology stack in many projects and nearly every industry. Furthermore, he is an Eclipse committer and an active member of the Eclipse community.

www.PacktPub.com

eBooks, discount offers, and more

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 <[email protected]> for more details.

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.

https://www2.packtpub.com/books/subscription/packtlib

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.

Why subscribe?

Fully searchable across every book published by PacktCopy and paste, print, and bookmark contentOn demand and accessible via a web browser

This book is dedicated in memory of Anne Tongs (née Blewitt)

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, will show how to create views with JFace using TreeViewers and TableViewers, along with integration with the properties view and user interaction.

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

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

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

Chapter 7, Creating Eclipse 4 Applications, discusses the key differences between the Eclipse 3.x and Eclipse 4.x models, along with commands, handlers and menu items.

Chapter 8, Migrating to Eclipse 4.x, teaches how to efficiently migrate views created for Eclipse 3.x to the new Eclipse 4.x model.

Chapter 9, Styling Eclipse 4 Applications, discusses how to style the UI with CSS, and create widgets that can adjust to CSS styles.

Chapter 10, Creating Features, Update Sites, Applications, and Products, takes the plug-ins created so far in this book, aggregates them into features, publishes to update sites, and teaches you how applications and products are used to create standalone entities.

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

Chapter 12, Automated Builds with Tycho, shows how to build Eclipse plug-ins, features, update sites, applications, and products automatically with Maven Tycho.

Chapter 13, Contributing to Eclipse, discusses how to use Git to check out Eclipse code bases, how to report bugs with Bugzilla, and how to upload patches into Gerrit.

Appendix A, Using OSGi Services to Dynamically Wire Applications, looks at OSGi services as an alternative means of providing dependent services in an Eclipse or OSGi application.

Appendix B, Pop Quiz Answers, covers all the answers enlisted in the pop quiz sections in the book.

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.8 is the current released version although the instructions should work for a newer version of Java.

This book has been tested with the Eclipse SDK (Classic/Standard) for Mars (4.5) and Neon (4.6). Newer versions of Eclipse may also work. Care should be taken to not install the Eclipse for RCP and RAP developers, as this will cause the applications created in Chapter 7, Understanding the Eclipse 4 Model and RCP Applications and Chapter 8, Migrating Views to the Eclipse 4 Model.

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.

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 8 a useful summary of what opportunities the new model provides.

Sections

In this book, you will find several headings that appear frequently (Time for action, What just happened?, Pop quiz, and Have a go hero).

To give clear instructions on how to complete a procedure or task, we use these sections as follows:

Time for action – heading

Action 1Action 2Action 3

Instructions often need some extra explanation to ensure they make sense, so they are followed with these sections:

What just happened?

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

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

Pop quiz – heading

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

Have a go hero – heading

These are practical challenges that give you ideas to experiment with what you have learned.

Conventions

You will also find a number of text styles 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: "Running java -version should give output like this."

A block of code is set as follows:

public class Utility { public static boolean breakpoint() { System.out.println("Breakpoint"); return false; } }

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

java version "1.8.0_92"Java(TM) SE Runtime Environment (build 1.8.0_92-b14)Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)

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: "Choose a workspace, which is the location in which projects are to be stored, and click on OK:"

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 disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail <[email protected]>, and mention the book's title in 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 at 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 this book 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.

You can download the code files by following these steps:

Log in or register to our website using your e-mail address and password.Hover the mouse pointer on the SUPPORT tab at the top.Click on Code Downloads & Errata.Enter the name of the book in the Search box.Select the book for which you're looking to download the code files.Choose from the drop-down menu where you purchased this book from.Click on Code Download.

You can also download the code files by clicking on the Code Files button on the book's webpage at the Packt Publishing website. This page can be accessed by entering the book's name in the Search box. Please note that you need to be logged in to your Packt account.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

WinRAR / 7-Zip for WindowsZipeg / iZip / UnRarX for Mac7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/alblue/com.packtpub.e4. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from http://www.packtpub.com/sites/default/files/downloads/EclipsePluginDevelopmentBeginnersGuideSecondEdition_ColorImages.pdf.

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 could 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.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted 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 <[email protected]> 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

If you have a problem with any aspect of this book, you can contact us at <[email protected]>, and we will do our best to address the problem.

Chapter 1. Creating Your First Plug-in

Eclipse – an IDE for everything and nothing in particular.

Eclipse is a highly modular application consisting of hundreds of plug-ins, and can be extended by installing additional plug-ins. Plug-ins are developed and debugged with the Plug-in Development Environment (PDE).

In this chapter we will:

Set up an Eclipse environment for doing plug-in developmentCreate a plug-in with the new plug-in wizardLaunch a new Eclipse instance with the plug-in enabledDebug the Eclipse plug-in

Getting started

Developing plug-ins requires an Eclipse development environment. This book has been developed and tested on Eclipse Mars 4.5 and Eclipse Neon 4.6, which was released in June 2016. Use the most recent version available.

Eclipse plug-ins are generally written in Java. Although it's possible to use other JVM-based languages (such as Groovy or Scala), this book will use the Java language.

There are several different packages of Eclipse available from the downloads page, each of which contains a different combination of plug-ins. This book has been tested with:

Eclipse SDK from http://download.eclipse.org/eclipse/downloads/Eclipse IDE for Eclipse Committers from http://www.eclipse.org/downloads/

These contain the necessary Plug-in Development Environment (PDE) feature as well as source code, help documentation, and other useful features. The RCP and RAP package should not be used as it will cause problems with exercises in Chapter 7, Understanding the Eclipse 4 Model and RCP Applications.

It is also possible to install the Eclipse PDE feature in an existing Eclipse instance. To do this, go to the Help menu and select Install New Software, followed by choosing the General Purpose Tools category from the selected update site. The Eclipse PDE feature contains everything needed to create a new plug-in.

Time for action – setting up the Eclipse environment

Eclipse is a Java-based application; it needs Java installed. Eclipse is distributed as a compressed archive and doesn't require an explicit installation step.

To obtain Java, go to http://java.com and follow the instructions to download and install Java.

Tip

Note that Java comes in two flavors: a 32-bit installation and a 64-bit installation. If the running OS is 32-bit, then install the 32-bit JDK; alternatively, if the running OS is 64-bit, then install the 64-bit JDK.

Running java -version should give output like this:
java version "1.8.0_92"Java(TM) SE Runtime Environment (build 1.8.0_92-b14)Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
Go to http://www.eclipse.org/downloads/ and select the Eclipse IDE for Eclipse Committers distribution.Download the one that matches the installed JDK. Running java -version should report either of these:
If it's a 32-bit JDK:
Java HotSpot(TM) Client VM
If it's a 64-bit JDK:
Java HotSpot(TM) 64-Bit Server VM

Note

On Linux, Eclipse requires GTK+ 2 or 3 to be installed. Most Linux distributions have a window manager based on GNOME, which provides GTK+ 2 or 3.

To install Eclipse, download and extract the contents to a suitable location. Eclipse is shipped as an archive, and needs no administrator privileges to install. Do not run it from a networked drive as this will cause performance problems.Note that Eclipse needs to write to the folder where it is extracted, so it's normal that the contents are writable afterwards. Generally, installing in /Applications or C:\Program Files as an administrator account is not recommended.Run Eclipse by double-clicking on the Eclipse icon, or by running eclipse.exe (Windows), eclipse (Linux), or Eclipse.app (macOS).On startup, the splash screen will be shown:Choose a workspace, which is the location in which projects are to be stored, and click on OK:Close the welcome screen by clicking on the cross in the tab next to the welcome text. The welcome screen can be reopened by navigating to Help | Welcome:

What just happened?

Eclipse needs Java to run, and so the first step involved in installing Eclipse is ensuring that an up-to-date Java installation is available. By default, Eclipse will find a copy of Java installed on the path or from one of the standard locations. It is also possible to specify a different Java by using the -vm command-line argument.

If the splash screen doesn't show, then the Eclipse version may be incompatible with the JDK (for example, a 64-bit JDK with a 32-bit Eclipse, or vice versa). Common error messages shown at the launcher may include Unable to find companion launcher or a cryptic message about being unable to find an SWT library.

On Windows, there is an additional eclipsec.exe launcher that allows log messages to be displayed on the console. This is sometimes useful if Eclipse fails to load and no other message is displayed. Other operating systems can use the eclipse command; and both support the -consolelog argument, which can display more diagnostic information about problems with launching Eclipse.

The Eclipse workspace is a directory used for two purposes: as the default project location, and to hold the .metadata directory containing Eclipse settings, preferences, and other runtime information. The Eclipse runtime log is stored in the .metadata/.log file.

The workspace chooser dialog has an option to set a default workspace. It can be changed within Eclipse by navigating to File | Switch Workspace. It can also be overridden by specifying a different workspace location with the -data command-line argument.

Finally, the welcome screen is useful for first-time users, but it is worth closing (rather than minimizing) once Eclipse has started.

Creating your first plug-in

In this task, Eclipse's plug-in wizard will be used to create a plug-in.

Time for action – creating a plug-in

In PDE, every plug-in has its own individual project. A plug-in project is typically created with the new project wizard, although it is also possible to upgrade an existing Java project to a plug-in project by adding the PDE nature and the required files by navigating to Configure | Convert to plug-in project.

To create a Hello World plug-in, navigate to File | New | Project…The project types shown may be different from this list but should include Plug-in Project with Eclipse IDE for Eclipse Committers or Eclipse SDK. If nothing is shown when you navigate to File | New, then navigate to Window | Open Perspective | Other | Plug-in Development first; the entries should then be seen under the New menu.Choose Plug-in Project and click on Next. Fill in the dialog as follows:
Project name should be com.packtpub.e4.hello.ui.Ensure that Use default location is selected.Ensure that Create a Java project is selected. The Eclipse version should be targeted to 3.5 or greater:
Click on Next again, and fill in the plug-in properties:
ID is set to com.packtpub.e4.hello.ui.Version is set to 1.0.0.qualifier.Name is set to Hello.Vendor is set to PacktPub.For Execution Environment, use the default (for example, JavaSE-1.8).Ensure that Generate an Activator is selected.Set Activator to com.packtpub.e4.hello.ui.Activator.Ensure that This plug-in will make contributions to the UI is selected.Rich client application should be No:
Click on Next and a set of templates will be provided:
Ensure that Create a plug-in using one of the templates is selected.Choose the Hello, World Command template:
Click on Next to customize the sample, including:
Java Package Name, which defaults to the project's name followed by .handlersHandler Class Name, which is the code that gets invoked for the actionMessage Box Text, which is the message to be displayed:
Finally, click on Finish and the project will be generated.If an Open Associated Perspective? dialog asks, click on Yes to show the Plug-in Development perspective.

What just happened?

Creating a plug-in project is the first step towards creating a plug-in for Eclipse. The new plug-in project wizard was used with one of the sample templates to create a project.

Plug-ins are typically named inreverse domain name format, so these examples will be prefixed with com.packtpub.e4. This helps to distinguish between many plug-ins; the stock Eclipse IDE for Eclipse Committers comes with more than 450 individual plug-ins; the Eclipse-developed ones start with org.eclipse.

Note

Conventionally, plug-ins that create additions to (or require) the use of the UI have .ui. in their name. This helps to distinguish those that don't, which can often be used headlessly. Of the more than 450 plug-ins that make up the Eclipse IDE for Eclipse Committers, approximately 120 are UI-related and the rest are headless.

The project contains a number of files that are automatically generated based on the content filled in the wizard. The key files in an Eclipse plug-in are:

META-INF/MANIFEST.MF: The MANIFEST.MF file, also known as the OSGi manifest, describes the plug-in's name, version, and dependencies. Double-clicking on it will open a custom editor, which shows the information entered in the wizards; or it can be opened in a standard text editor. The manifest follows standard Java conventions; line continuations are represented by a newline followed by a single space character, and the file must end with a newline.plugin.xml: The plugin.xml file declares what extensions the plug-in provides to the Eclipse runtime. Not all plug-ins need a plugin.xml file; headless (non-UI) plug-ins often don't need to have one. Extension points will be covered in more detail later; but the sample project creates an extension for the commands, handlers, bindings, and menus' extension points. Text labels for the commands/actions/menus are represented declaratively in the plugin.xml file, rather than programmatically; this allows Eclipse to show the menu before needing to load or execute any code.

Note

This is one of the reasons Eclipse starts so quickly; by not needing to load or execute classes, it can scale by showing what's needed at the time, and then load the class on demand when the user invokes the action. Java Swing's Action class provides labels and tooltips programmatically, which can result in slower initialization of Swing-based user interfaces.

build.properties: The build.properties file is used by PDE at development time and at build time. Generally it can be ignored, but if resources are added that need to be made available to the plug-in (such as images, properties files, HTML content and more), then an entry must be added here as otherwise it won't be found. Generally the easiest way to do this is by going to the Build tab of the build.properties file, which will gives a tree-like view of the project's contents. This file is an archaic hangover from the days of Ant builds, and is generally useless when using more up-to-date builds such as Maven Tycho, which will be covered in Chapter 12, Automated Builds with Tycho.

Pop quiz – Eclipse workspaces and plug-ins

Q1. What is an Eclipse workspace?

Q2. What is the naming convention for Eclipse plug-in projects?

Q3. What are the names of the three key files in an Eclipse plug-in?

Running plug-ins

To test an Eclipse plug-in, Eclipse is used to run or debug a new Eclipse instance with the plug-in installed.

Time for action – launching Eclipse from within Eclipse

Eclipse can launch a new Eclipse application by clicking on the run icon, or via the Run menu.

Select the plug-in project in the workspace. Click on the run icon to launch the project. The first time this happens, a dialog will be shown; subsequent launches will remember the chosen type: Choose the Eclipse Application type and click on OK. A new Eclipse instance will be launched.Close the Welcome page in the launched application, if shown.Click on the hello world icon in the menu bar, or navigate to Sample Menu | Sample Command from the menu, and the dialog box created via the wizard will be shown:Quit the target Eclipse instance by closing the window, or via the usual keyboard shortcuts or menus (Cmd + Q on macOS or Alt + F4 on Windows).

What just happened?

Upon clicking on run in the toolbar (or via Run | Run As | Eclipse Application) a launch configuration is created, which includes any plug-ins open in the workspace. A second copy of Eclipse—with its own temporary workspace—will enable the plug-in to be tested and verify that it works as expected.

The run operation is intelligent, in that it launches an application based on what is selected in the workspace. If a plug-in is selected, it will offer the opportunity to run as an Eclipse Application; if a Java project with a class with a main method, it will run it as a standard Java Application; and if it has tests, then it will offer to run the test launcher instead.

However, the run operation can also be counter-intuitive; if clicked a second time, and in a different project context, then something other than the expected launched might be run.

A list of the available launch configurations can be seen by going to the Run menu, or by going to the dropdown to the right of the run icon. The Run | Run Configurations menu shows all the available types, including any previously run:

By default, the runtime workspace is kept between runs. The launch configuration for an Eclipse application has options that can be customized; in the preceding screenshot, the Workspace Data section in the Main tab shows where the runtime workspace is stored, and an option is shown that allows the workspace to be cleared (with or without confirmation) between runs.

Launch configurations can be deleted by clicking on the red delete icon on the top left, and new launch configurations can be created by clicking on the new icon. Each launch configuration has a type:

Eclipse ApplicationJava AppletJava ApplicationJUnitJUnit Plug-in TestOSGi Framework

The launch configuration can be thought of as a pre-canned script that can launch different types of programs. Additional tabs are used to customize the launch, such as the environment variables, system properties, or command-line arguments. The type of the launch configuration specifies what parameters are required and how the launch is executed.

When a program is launched with the run icon, changes to the project's source code while it is running have no effect. However, as we'll see in the next section, if launched with the debug icon, changes can take effect.

If the target Eclipse is hanging or otherwise unresponsive, in the host Eclipse instance, the Console view (shown by navigating to Window | View | Show View | Other | General | Console menu) can be used to stop the target Eclipse instance.

Pop quiz: launching Eclipse

Q1. What are the two ways of terminating a launched Eclipse instance?

Q2. What are launch configurations?

Q3. How are launch configurations created and deleted?

Have a go hero – modifying the plug-in

Now that the Eclipse plug-in is running, try the following:

Change the message of the label and title of the dialog box to something elseInvoke the action by using the keyboard shortcut (defined in plugin.xml)Change the tooltip of the action to a different messageSwitch the action icon to a different graphic (if a different filename is used, remember to update it in plugin.xml and build.properties)

Debugging a plug-in

Since it's rare that everything works first time, it's often necessary to develop iteratively, adding progressively more functionality each time. Secondly, it's sometimes necessary to find out what's going on under the cover when trying to fix a bug, particularly if it's a hard-to-track-down exception such as NullPointerException.

Fortunately, Eclipse comes with excellent debugging support, which can be used to debug both standalone Java applications as well as Eclipse plug-ins.

Time for action – debugging a plug-in

Debugging an Eclipse plug-in is much the same as running an Eclipse plug-in, except that breakpoints can be used, the state of the program can be updated, and variables and minor changes to the code can be made. Rather than debugging plug-ins individually, the entire Eclipse launch configuration is started in debug mode. That way, all the plug-ins can be debugged at the same time.

Although run mode is slightly faster, the added flexibility of being able to make changes makes debug mode much more attractive to use as a default.

Start the target Eclipse instance by navigating to Debug | Debug As | Eclipse Application, or by clicking on debug in the toolbar.

Click on the hello world icon in the target Eclipse to display the dialog, as before, and click on OK to dismiss it.In the host Eclipse, open the SampleHandler class and go to the first line of the execute method.Add a breakpoint by double-clicking in the vertical ruler (the grey/blue bar on the left of the editor), or by pressing Ctrl + Shift + B (or Cmd + Shift + B on macOS). A blue dot representing the breakpoint will appear in the ruler:Click on the hello world icon in the target Eclipse to display the dialog, and the debugger will pause the thread at the breakpoint in the host Eclipse:

Note

The debugger perspective will open whenever a breakpoint is triggered and the program will be paused. While it is paused, the target Eclipse is unresponsive. Any clicks on the target Eclipse application will be ignored, and it will show a busy cursor.

In the top right, variables that are active in the line of code are shown. In this case, it's just the implicit variables (via this), any local variables (none yet), as well as the parameter (in this case, event).Click on Step Over or press F6, and window will be added to the list of available variables: When ready to continue, click on resume or press F8 to keep running.

What just happened?

The built-in Eclipse debugger was used to launch Eclipse in debug mode. By triggering an action that led to a breakpoint, the debugger was revealed, allowing the local variables to be inspected.

When in the debugger, there are several ways to step through the code:

Step Over: This allows stepping over line by line in the methodStep Into: This follows the method calls recursively as execution unfolds

Note

There is also a Run | Step into Selection menu item; it does not have a toolbar icon. It can be invoked with Ctrl + F5 (Alt + F5 on macOS) and is used to step into a specific expression.

Step Return: This jumps to the end of a methodDrop to Frame: This returns to a stack frame in the thread to re-run an operation

Time for action – updating code in the debugger

When an Eclipse instance is launched in run mode, changes made to the source code aren't reflected in the running instance. However, debug mode allows changes made to the source to be reflected in the running target Eclipse instance.

Launch the target Eclipse in debug mode by clicking on the debug icon.Click on the hello world icon in the target Eclipse to display the dialog, as before, and click on OK to dismiss it. It may be necessary to remove or resume the breakpoint in the host Eclipse instance to allow execution to continue.In the host Eclipse, open the SampleHandler class and go to the execute method.Change the title of the dialog to Hello again, Eclipse world and save the file. Provided the Build Automatically option in Project menu is enabled, the change will be automatically recompiled.Click on the hello world icon in the target Eclipse instance again. The new message should be shown.

What just happened?

By default, Eclipse ships with the Build Automatically option in Project menu enabled. Whenever changes are made to Java files, they are recompiled along with their dependencies if necessary.

When a Java program is launched in run mode, it will load classes on demand and then keep using that definition until the JVM shuts down. Even if the classes are changed, the JVM won't notice that they have been updated, and so no differences will be seen in the running application.

However, when a Java program is launched in debug mode, whenever changes to classes are made, Eclipse will update the running JVM with the new code if possible. The limits to what can be replaced are controlled by the JVM through theJava Virtual Machine Tools Interface (JVMTI). Generally, updating an existing method and adding a new method or field will work, but changes to interfaces and superclasses may not be.

Note

The Hotspot JVM cannot replace classes if methods are added or interfaces are updated. Some JVMs have additional capabilities that can substitute more code on demand. Other JVMs, such as IBM's, can deal with a wider range of replacements.

Note that there are some types of changes that won't be picked up, for example, new extensions added to the plugin.xml file. In order to see these changes, it is possible to start and stop the plug-in through the command-line OSGi console, or restart Eclipse inside or outside of the host Eclipse to see the change.

Debugging with step filters

When debugging using Step Into, the code will frequently go into Java internals, such as the implementation of Java collections classes or other internal JVM classes. These don't usually add value, so fortunately Eclipse has a way of ignoring uninteresting classes.

Time for action – setting up step filtering

Step filters allow for uninteresting packages and classes to be ignored during step debugging.

Run the target Eclipse instance in debug mode.Ensure that a breakpoint is set at the start of the execute method of the SampleHandler class.Click on the hello world icon, and the debugger should open at the first line, as before.Click on Step Into five or six times. At each point, the code will jump to the next method in the expression, first through various methods in HandlerUtil and then into ExecutionEvent. Click on resume to continue. Open Preferences and then navigate to Java | Debug | Step Filtering. Select the Use Step Filters option.Click on Add Package and enter org.eclipse.ui, followed by a click on OK:Click on the hello world icon again.Click on Step Into as before. This time, the debugger goes straight to the getApplicationContext method in the ExecutionEvent class. Click on resume to continue. To make debugging more efficient by skipping accessors, go back to the Step Filters preference and select Filter Simple Getters from the Step Filters preferences page.Click on the hello world icon again.Click on Step Into as before.Instead of going into the getApplicationContext method, the execution will drop through to the getVariable method of the ExpressionContext class instead.

What just happened?

Step Filters allows uninteresting packages to be skipped, at least from the point of debugging. Typically, JVM internal classes (such as those beginning with sun or sunw) are not helpful when debugging and can easily be ignored. This also avoids debugging through the ClassLoader as it loads classes on demand.

Typically it makes sense to enable all the default packages in the Step Filters dialog, as it's pretty rare to need to debug any of the JVM libraries (internal or public interfaces). This means that when stepping through code, if a common method such as toString is called, debugging won't step through the internal implementation.

It also makes sense to filter out simple setters and getters (those that just set a variable or those that just return a variable). If the method is more complex (like the getVariable method previously), then it will still stop in the debugger.

Constructors and static initializers can also be filtered specifically.

Using different breakpoint types

Although it's possible to place a breakpoint anywhere in a method, a special breakpoint type exists that can fire on method entry, exit, or both. Breakpoints can also be customized to only fire in certain situations or when certain conditions are met.

Time for action – breaking at method entry and exit

Method breakpoints allow the user to see when a method is entered or exited.

Open the SampleHandler class, and go to the execute method.Double-click in the vertical ruler at the method signature, or select Toggle Method Breakpoint from the method in one of the Outline, Package Explorer or Members views.The breakpoint should be shown on the line:
public Object execute(...) throws ExecutionException {
Open the breakpoint properties by right-clicking on the breakpoint or via the Breakpoints view, which is shown in the Debug perspective. Set the breakpoint to trigger at method entry and method exit.Click on the hello world icon again. When the debugger stops at method entry, click on resume . When the debugger stops at method exit, click on resume .

What just happened?

The breakpoint triggers at the time the method enters and subsequently when the method's return