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

This is a truly hands-on book for developing Eclipse plug-ins. A whole series of “Time for Action” sections gets you involved in practical examples that teach you everything from the very basics to more advanced activities.

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

Beginner's Guide
Dr Alex Blewitt

This is a truly hands-on book for developing Eclipse plug-ins. A whole series of “Time for Action” sections gets you involved in practical examples that teach you everything from the very basics to more advanced activities.
$26.99
$44.99
RRP $26.99
RRP $44.99
eBook
Print + eBook
$12.99 p/month

Get Access

Get Unlimited Access to every Packt eBook and Video course

Enjoy full and instant access to over 3000 books and videos – you’ll find everything you need to stay ahead of the curve and make sure you can always get the job done.

Book Details

ISBN 139781782160328
Paperback348 pages

About This Book

  • Create plug-ins to extend the Eclipse runtime covering Eclipse 3.x and the changes required for Eclipse 4.x
  • Plug-ins from design to distribution — wide coverage of the entire process
  • No prior OSGi or Eclipse plug-in development experience necessary

Who This Book Is For

This book is for Java developers who are familiar with Eclipse as a Java IDE and are interested in learning how to develop plug-ins for Eclipse. No prior knowledge of Eclipse plug-in development or OSGi is necessary, although you are expected to know how to create, run, and debug Java programs in Eclipse.

Table of Contents

Chapter 1: Creating Your First Plug-in
Getting started
Time for action – setting up the Eclipse SDK environment
Creating your first plug-in
Time for action – creating a plug-in
Running plug-ins
Time for action – launching Eclipse from within Eclipse
Debugging a plug-in
Time for action – debugging a plug-in
Time for action – updating code in debugger
Debugging with step filters
Time for action – setting up step filtering
Using different breakpoint types
Time for action – breaking at method entry and exit
Using conditional breakpoints
Time for action – setting a conditional breakpoint
Using exceptional breakpoints
Time for action – catching exceptions
Time for action – using watch variables and expressions
Summary
Chapter 2: Creating Views with SWT
Creating views and widgets
Time for action – creating a view
Time for action – drawing a custom view
Time for action – drawing a second hand
Time for action – animating the second hand
Time for action – running on the UI thread
Time for action – creating a reusable widget
Time for action – using layouts
Managing resources
Time for action – getting colorful
Time for action – finding the leak
Time for action – plugging the leak
Interacting with the user
Time for action – getting in focus
Time for action – responding to input
Using other SWT widgets
Time for action – adding items to the tray
Time for action – responding to the user
Time for action – modal and other effects
Time for action – groups and tab folders
Summary
Chapter 3: Creating JFace Viewers
Why JFace?
Creating TreeViewers
Time for action – creating a TreeViewer
Time for action – using Images in JFace
Time for action – styling label providers
Sorting and filtering
Time for action – sorting items in a viewer
Time for action – filtering items in a viewer
Interaction and properties
Time for action – adding a double-click listener
Time for action – showing properties
Tabular data
Time for action – viewing time zones in tables
Time for action – syncing selection
Summary
Chapter 4: Interacting with the User
Creating actions, commands, and handlers
Time for action – adding context menus
Time for action – creating commands and handlers
Time for action – binding commands to keys
Time for action – changing contexts
Time for action – enabling and disabling the menu's items
Time for action – reusing expressions
Time for action – contributing commands to pop-up menus
Jobs and progress
Time for action – running operations in the background
Time for action – reporting progress
Time for action – dealing with cancellation
Time for action – using subtasks and subprogress monitors
Time for action – using null progress monitors and submonitors
Time for action – setting job properties
Reporting errors
Time for action – showing errors
Summary
Chapter 5: Storing Preferences and Settings
Storing preferences
Time for action – persisting a value
Time for action – creating a preference page
Time for action – creating warning and error messages
Time for action – choosing from a list
Time for action – using a grid
Time for action – placing the preferences page
Time for action – using other field editors
Time for action – adding keywords
Time for action: using IEclipsePreferences
Using IMemento and DialogSettings
Time for action – adding a memento for the Time Zone View
Time for action – using DialogSettings
Summary
Chapter 6: Working with Resources
Using the workspace and resources
Time for action – creating an editor
Time for action – writing the markup parser
Time for action – building the builder
Time for action – iterating through resources
Time for action – creating resources
Time for action – implementing incremental builds
Time for action – handling deletion
Using natures
Time for action – creating a nature
Using markers
Time for action – error markers if the file is empty
Time for action – registering a marker type
Summary
Chapter 7: Understanding the Eclipse 4 Model
Working with the Eclipse 4 model
Time for action – installing E4 tooling
Time for action – creating an E4 application
Time for action – creating a part
Time for action – styling the UI with CSS
Using services and contexts
Time for action – adding logging
Time for action – getting the window
Time for action – obtaining the selection
Time for action – dealing with events
Time for action – calculating values on demand
Time for action – using preferences
Time for action – interacting with the UI
Using Commands, Handlers, and MenuItems
Time for action – wiring a menu to a command with a handler
Time for action – passing command parameters
Time for action – creating a direct menu and keybindings
Time for action – creating a pop-up menu and a view menu
Creating custom injectable classes
Time for action – creating a simple service
Time for action – injecting subtypes
Summary
Chapter 8: Creating Features, Update Sites, Applications, and Products
Grouping plug-ins with features
Time for action – creating a feature
Time for action – exporting a feature
Time for action – installing a feature
Time for action – categorizing the update site
Time for action – depending on other features
Time for action – branding features
Building applications and products
Time for action – creating a headless application
Time for action – creating a product
Summary
Chapter 9: Automated Testing of Plug-ins
Using JUnit for automated testing
Time for action – writing a simple JUnit test case
Time for action – writing a plug-in test
Using SWTBot for user interface testing
Time for action – writing an SWTBot test
Time for action – working with menus
Working with SWTBot
Time for action – hiding the welcome screen
Time for action – avoiding SWTBot runtime errors
Working with views
Time for action – showing views
Time for action – interrogating views
Interacting with the UI
Time for action – getting values from the UI
Time for action – waiting for a condition
Summary
Chapter 10: Automated Builds with Tycho
Using Maven to build Eclipse plug-ins with Tycho
Time for action – installing Maven
Time for action – building with Tycho
Building features and update sites with Tycho
Time for action – creating a parent project
Time for action – building a feature
Time for action – building an update site
Time for action – building a product
Testing and releasing
Time for action – running automated tests
Time for action – changing the version numbers
Signing update sites
Time for action – creating a self-signed certificate
Time for action – signing the plug-ins
Time for action – serving an update site
Summary

What You Will Learn

  • How to create plug-ins for Eclipse 3.x and 4.x and automatically test plug-ins with JUnit
  • How to display tree and table information in views
  • What are the specific differences between the Eclipse 3.x model and the Eclipse 4.x model
  • How and when to build user interfaces from SWT and JFace
  • How to run tasks in the background and update the user interface asynchronously
  • How to build plug-ins, features and update sites with Maven Tycho and automate user interface tests with SWTBot
  • How to store and obtain preferences, and how to integrate with the Preferences panel
  • How to work with the Eclipse resources model for creating and updating files and reporting errors to the user

In Detail

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.

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

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.

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.

Authors

Table of Contents

Chapter 1: Creating Your First Plug-in
Getting started
Time for action – setting up the Eclipse SDK environment
Creating your first plug-in
Time for action – creating a plug-in
Running plug-ins
Time for action – launching Eclipse from within Eclipse
Debugging a plug-in
Time for action – debugging a plug-in
Time for action – updating code in debugger
Debugging with step filters
Time for action – setting up step filtering
Using different breakpoint types
Time for action – breaking at method entry and exit
Using conditional breakpoints
Time for action – setting a conditional breakpoint
Using exceptional breakpoints
Time for action – catching exceptions
Time for action – using watch variables and expressions
Summary
Chapter 2: Creating Views with SWT
Creating views and widgets
Time for action – creating a view
Time for action – drawing a custom view
Time for action – drawing a second hand
Time for action – animating the second hand
Time for action – running on the UI thread
Time for action – creating a reusable widget
Time for action – using layouts
Managing resources
Time for action – getting colorful
Time for action – finding the leak
Time for action – plugging the leak
Interacting with the user
Time for action – getting in focus
Time for action – responding to input
Using other SWT widgets
Time for action – adding items to the tray
Time for action – responding to the user
Time for action – modal and other effects
Time for action – groups and tab folders
Summary
Chapter 3: Creating JFace Viewers
Why JFace?
Creating TreeViewers
Time for action – creating a TreeViewer
Time for action – using Images in JFace
Time for action – styling label providers
Sorting and filtering
Time for action – sorting items in a viewer
Time for action – filtering items in a viewer
Interaction and properties
Time for action – adding a double-click listener
Time for action – showing properties
Tabular data
Time for action – viewing time zones in tables
Time for action – syncing selection
Summary
Chapter 4: Interacting with the User
Creating actions, commands, and handlers
Time for action – adding context menus
Time for action – creating commands and handlers
Time for action – binding commands to keys
Time for action – changing contexts
Time for action – enabling and disabling the menu's items
Time for action – reusing expressions
Time for action – contributing commands to pop-up menus
Jobs and progress
Time for action – running operations in the background
Time for action – reporting progress
Time for action – dealing with cancellation
Time for action – using subtasks and subprogress monitors
Time for action – using null progress monitors and submonitors
Time for action – setting job properties
Reporting errors
Time for action – showing errors
Summary
Chapter 5: Storing Preferences and Settings
Storing preferences
Time for action – persisting a value
Time for action – creating a preference page
Time for action – creating warning and error messages
Time for action – choosing from a list
Time for action – using a grid
Time for action – placing the preferences page
Time for action – using other field editors
Time for action – adding keywords
Time for action: using IEclipsePreferences
Using IMemento and DialogSettings
Time for action – adding a memento for the Time Zone View
Time for action – using DialogSettings
Summary
Chapter 6: Working with Resources
Using the workspace and resources
Time for action – creating an editor
Time for action – writing the markup parser
Time for action – building the builder
Time for action – iterating through resources
Time for action – creating resources
Time for action – implementing incremental builds
Time for action – handling deletion
Using natures
Time for action – creating a nature
Using markers
Time for action – error markers if the file is empty
Time for action – registering a marker type
Summary
Chapter 7: Understanding the Eclipse 4 Model
Working with the Eclipse 4 model
Time for action – installing E4 tooling
Time for action – creating an E4 application
Time for action – creating a part
Time for action – styling the UI with CSS
Using services and contexts
Time for action – adding logging
Time for action – getting the window
Time for action – obtaining the selection
Time for action – dealing with events
Time for action – calculating values on demand
Time for action – using preferences
Time for action – interacting with the UI
Using Commands, Handlers, and MenuItems
Time for action – wiring a menu to a command with a handler
Time for action – passing command parameters
Time for action – creating a direct menu and keybindings
Time for action – creating a pop-up menu and a view menu
Creating custom injectable classes
Time for action – creating a simple service
Time for action – injecting subtypes
Summary
Chapter 8: Creating Features, Update Sites, Applications, and Products
Grouping plug-ins with features
Time for action – creating a feature
Time for action – exporting a feature
Time for action – installing a feature
Time for action – categorizing the update site
Time for action – depending on other features
Time for action – branding features
Building applications and products
Time for action – creating a headless application
Time for action – creating a product
Summary
Chapter 9: Automated Testing of Plug-ins
Using JUnit for automated testing
Time for action – writing a simple JUnit test case
Time for action – writing a plug-in test
Using SWTBot for user interface testing
Time for action – writing an SWTBot test
Time for action – working with menus
Working with SWTBot
Time for action – hiding the welcome screen
Time for action – avoiding SWTBot runtime errors
Working with views
Time for action – showing views
Time for action – interrogating views
Interacting with the UI
Time for action – getting values from the UI
Time for action – waiting for a condition
Summary
Chapter 10: Automated Builds with Tycho
Using Maven to build Eclipse plug-ins with Tycho
Time for action – installing Maven
Time for action – building with Tycho
Building features and update sites with Tycho
Time for action – creating a parent project
Time for action – building a feature
Time for action – building an update site
Time for action – building a product
Testing and releasing
Time for action – running automated tests
Time for action – changing the version numbers
Signing update sites
Time for action – creating a self-signed certificate
Time for action – signing the plug-ins
Time for action – serving an update site
Summary

Book Details

ISBN 139781782160328
Paperback348 pages
Read More