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 values from the UI


If the test tries to access a property from the returned widget, there will be an exception thrown. For example, ctabs.get(0).getText() will result in an Invalid thread access SWT error.

To perform testing on widgets, the code has to run in the UI thread. Either the Display.getDefault().syncExec() or the equivalent Synchronizer class can be used, but SWTBot has a UIThreadRunnable that can launch code and a general interface called StringResult, which is like a Runnable that can return a String value through syncExec.

  1. At the end of the testTimeZone method of the UITest class, create a new StringResult and pass it to UIThreadRunnable.syncExec().

  2. In the run method, get the first CTabItem and return its text value.

  3. After the Runnable method has run, assert that the value is Africa.

  4. The code looks like:

    String tabText = UIThreadRunnable.syncExec(new StringResult() {
      @Override
      public String run() {
        return ctabs.get(0).getText();
      }
    });
    assertEquals...