Book Image

Eclipse Plug-in Development Beginner's Guide - Second Edition

By : Alex Blewitt
Book Image

Eclipse Plug-in Development Beginner's Guide - Second Edition

By: Alex Blewitt

Overview of this book

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.
Table of Contents (24 chapters)
Eclipse Plug-in Development Beginner's Guide Second Edition
Credits
Foreword
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Chapter 3 – Creating JFace Viewers


Understanding JFace

1. getImage() is called to determine what image to show for an entry, while getText() is used to determine the text value of an entry.

2. The hasChildren() method is used to determine whether or not an element is shown with an expandable element, and getChildren() is used to calculate a list of children.

3. An ImageRegistry is used to share images between plug-ins or different views in plug-ins, with a means of clearing up the resources when the view is disposed.

4. Entries can be styled with an IStyledLabelProvider.

Understanding sorting and filters

1. Specifying a ViewerComparator can allow elements to be sorted in a different order other than the default one.

2. The select() method is used to filter elements, which is originally derived from the Smalltalk terminology.

3. Multiple filters can be combined by setting an array of filters, or by writing a filter to combine two or more filters together.

Understanding interaction

1. Add a DoubleClickListener to the view.

2. Dialog subclasses are used to create a Dialog with custom content.

Understanding tables

1. To show the headers, get the Table from the viewer, and use it to call the setHeaderVisible(true).

2. TableViewerColumn instances are used to set properties on individual columns and to bind the label provider for the columns.

3. An ArrayContentProvider can be used to store items as an array.

4. The TableViewerColumn is a class in the JFace package which defines where the data comes from; the TableColumn is the underlying SWT widget that the width of the column.

Understanding selection

1. Viewers have the getSelection and setSelection methods to get and set the selection, using the ISelection interface (or more commonly the IStructuredSelection interface).

2. The ISelectionChangedListener interface is used to receive notifications for selection changes from a viewer.

3. E4 uses the ESelectionService to maintain the selected object in the workspace, which can be injected into a part.

4. Although the currently selected object can be injected as a field into a part, it is more common to use an optional method with a @Named argument of IServiceConstants.ACTIVE_SELECTION.