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 – animating the second hand


The second hand is drawn with a redraw on the Canvas, but this will need to be run periodically. If it is redrawn once per second, it can emulate a clock ticking.

Eclipse has a jobs plug-in, which would be just right for this task, but this will be covered in Chapter 4, Interacting with the User. So to begin with, a simple Thread will be used to issue the redraw.

  1. Open the ClockView class.

  2. Add the following at the bottom of the createPartControl method:

    Runnable redraw = () -> {
      while (!clock.isDisposed()) {
        clock.redraw();
        try {
          Thread.sleep(1000);
        } catch (InterruptedException e) {
          return;
        }
      }
    };
    new Thread(redraw, "TickTock").start();
  3. Relaunch the test Eclipse instance, and open the Clock View.

  4. Open the host Eclipse instance and look in the Console View for the errors.

What just happened?

When the ClockView is shown, a Thread is created and started, which redraws the clock once per second. When it is shown, an exception...