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

Time for action – getting in focus


To allow the time zone of the clock widgets to be changed, a drop-down box (known as Combo) as well as a Button will be added to the view. The Combo will be created from a set of ZoneId instances.

  1. Create a timeZones field in the ClockView class:

    private Combo timeZones;
  2. At the end of the createPartControl method, add this snippet to create the drop-down list:

    public void createPartControl(Composite parent) {
      ...
      timeZones = new Combo(parent, SWT.DROP_DOWN);
      timeZones.setVisibleItemCount(5);
      for (String zone : ZoneId.getAvailableZoneIds()) {
        timeZones.add(zone);
      }
    }
  3. Run the target Eclipse and open the Clock View again; a list of time zone names will be shown in a drop-down:

  4. It's conventional to set the focus on a particular widget when a view is opened. Implement the appropriate call in the ClockView method setFocus:

    public void setFocus() {
      timeZones.setFocus();
    }
  5. Run Eclipse and show the Clock View; the time zone drop-down widget will be focused...